コード例 #1
0
 /**
  * Test foreign key relationships based on references to unique cols but not PK.
  * @link       http://propel.phpdb.org/trac/ticket/691
  */
 public function testUniqueFkRel()
 {
     BookstoreEmployeeAccountTableMap::doDeleteAll();
     $employee = new BookstoreEmployee();
     $employee->setName("Johnny Walker");
     $acct = new BookstoreEmployeeAccount();
     $acct->setBookstoreEmployee($employee);
     $acct->setLogin("test-login");
     $acct->save();
     $acctId = $acct->getEmployeeId();
     $al = new AcctAuditLog();
     $al->setBookstoreEmployeeAccount($acct);
     $al->save();
     $alId = $al->getId();
     BookstoreEmployeeTableMap::clearInstancePool();
     BookstoreEmployeeAccountTableMap::clearInstancePool();
     AcctAuditLogTableMap::clearInstancePool();
     $al2 = AcctAuditLogQuery::create()->findPk($alId);
     /* @var $al2 AcctAuditLog */
     $mapacct = $al2->getBookstoreEmployeeAccount();
     $lookupacct = BookstoreEmployeeAccountQuery::create()->findPk($acctId);
     $logs = $lookupacct->getAcctAuditLogs();
     $this->assertTrue(count($logs) == 1, "Expected 1 audit log result.");
     $this->assertEquals($logs[0]->getId(), $al->getId(), "Expected returned audit log to match created audit log.");
 }
コード例 #2
0
 public function testFilterByTimestamp()
 {
     $q = BookstoreEmployeeAccountQuery::create()->filterByCreated(12);
     $q1 = BookstoreEmployeeAccountQuery::create()->add(BookstoreEmployeeAccountTableMap::CREATED, 12, Criteria::EQUAL);
     $this->assertEquals($q1, $q, 'filterByDateColumn() translates to a Criteria::EQUAL by default');
     $q = BookstoreEmployeeAccountQuery::create()->filterByCreated(12, Criteria::NOT_EQUAL);
     $q1 = BookstoreEmployeeAccountQuery::create()->add(BookstoreEmployeeAccountTableMap::CREATED, 12, Criteria::NOT_EQUAL);
     $this->assertEquals($q1, $q, 'filterByDateColumn() accepts an optional comparison operator');
     $q = BookstoreEmployeeAccountQuery::create()->setModelAlias('b', true)->filterByCreated(12);
     $q1 = BookstoreEmployeeAccountQuery::create()->setModelAlias('b', true)->add('b.CREATED', 12, Criteria::EQUAL);
     $this->assertEquals($q1, $q, 'filterByDateColumn() uses true table alias if set');
     $q = BookstoreEmployeeAccountQuery::create()->filterByCreated(array('min' => 10));
     $q1 = BookstoreEmployeeAccountQuery::create()->add(BookstoreEmployeeAccountTableMap::CREATED, 10, Criteria::GREATER_EQUAL);
     $this->assertEquals($q1, $q, 'filterByDateColumn() translates to a Criteria::GREATER_EQUAL when passed a \'min\' key');
     $q = BookstoreEmployeeAccountQuery::create()->filterByCreated(array('max' => 12));
     $q1 = BookstoreEmployeeAccountQuery::create()->add(BookstoreEmployeeAccountTableMap::CREATED, 12, Criteria::LESS_EQUAL);
     $this->assertEquals($q1, $q, 'filterByDateColumn() translates to a Criteria::LESS_EQUAL when passed a \'max\' key');
     $q = BookstoreEmployeeAccountQuery::create()->filterByCreated(array('min' => 10, 'max' => 12));
     $q1 = BookstoreEmployeeAccountQuery::create()->add(BookstoreEmployeeAccountTableMap::CREATED, 10, Criteria::GREATER_EQUAL)->addAnd(BookstoreEmployeeAccountTableMap::CREATED, 12, Criteria::LESS_EQUAL);
     $this->assertEquals($q1, $q, 'filterByDateColumn() translates to a between when passed both a \'min\' and a \'max\' key');
 }
コード例 #3
0
 /**
  * Test hydration of joined rows that contain lazy load columns.
  * @link       http://propel.phpdb.org/trac/ticket/464
  */
 public function testHydrationJoinLazyLoad()
 {
     BookstoreEmployeeAccountTableMap::doDeleteAll();
     BookstoreEmployeeTableMap::doDeleteAll();
     AcctAccessRoleTableMap::doDeleteAll();
     $bemp2 = new BookstoreEmployee();
     $bemp2->setName("Pieter");
     $bemp2->setJobTitle("Clerk");
     $bemp2->save();
     $role = new AcctAccessRole();
     $role->setName("Admin");
     $bempacct = new BookstoreEmployeeAccount();
     $bempacct->setBookstoreEmployee($bemp2);
     $bempacct->setAcctAccessRole($role);
     $bempacct->setLogin("john");
     $bempacct->setPassword("johnp4ss");
     $bempacct->save();
     $results = BookstoreEmployeeAccountQuery::create()->find();
     $o = $results[0];
     $this->assertEquals('Admin', $o->getAcctAccessRole()->getName());
 }