예제 #1
0
 public function testContainerAnyEvery()
 {
     $container = new Container($a = new EBTC(1, 'a'), $b = new EBTC(2, 'b'), $c = new EBTC(3, 'c'));
     $isEven = function ($entity) {
         return $entity->id % 2 === 0;
     };
     $nameC = function ($entity) {
         return $entity->name === 'c';
     };
     $alwaysTrue = function ($entity) {
         return true;
     };
     $this->assertTrue($container->any($isEven));
     $this->assertTrue($container->any($nameC));
     $this->assertTrue($container->any($alwaysTrue));
     $this->assertFalse($container->every($isEven));
     $this->assertFalse($container->every($nameC));
     $this->assertTrue($container->any($alwaysTrue));
     $container->remove($b);
     $this->assertFalse($container->any($isEven));
     $container->remove($a);
     $this->assertTrue($container->every($nameC));
     $container->remove($c);
     $this->assertTrue($container->every($alwaysTrue));
     $this->assertFalse($container->every($alwaysTrue, false));
     $this->assertFalse($container->any($alwaysTrue));
 }
예제 #2
0
 /**
  * Get all inherited Attributes
  * @return Container
  */
 public function getChildren()
 {
     $output = new BaseContainer();
     foreach ($this->getRelation()->getChildren() as $childRelation) {
         $childAttribute = $childRelation->getAttributeByName($this->name);
         $output->add($childAttribute, $childAttribute->getChildren());
     }
     return $output;
 }