public function testFormat()
 {
     $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
     BookstoreEmployeeTableMap::clearInstancePool();
     $stmt = $con->query('SELECT id, class_key, name, job_title, supervisor_id, photo FROM bookstore_employee');
     $formatter = new ObjectFormatter();
     $formatter->init(new ModelCriteria('bookstore', 'Propel\\Tests\\Bookstore\\BookstoreEmployee'));
     $emps = $formatter->format($stmt);
     $expectedClass = ['b1' => 'Propel\\Tests\\Bookstore\\BookstoreEmployee', 'b2' => 'Propel\\Tests\\Bookstore\\BookstoreManager', 'b3' => 'Propel\\Tests\\Bookstore\\BookstoreCashier'];
     foreach ($emps as $emp) {
         $this->assertEquals($expectedClass[$emp->getName()], get_class($emp), 'format() creates objects of the correct class when using inheritance');
     }
 }
Пример #2
0
 public function testFormatOneNoResult()
 {
     $con = Propel::getServiceContainer()->getConnection(BookPeer::DATABASE_NAME);
     $stmt = $con->query('SELECT * FROM book WHERE book.TITLE = "foo"');
     $formatter = new ObjectFormatter();
     $formatter->init(new ModelCriteria('bookstore', '\\Propel\\Tests\\Bookstore\\Book'));
     $book = $formatter->formatOne($stmt);
     $this->assertNull($book, 'ObjectFormatter::formatOne() returns null when no result');
 }
Пример #3
0
 public function init(ModelCriteria $criteria)
 {
     parent::init($criteria);
     $this->isSingleTableInheritance = $criteria->getTableMap()->isSingleTableInheritance();
     return $this;
 }
 public function init(BaseModelCriteria $criteria = null, DataFetcherInterface $dataFetcher = null)
 {
     parent::init($criteria, $dataFetcher);
     $this->isSingleTableInheritance = $criteria->getTableMap()->isSingleTableInheritance();
     return $this;
 }