コード例 #1
0
ファイル: ItemTest.php プロジェクト: mheydt/scalr
 /**
  * @test
  */
 public function testConstructor()
 {
     $pathPart = $this->getMock('Scalr\\Api\\Rest\\Routing\\PathPart');
     $item = new Item($pathPart);
     $this->assertInternalType('array', $item->routes);
     $this->assertEquals([], $item->routes);
     $this->assertEquals($pathPart, $item->getPathPart());
     $this->assertInstanceOf('Scalr\\Api\\Rest\\Routing\\Table', $item->getTable());
     $this->assertEquals(0, count($item->getTable()));
     $this->assertSubClassOf('Traversable', $item->getTable());
 }
コード例 #2
0
 /**
  * @test
  */
 public function testConstructor()
 {
     $stringItem = new Item(new PathPart('string'));
     $regexpItem = new Item(new PathPart('~^[\\d]+$~', PathPart::TYPE_REGEXP));
     $this->assertTrue($stringItem->getPathPart()->isString());
     $this->assertTrue($regexpItem->getPathPart()->isRegexp());
     $iterator = new RegexpItemIterator(new \ArrayIterator([$stringItem, $regexpItem, $stringItem, $stringItem, $regexpItem]));
     $count = 0;
     foreach ($iterator as $item) {
         /* @var $item Item */
         $this->assertFalse($item->getPathPart()->isString());
         $count++;
     }
     $this->assertEquals(2, $count);
 }