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();
 }
 public function testDeleteAllFilter()
 {
     BookstoreDataPopulator::depopulate($this->con);
     $manager = new BookstoreManager();
     $manager->save($this->con);
     $cashier1 = new BookstoreCashier();
     $cashier1->save($this->con);
     $cashier2 = new BookstoreCashier();
     $cashier2->save($this->con);
     BookstoreManagerQuery::create()->deleteAll();
     $nbCash = BookstoreEmployeeQuery::create()->count();
     $this->assertEquals(2, $nbCash, 'Delete in sub query affects only child results');
 }
 public function testFindPkSimpleWithSingleTableInheritanceReturnCorrectClass()
 {
     Propel::disableInstancePooling();
     $employee = new BookstoreEmployee();
     $employee->save($this->con);
     $manager = new BookstoreManager();
     $manager->save($this->con);
     $cashier1 = new BookstoreCashier();
     $cashier1->save($this->con);
     $cashier2 = new BookstoreCashier();
     $cashier2->save($this->con);
     $this->assertInstanceOf('BookstoreEmployee', BookstoreEmployeeQuery::create()->findPk($employee->getId()), 'findPk() return right object : BookstoreEmployee');
     $this->assertInstanceOf('BookstoreManager', BookstoreEmployeeQuery::create()->findPk($manager->getId()), 'findPk() return right object : BookstoreManager');
     $this->assertInstanceOf('BookstoreCashier', BookstoreEmployeeQuery::create()->findPk($cashier1->getId()), 'findPk() return right object : BookstoreCashier');
     $this->assertInstanceOf('BookstoreCashier', BookstoreEmployeeQuery::create()->findPk($cashier2->getId()), 'findPk() return right object : BookstoreCashier');
     Propel::enableInstancePooling();
 }
 /**
  * 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));
 }