protected function setUp()
 {
     parent::setUp();
     $b1 = new BookstoreEmployee();
     $b1->setName('b1');
     $b1->save();
     $b2 = new BookstoreManager();
     $b2->setName('b2');
     $b2->save();
     $b3 = new BookstoreCashier();
     $b3->setName('b3');
     $b3->save();
 }
Ejemplo n.º 2
0
 /**
  * Test inheritance features.
  */
 public function testInheritance()
 {
     $manager = new BookstoreManager();
     $manager->setName("Manager 1");
     $manager->setJobTitle("Warehouse Manager");
     $manager->save();
     $managerId = $manager->getId();
     $employee = new BookstoreEmployee();
     $employee->setName("Employee 1");
     $employee->setJobTitle("Janitor");
     $employee->setSupervisorId($managerId);
     $employee->save();
     $empId = $employee->getId();
     $cashier = new BookstoreCashier();
     $cashier->setName("Cashier 1");
     $cashier->setJobTitle("Cashier");
     $cashier->save();
     $cashierId = $cashier->getId();
     // 1) test the pooled instances'
     $c = new Criteria();
     $c->add(BookstoreEmployeePeer::ID, array($managerId, $empId, $cashierId), Criteria::IN);
     $c->addAscendingOrderByColumn(BookstoreEmployeePeer::ID);
     $objects = BookstoreEmployeePeer::doSelect($c);
     $this->assertEquals(3, count($objects), "Expected 3 objects to be returned.");
     list($o1, $o2, $o3) = $objects;
     $this->assertSame($o1, $manager);
     $this->assertSame($o2, $employee);
     $this->assertSame($o3, $cashier);
     // 2) test a forced reload from database
     BookstoreEmployeePeer::clearInstancePool();
     list($o1, $o2, $o3) = BookstoreEmployeePeer::doSelect($c);
     $this->assertTrue($o1 instanceof BookstoreManager, "Expected BookstoreManager object, got " . get_class($o1));
     $this->assertTrue($o2 instanceof BookstoreEmployee, "Expected BookstoreEmployee object, got " . get_class($o2));
     $this->assertTrue($o3 instanceof BookstoreCashier, "Expected BookstoreCashier object, got " . get_class($o3));
 }