3 namespace RedUNIT\Blackhole;
5 use RedUNIT\Blackhole as Blackhole;
6 use RedBeanPHP\Facade as R;
7 use RedBeanPHP\OODBBean as OODBBean;
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.
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
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.
28 class Labels extends Blackhole
35 public function testLabels()
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 );
44 $listOfMeals = implode( ',', R::gatherLabels( $meals ) );
45 asrt( $listOfMeals, 'fish,meat,vegetarian' );