public function setup()
 {
     parent::setup();
     RelationTestPerson::setupTables($this->db);
     RelationTestPerson::insertData($this->db);
     $this->session = new ezcPersistentSession($this->db, $this->defManager);
     $this->idMap = new ezcPersistentBasicIdentityMap($this->defManager);
     $this->options = new ezcPersistentSessionIdentityDecoratorOptions();
     $this->extractor = new ezcPersistentIdentityRelationObjectExtractor($this->idMap, $this->defManager, $this->options);
 }
예제 #2
0
 public function setup()
 {
     try {
         $this->db = ezcDbInstance::get();
     } catch (Exception $e) {
         $this->markTestSkipped('There was no database configured');
     }
     RelationTestPerson::setupTables();
     RelationTestPerson::insertData();
     $this->session = new ezcPersistentSession(ezcDbInstance::get(), new ezcPersistentCodeManager(dirname(__FILE__) . "/../data/"));
 }
 public function testRemoveRelatedObjectFromEmployer2Success()
 {
     $employer = $this->session->load("RelationTestEmployer", 2);
     $person = $this->session->getRelatedObject($employer, "RelationTestPerson");
     $this->session->removeRelatedObject($employer, $person);
     $res = RelationTestPerson::__set_state(array('id' => '1', 'firstname' => 'Theodor', 'surname' => 'Gopher', 'employer' => null));
     $this->assertEquals($res, $person, "Related RelationTestPerson objects not removed correctly.");
 }
 public function testDeleteRelatedObjectWithAmbigiousColumn()
 {
     $person = $this->session->load("RelationTestPerson", 1);
     $res = RelationTestAddress::__set_state(array('id' => '1', 'street' => 'Httproad 23', 'zip' => '12345', 'city' => 'Internettown', 'type' => 'work'));
     $this->assertEquals($res, $this->session->getRelatedObject($person, "RelationTestAddress"), "Related RelationTestPerson objects not fetched correctly.");
     $friends = $this->session->getRelatedObjects($person, 'RelationTestPerson');
     $res = array(0 => RelationTestPerson::__set_state(array('id' => '2', 'firstname' => 'Frederick', 'surname' => 'Ajax', 'employer' => '1')), 1 => RelationTestPerson::__set_state(array('id' => '3', 'firstname' => 'Raymond', 'surname' => 'Socialweb', 'employer' => '1')));
     $this->assertEquals($res, $friends);
     $this->session->removeRelatedObject($person, $friends[0]);
     $this->session->removeRelatedObject($person, $friends[1]);
     $friends = $this->session->getRelatedObjects($person, 'RelationTestPerson');
     $this->assertEquals(array(), $this->session->getRelatedObjects($person, 'RelationTestPerson'));
 }
예제 #5
0
파일: load_test.php 프로젝트: bmdevel/ezc
 public function testSubSelectDifferentClass()
 {
     RelationTestPerson::setupTables($this->session->database);
     RelationTestPerson::insertData($this->session->database);
     $q = $this->session->createFindQuery('RelationTestPerson');
     $subQ = $this->session->createSubQuery($q, 'RelationTestBirthday');
     $subQ->select('person');
     $q->where($q->expr->in('id', $subQ));
     $stmt = $q->prepare();
     $this->assertTrue($stmt->execute());
     $this->assertEquals(2, count($stmt->fetchAll()));
     RelationTestPerson::cleanup($this->session->database);
 }