Пример #1
0
 /**
  * @param mixed $definition
  *
  * @dataProvider providerDefinitions
  */
 public function testHasAndRemove($definition)
 {
     $di = new Container();
     $di->set('test', $definition);
     $this->assertTrue($di->has('test'));
     $di->remove('test');
     $this->assertFalse($di->has('test'));
 }
 public function remove($key)
 {
     $key = $this->findKey($key);
     if ($key === false) {
         return;
     }
     return parent::remove($key);
 }
 function test_generic_container()
 {
     $comp = new Container(new FlowLayout(), MENU, 5);
     $c = new Component("Hello!", FOOTER, 4);
     $c1 = $comp->add($c, "12px", "2em", LEFT, BOTTOM);
     $this->assertReference($c1, $c);
     $this->assertReference($comp->getComponent(1), $c);
     $this->assertIdentical($comp->getComponentWidth(1), "12px");
     $this->assertIdentical($comp->getComponentHeight(1), "2em");
     $this->assertIdentical($comp->getComponentAlignmentX(1), LEFT);
     $this->assertIdentical($comp->getComponentAlignmentY(1), BOTTOM);
     $this->assertIdentical($comp->getComponentsCount(), 1);
     $c = new Component("Hello!", MENU_ITEM_LINK_SELECTED, 2);
     $c2 = $comp->add($c, "16px", "6em", RIGHT, CENTER);
     $this->assertReference($c2, $c);
     $this->assertReference($comp->getComponent(2), $c);
     $this->assertIdentical($comp->getComponentsCount(), 2);
     $c = new Component("Hello!", MENU_ITEM_LINK_UNSELECTED, 5);
     $c3 = $comp->add($c, "6px", "2em", CENTER, TOP);
     $this->assertReference($c3, $c);
     $this->assertReference($comp->getComponent(3), $c);
     $this->assertIdentical($comp->getComponentsCount(), 3);
     $c = $comp->remove(2);
     $this->assertReference($c, $c2);
     $this->assertNull($comp->getComponent(2));
     $this->assertIdentical($comp->getComponentsCount(), 2);
     $comp->removeAll();
     $this->assertIdentical($comp->_components, array());
     $this->assertIdentical($comp->getComponentsCount(), 0);
 }
Пример #4
0
 /**
  * @param Container $container
  * @depends testMakeContainer
  */
 public function testRemove(Container $container)
 {
     $this->assertEquals('H', $container->remove('h'));
     $this->assertFalse($container->has('h'));
 }