/** * @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()); }
/** * @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); }