PHP Classes

File: vendor/gabordemooij/redbean/testing/RedUNIT/Blackhole/Labels.php

Recommend this page to a friend!
  Classes of Adrian M   upMVC   vendor/gabordemooij/redbean/testing/RedUNIT/Blackhole/Labels.php   Download  
File: vendor/gabordemooij/redbean/testing/RedUNIT/Blackhole/Labels.php
Role: Class source
Content type: text/plain
Description: Class source
Class: upMVC
Pure PHP web development without other frameworks
Author: By
Last change:
Date: 25 days ago
Size: 1,304 bytes
 

Contents

Class file image Download
<?php

namespace RedUNIT\Blackhole;

use
RedUNIT\Blackhole as Blackhole;
use
RedBeanPHP\Facade as R;
use
RedBeanPHP\OODBBean as OODBBean;

/**
 * Labels
 *
 * Labels are very simple beans, only having a title and an ID.
 * The idea behind labels is that they are very easy to generate
 * from a comma separated list and they can easily be converted
 * to such a list. Labels can be used for simplistic relations in the
 * database like tagging or enums.
 *
 * @file RedUNIT/Blackhole/Labels.php
 * @desc Tests Facade Label functions.
 * @author Gabor de Mooij and the RedBeanPHP Community
 * @license New BSD/GPLv2
 *
 * (c) G.J.G.T. (Gabor) de Mooij and the RedBeanPHP Community.
 * This source file is subject to the New BSD/GPLv2 License that is bundled
 * with this source code in the file license.txt.
 */

class Labels extends Blackhole
{
   
/**
     * Test basic labels.
     *
     * @return void
     */
   
public function testLabels()
    {
       
testpack( 'Test Labels' );
       
$meals = R::dispenseLabels( 'meal', array( 'meat', 'fish', 'vegetarian' ) );
       
asrt( is_array( $meals ), TRUE );
       
asrt( count( $meals ), 3 );
        foreach (
$meals as $m ) {
           
asrt( ( $m instanceof OODBBean ), TRUE );
        }
       
$listOfMeals = implode( ',', R::gatherLabels( $meals ) );
       
asrt( $listOfMeals, 'fish,meat,vegetarian' );
    }
}