Ejemplo n.º 1
0
 public function multipleJoinResultTest()
 {
     $rs = new MockResultSet([[JoinProcessor::FIRST . '_job_id' => '11', JoinProcessor::FIRST . '_title' => 'clean toilette', JoinProcessor::FIRST . '_valid_from' => new \util\Date(), JoinProcessor::FIRST . '_expire_at' => '', JoinProcessor::pathToKey(['PersonJob']) . '_person_id' => '11', JoinProcessor::pathToKey(['PersonJob']) . '_name' => 'Schultz', JoinProcessor::pathToKey(['PersonJob']) . '_job_id' => '21', JoinProcessor::pathToKey(['PersonJob']) . '_department_id' => '31'], [JoinProcessor::FIRST . '_job_id' => '11', JoinProcessor::FIRST . '_title' => 'clean toilette', JoinProcessor::FIRST . '_valid_from' => new \util\Date(), JoinProcessor::FIRST . '_expire_at' => '', JoinProcessor::pathToKey(['PersonJob']) . '_person_id' => '12', JoinProcessor::pathToKey(['PersonJob']) . '_name' => 'Müller', JoinProcessor::pathToKey(['PersonJob']) . '_job_id' => '11', JoinProcessor::pathToKey(['PersonJob']) . '_department_id' => '31'], [JoinProcessor::FIRST . '_job_id' => '12', JoinProcessor::FIRST . '_title' => 'second job', JoinProcessor::FIRST . '_valid_from' => new \util\Date(), JoinProcessor::FIRST . '_expire_at' => '', JoinProcessor::pathToKey(['PersonJob']) . '_person_id' => '11', JoinProcessor::pathToKey(['PersonJob']) . '_name' => 'Schultz', JoinProcessor::pathToKey(['PersonJob']) . '_job_id' => '21', JoinProcessor::pathToKey(['PersonJob']) . '_department_id' => '31'], [JoinProcessor::FIRST . '_job_id' => '13', JoinProcessor::FIRST . '_title' => 'third job', JoinProcessor::FIRST . '_valid_from' => new \util\Date(), JoinProcessor::FIRST . '_expire_at' => '', JoinProcessor::pathToKey(['PersonJob']) . '_person_id' => null, JoinProcessor::pathToKey(['PersonJob']) . '_name' => null, JoinProcessor::pathToKey(['PersonJob']) . '_job_id' => null, JoinProcessor::pathToKey(['PersonJob']) . '_department_id' => null]]);
     $jp = new JoinProcessor(Job::getPeer());
     $jp->setFetchModes(['PersonJob' => 'join']);
     $ji = new JoinIterator($jp, $rs);
     $this->assertTrue($ji->hasNext());
     $this->assertInstanceOf(Job::class, $job = $ji->next());
     $this->assertInstanceOf('var[]', $job->getPersonJobList());
     $this->assertInstanceOf(CachedResults::class, $pji = $job->getPersonJobIterator());
     $this->assertTrue($pji->hasNext());
     $this->assertInstanceOf(Person::class, $pji->next());
     $this->assertTrue($pji->hasNext());
     $this->assertInstanceOf(Person::class, $pji->next());
     $this->assertFalse($pji->hasNext());
     $this->assertTrue($ji->hasNext());
     $this->assertInstanceOf(Job::class, $job = $ji->next());
     $this->assertInstanceOf('var[]', $job->getPersonJobList());
     $this->assertInstanceOf(CachedResults::class, $pji = $job->getPersonJobIterator());
     $this->assertTrue($pji->hasNext());
     $this->assertInstanceOf(Person::class, $pji->next());
     $this->assertFalse($pji->hasNext());
     $this->assertTrue($ji->hasNext());
     $this->assertInstanceOf(Job::class, $job = $ji->next());
     $this->assertInstanceOf('var[]', $job->getPersonJobList());
     $this->assertInstanceOf(CachedResults::class, $pji = $job->getPersonJobIterator());
     $this->assertFalse($pji->hasNext());
     $this->assertFalse($ji->hasNext());
 }
 public function multipleJoinResultTest()
 {
     $rs = new MockResultSet(array(array(JoinProcessor::FIRST . '_job_id' => '11', JoinProcessor::FIRST . '_title' => 'clean toilette', JoinProcessor::FIRST . '_valid_from' => new \util\Date(), JoinProcessor::FIRST . '_expire_at' => '', JoinProcessor::pathToKey(array('PersonJob')) . '_person_id' => '11', JoinProcessor::pathToKey(array('PersonJob')) . '_name' => 'Schultz', JoinProcessor::pathToKey(array('PersonJob')) . '_job_id' => '21', JoinProcessor::pathToKey(array('PersonJob')) . '_department_id' => '31'), array(JoinProcessor::FIRST . '_job_id' => '11', JoinProcessor::FIRST . '_title' => 'clean toilette', JoinProcessor::FIRST . '_valid_from' => new \util\Date(), JoinProcessor::FIRST . '_expire_at' => '', JoinProcessor::pathToKey(array('PersonJob')) . '_person_id' => '12', JoinProcessor::pathToKey(array('PersonJob')) . '_name' => 'Müller', JoinProcessor::pathToKey(array('PersonJob')) . '_job_id' => '11', JoinProcessor::pathToKey(array('PersonJob')) . '_department_id' => '31'), array(JoinProcessor::FIRST . '_job_id' => '12', JoinProcessor::FIRST . '_title' => 'second job', JoinProcessor::FIRST . '_valid_from' => new \util\Date(), JoinProcessor::FIRST . '_expire_at' => '', JoinProcessor::pathToKey(array('PersonJob')) . '_person_id' => '11', JoinProcessor::pathToKey(array('PersonJob')) . '_name' => 'Schultz', JoinProcessor::pathToKey(array('PersonJob')) . '_job_id' => '21', JoinProcessor::pathToKey(array('PersonJob')) . '_department_id' => '31'), array(JoinProcessor::FIRST . '_job_id' => '13', JoinProcessor::FIRST . '_title' => 'third job', JoinProcessor::FIRST . '_valid_from' => new \util\Date(), JoinProcessor::FIRST . '_expire_at' => '', JoinProcessor::pathToKey(array('PersonJob')) . '_person_id' => null, JoinProcessor::pathToKey(array('PersonJob')) . '_name' => null, JoinProcessor::pathToKey(array('PersonJob')) . '_job_id' => null, JoinProcessor::pathToKey(array('PersonJob')) . '_department_id' => null)));
     $jp = new JoinProcessor(Job::getPeer());
     $jp->setFetchModes(array('PersonJob' => 'join'));
     $ji = new JoinIterator($jp, $rs);
     $this->assertTrue($ji->hasNext());
     $this->assertClass($job = $ji->next(), 'net.xp_framework.unittest.rdbms.dataset.Job');
     $this->assertArray($job->getPersonJobList());
     $this->assertClass($pji = $job->getPersonJobIterator(), 'util.HashmapIterator');
     $this->assertTrue($pji->hasNext());
     $this->assertClass($pji->next(), 'net.xp_framework.unittest.rdbms.dataset.Person');
     $this->assertTrue($pji->hasNext());
     $this->assertClass($pji->next(), 'net.xp_framework.unittest.rdbms.dataset.Person');
     $this->assertFalse($pji->hasNext());
     $this->assertTrue($ji->hasNext());
     $this->assertClass($job = $ji->next(), 'net.xp_framework.unittest.rdbms.dataset.Job');
     $this->assertArray($job->getPersonJobList());
     $this->assertClass($pji = $job->getPersonJobIterator(), 'util.HashmapIterator');
     $this->assertTrue($pji->hasNext());
     $this->assertClass($pji->next(), 'net.xp_framework.unittest.rdbms.dataset.Person');
     $this->assertFalse($pji->hasNext());
     $this->assertTrue($ji->hasNext());
     $this->assertClass($job = $ji->next(), 'net.xp_framework.unittest.rdbms.dataset.Job');
     $this->assertArray($job->getPersonJobList());
     $this->assertClass($pji = $job->getPersonJobIterator(), 'util.HashmapIterator');
     $this->assertFalse($pji->hasNext());
     $this->assertFalse($ji->hasNext());
 }
