Yaffs site version 1.1
[yaffs-website] / vendor / gabordemooij / redbean / testing / RedUNIT / Blackhole / Labels.php
1 <?php
2
3 namespace RedUNIT\Blackhole;
4
5 use RedUNIT\Blackhole as Blackhole;
6 use RedBeanPHP\Facade as R;
7 use RedBeanPHP\OODBBean as OODBBean;
8
9 /**
10  * Labels
11  *
12  * Labels are very simple beans, only having a title and an ID.
13  * The idea behind labels is that they are very easy to generate
14  * from a comma separated list and they can easily be converted
15  * to such a list. Labels can be used for simplistic relations in the
16  * database like tagging or enums.
17  *
18  * @file    RedUNIT/Blackhole/Labels.php
19  * @desc    Tests Facade Label functions.
20  * @author  Gabor de Mooij and the RedBeanPHP Community
21  * @license New BSD/GPLv2
22  *
23  * (c) G.J.G.T. (Gabor) de Mooij and the RedBeanPHP Community.
24  * This source file is subject to the New BSD/GPLv2 License that is bundled
25  * with this source code in the file license.txt.
26  */
27
28 class Labels extends Blackhole
29 {
30         /**
31          * Test basic labels.
32          *
33          * @return void
34          */
35         public function testLabels()
36         {
37                 testpack( 'Test Labels' );
38                 $meals = R::dispenseLabels( 'meal', array( 'meat', 'fish', 'vegetarian' ) );
39                 asrt( is_array( $meals ), TRUE );
40                 asrt( count( $meals ), 3 );
41                 foreach ( $meals as $m ) {
42                         asrt( ( $m instanceof OODBBean ), TRUE );
43                 }
44                 $listOfMeals = implode( ',', R::gatherLabels( $meals ) );
45                 asrt( $listOfMeals, 'fish,meat,vegetarian' );
46         }
47 }