prophesize('common_persistence_SqlPersistence'); $statementProphecy = $this->prophesize('PDOStatement'); $statementValue = [ "modelid" => 1, "subject" => '#subject', "predicate" => '#predicate', "object" => 'obb', "id" => 898, "l_language" => 'en-US', "author" => 'testauthor' ]; $statementValue2 = [ "modelid" => 1, "subject" => '#subject2', "predicate" => '#predicate2', "object" => 'ob2', "id" => 899, "l_language" => 'en-US', "author" => 'testauthor' ]; $return = new ReturnPromise([ $statementValue, $statementValue2, false ]); $statementProphecy->fetch()->will($return); $plop = $statementProphecy->reveal(); $query = 'SELECT * FROM statements ORDER BY id'; $finalQuery = $query . ' LIMIT 100'; $platformProphecy = $this->prophesize('common_persistence_sql_Platform'); $platformProphecy->limitStatement($query, 100, 0)->willReturn($finalQuery); $platform = $platformProphecy->reveal(); $persistenceProphecy->getPlatForm()->willReturn($platform); $persistenceProphecy ->query($finalQuery, Argument::type('array'), Argument::type('array')) ->willReturn($plop); $iterator = new \core_kernel_persistence_smoothsql_SmoothIterator($persistenceProphecy->reveal()); return $iterator; } public function testConstruct() { $this->assertInstanceOf('core_kernel_persistence_smoothsql_SmoothIterator', $this->createIterator()); } /** * @author Lionel Lecaque, lionel@taotesting.com */ public function testCurrent() { $iterator = $this->createIterator(); $this->assertTrue($iterator->valid()); $current = $iterator->current(); $this->assertInstanceOf('core_kernel_classes_Triple', $current); $this->assertSame(1, $current->modelid); $this->assertSame('#subject', $current->subject); $this->assertSame('#predicate', $current->predicate); $this->assertSame('obb', $current->object); $this->assertSame(898, $current->id); $this->assertSame('en-US', $current->lg); } /** * @author Lionel Lecaque, lionel@taotesting.com */ public function testNext() { $iterator = $this->createIterator(); $iterator->next(); $this->assertTrue($iterator->valid()); $current = $iterator->current(); $this->assertInstanceOf('core_kernel_classes_Triple', $current); $this->assertSame(1, $current->modelid); $this->assertSame('#subject2', $current->subject); $this->assertSame('#predicate2', $current->predicate); $this->assertSame('ob2', $current->object); $this->assertSame(899, $current->id); $this->assertSame('en-US', $current->lg); } }