Example #1
0
 public function testAddInput_Directories()
 {
     $input = new \vc\App\Paths();
     $this->assertSame($input, $input->addInput(\r8\FileSys::create($this->dir . '/third')));
     $value = \r8\Test\Constraint\Iterator::iteratorToArray(10, $input);
     $this->assertEquals(5, count($value));
     $this->assertEquals(array(0, 1, 2, 3, 4), array_keys($value));
     $this->assertSame('third-one', $value[0]->getBaseName());
     $this->assertSame('fourth-two', $value[1]->getBaseName());
     $this->assertSame('fourth-one', $value[2]->getBaseName());
     $this->assertSame('third-two', $value[3]->getBaseName());
     $this->assertSame('third-three', $value[4]->getBaseName());
 }
Example #2
0
 public function testIteration_many()
 {
     $iterator = new \r8\Iterator\DOMNodeList($this->runTestXPath("/doc/*"));
     $result = \r8\Test\Constraint\Iterator::iteratorToArray(10, $iterator);
     $this->assertSame(4, count($result));
     $this->assertArrayHasKey(0, $result);
     $this->assertArrayHasKey(1, $result);
     $this->assertArrayHasKey(2, $result);
     $this->assertArrayHasKey(3, $result);
     $this->assertThat($result[0], $this->isInstanceOf("DOMElement"));
     $this->assertThat($result[1], $this->isInstanceOf("DOMElement"));
     $this->assertThat($result[2], $this->isInstanceOf("DOMElement"));
     $this->assertThat($result[3], $this->isInstanceOf("DOMElement"));
     $this->assertSame("one", $result[0]->tagName);
     $this->assertSame("two", $result[1]->tagName);
     $this->assertSame("three", $result[2]->tagName);
     $this->assertSame("four", $result[3]->tagName);
 }
Example #3
0
 public function testIterate_ArrayAccess()
 {
     $data = array($this->getArrayAccess(array("num" => 5, "color" => "blue")), $this->getArrayAccess(array("num" => 5, "color" => "red")), $this->getArrayAccess(array("color" => "red")), $this->getArrayAccess(array("num" => 6, "color" => "red")), $this->getArrayAccess(array("num" => NULL, "color" => "blue")));
     $iter = new \r8\Iterator\Group("num", new ArrayIterator($data));
     $this->assertEquals(array(5 => array($data[0], $data[1]), 6 => array($data[3])), \r8\Test\Constraint\Iterator::iteratorToArray(10, $iter, TRUE));
 }