Ejemplo n.º 3
0
 public function getJoinStringTest()
 {
     $jp = new JoinProcessor(Job::getPeer());
     $jp->setFetchModes(['PersonJob' => 'join']);
     $jp->setFetchModes(['PersonJob->Department' => 'join']);
     $this->assertEquals('JOBS.job as ' . JoinProcessor::FIRST . ' LEFT OUTER JOIN JOBS.Person as ' . JoinProcessor::pathToKey(['PersonJob']) . ' on (' . JoinProcessor::FIRST . '.job_id = ' . JoinProcessor::pathToKey(['PersonJob']) . '.job_id) LEFT JOIN JOBS.Department as ' . JoinProcessor::pathToKey(['PersonJob', 'Department']) . ' on (' . JoinProcessor::pathToKey(['PersonJob']) . '.department_id = ' . JoinProcessor::pathToKey(['PersonJob', 'Department']) . '.department_id) where ', $jp->getJoinString());
 }
Ejemplo n.º 4
0
 /**
  * Returns the fragment SQL
  *
  * @param   rdbms.DBConnection conn
  * @return  string
  * @throws  rdbms.SQLStateException
  */
 public function asSql(DBConnection $conn)
 {
     if (JoinProcessor::isJoinContext()) {
         return JoinProcessor::pathToKey($this->path) . '.' . $this->name;
     } else {
         return $this->name;
     }
 }