public function testFormatSingleTableInheritanceManyResults() { $con = Propel::getConnection(BookPeer::DATABASE_NAME); BookstoreDataPopulator::populate($con); $stmt = $con->query('SELECT * FROM bookstore_employee'); $formatter = new PropelOnDemandFormatter(); $formatter->init(new ModelCriteria('bookstore', 'BookstoreEmployee')); $employees = $formatter->format($stmt); foreach ($employees as $employee) { $row = array(); $row[1] = $employee->getClassKey(); $omClass = BookstoreEmployeePeer::getOMClass($row, 0, false); $actualClass = get_class($employee); $this->assertEquals($omClass, $actualClass, 'PropelOnDemandFormatter::format() should handle single table inheritance'); } }
public function testFormatNoResult() { $con = Propel::getConnection(BookPeer::DATABASE_NAME); $stmt = $con->query('SELECT * FROM book WHERE book.TITLE = "foo"'); $formatter = new PropelOnDemandFormatter(); $formatter->init(new ModelCriteria('bookstore', 'Book')); $books = $formatter->format($stmt); $this->assertTrue($books instanceof PropelOnDemandCollection, 'PropelOnDemandFormatter::format() returns a PropelCollection'); $this->assertEquals(0, count($books), 'PropelOnDemandFormatter::format() returns an empty collection when no record match the query'); foreach ($books as $book) { $this->fail('PropelOnDemandFormatter returns an empty iterator when no record match the query'); } }