Ejemplo n.º 1
0
 public function testSelectSubsetInExpand()
 {
     Project::ClearCache();
     Person::ClearCache();
     Milestone::ClearCache();
     $objPersonArray = Person::QueryArray(QQ::OrCondition(QQ::Like(QQN::Person()->ProjectAsManager->Name, '%ACME%'), QQ::Like(QQN::Person()->ProjectAsManager->Name, '%HR%')), QQ::Clause(QQ::Select(QQN::Person()->LastName), QQ::Expand(QQN::Person()->ProjectAsManager, null, QQ::Select(QQN::Person()->ProjectAsManager->Spent)), QQ::OrderBy(QQN::Person()->LastName, QQN::Person()->FirstName)));
     foreach ($objPersonArray as $objPerson) {
         $this->assertNull($objPerson->FirstName, "FirstName should be null, since it was not selected");
         $this->assertNotNull($objPerson->Id, "Id should not be null since it's always added to the select list");
         $this->assertNotNull($objPerson->_ProjectAsManager->Id, "ProjectAsManager->Id should not be null since id's are always added to the select list");
         $this->assertNull($objPerson->_ProjectAsManager->Name, "ProjectAsManager->Name should be null since it was not selected");
     }
     // generate full objects to load into cache
     $objPersonArray = Person::QueryArray(QQ::OrCondition(QQ::Like(QQN::Person()->ProjectAsManager->Name, '%ACME%'), QQ::Like(QQN::Person()->ProjectAsManager->Name, '%HR%')), QQ::Clause(QQ::Expand(QQN::Person()->ProjectAsManager), QQ::OrderBy(QQN::Person()->LastName, QQN::Person()->FirstName)));
     $objPersonArray = Person::QueryArray(QQ::OrCondition(QQ::Like(QQN::Person()->ProjectAsManager->Name, '%ACME%'), QQ::Like(QQN::Person()->ProjectAsManager->Name, '%HR%')), QQ::Clause(QQ::Select(QQN::Person()->LastName), QQ::Expand(QQN::Person()->ProjectAsManager, null, QQ::Select(QQN::Person()->ProjectAsManager->Spent)), QQ::OrderBy(QQN::Person()->LastName, QQN::Person()->FirstName)));
     foreach ($objPersonArray as $objPerson) {
         $this->assertNotNull($objPerson->FirstName, "FirstName should not be null, because it has been cached");
         $this->assertNotNull($objPerson->Id, "Id should not be null since it's always added to the select list");
         $this->assertNotNull($objPerson->_ProjectAsManager->Id, "ProjectAsManager->Id should not be null since id's are always added to the select list");
         $this->assertNotNull($objPerson->_ProjectAsManager->Name, "ProjectAsManager->Name should not be null since it was cached");
     }
 }