public function testExpand() { // Test intermediate nodes on expansion $clauses = QQ::Clause(QQ::Expand(QQN::Milestone()->Project->ManagerPerson)); $objMilestone = Milestone::QuerySingle(QQ::Equal(QQN::Milestone()->Id, 1), $clauses); $this->assertTrue(!is_null($objMilestone->Name), "Milestone 1 has a name"); $this->assertEqual($objMilestone->Name, "Milestone A", "Milestone 1 has name of Milestone A"); $this->assertTrue(!is_null($objMilestone->Project->Name), "Project 1 has a name"); $this->assertEqual($objMilestone->Project->Name, "ACME Website Redesign", "Project 1 has name of ACME Website Redesign"); $this->assertTrue(!is_null($objMilestone->Project->ManagerPerson->FirstName), "Person 7 has a name"); $this->assertEqual($objMilestone->Project->ManagerPerson->FirstName, "Karen", "Person 7 has first name of Karen"); $clauses = QQ::Clause(QQ::ExpandAsArray(QQN::Project()->PersonAsTeamMember), QQ::OrderBy(QQN::Project()->PersonAsTeamMember->Person->LastName, QQN::Project()->PersonAsTeamMember->Person->FirstName)); // short reach $objProject = Project::QuerySingle(QQ::Equal(QQN::Project()->Id, 1), $clauses); $objPersonArray = $objProject->_PersonAsTeamMemberArray; $arrNamesOnly = array(); foreach ($objPersonArray as $item) { $arrNamesOnly[] = $item->FirstName . " " . $item->LastName; } $this->assertEqual($arrNamesOnly, array("Samantha Jones", "Kendall Public", "Alex Smith", "Wendy Smith", "Karen Wolfe"), "Project Team Member expansion is correct"); // long reach $clauses = QQ::Clause(QQ::ExpandAsArray(QQN::Milestone()->Project->PersonAsTeamMember), QQ::OrderBy(QQN::Milestone()->Project->PersonAsTeamMember->Person->LastName, QQN::Milestone()->Project->PersonAsTeamMember->Person->FirstName)); $objMilestone = Milestone::QuerySingle(QQ::Equal(QQN::Milestone()->Id, 1), $clauses); $objPersonArray = $objMilestone->Project->_PersonAsTeamMemberArray; $arrNamesOnly = array(); foreach ($objPersonArray as $item) { $arrNamesOnly[] = $item->FirstName . " " . $item->LastName; } $this->assertEqual($arrNamesOnly, array("Samantha Jones", "Kendall Public", "Alex Smith", "Wendy Smith", "Karen Wolfe"), "Long reach Milestone to Project Team Member expansion is correct"); }
public function testExpand() { // Test intermediate nodes on expansion $clauses = QQ::Clause(QQ::Expand(QQN::Milestone()->Project->ManagerPerson)); $objMilestone = Milestone::QuerySingle(QQ::Equal(QQN::Milestone()->Id, 1), $clauses); $this->assertTrue(!is_null($objMilestone->Name), "Milestone 1 has a name"); $this->assertEqual($objMilestone->Name, "Milestone A", "Milestone 1 has name of Milestone A"); $this->assertTrue(!is_null($objMilestone->Project->Name), "Project 1 has a name"); $this->assertEqual($objMilestone->Project->Name, "ACME Website Redesign", "Project 1 has name of ACME Website Redesign"); $this->assertTrue(!is_null($objMilestone->Project->ManagerPerson->FirstName), "Person 7 has a name"); $this->assertEqual($objMilestone->Project->ManagerPerson->FirstName, "Karen", "Person 7 has first name of Karen"); }
public function testMultiLeafExpansion() { $objMilestone = Milestone::QuerySingle(QQ::Equal(QQN::Milestone()->Id, 1), QQ::Clause(QQ::ExpandAsArray(QQN::Milestone()->Project->ManagerPerson->ProjectAsTeamMember), QQ::ExpandAsArray(QQN::Milestone()->Project->PersonAsTeamMember))); $objProjectArray = $objMilestone->Project->ManagerPerson->_ProjectAsTeamMemberArray; $objPeopleArray = $objMilestone->Project->_PersonAsTeamMemberArray; $this->assertTrue(is_array($objProjectArray), "_ProjectAsTeamMemberArray is an array"); $this->assertEqual(count($objProjectArray), 2, "_ProjectAsTeamMemberArray has 2 Project objects"); $this->assertTrue(is_array($objPeopleArray), "_PersonAsTeamMemberArray is an array"); $this->assertEqual(count($objPeopleArray), 5, "_PersonAsTeamMemberArray has 5 People objects"); // try through a unique relationship $objLogin = Login::QuerySingle(QQ::Equal(QQN::Login()->PersonId, 7), QQ::Clause(QQ::ExpandAsArray(QQN::Login()->Person->ProjectAsTeamMember), QQ::ExpandAsArray(QQN::Login()->Person->ProjectAsManager))); $objProjectArray = $objLogin->Person->_ProjectAsTeamMemberArray; $this->assertTrue(is_array($objProjectArray), "_ProjectAsTeamMemberArray is an array"); $this->assertEqual(count($objProjectArray), 2, "_ProjectAsTeamMemberArray has 2 Project objects"); $objProjectArray = $objLogin->Person->_ProjectAsManagerArray; $this->assertTrue(is_array($objProjectArray), "_ProjectAsManagerArray is an array"); $this->assertEqual(count($objProjectArray), 2, "_ProjectAsManagerArray has 2 Project objects"); }
public function testDataGridHtml() { $objMilestone = Milestone::QuerySingle(QQ::Equal(QQN::Milestone()->Id, 1), QQ::Clause(QQ::Expand(QQN::Milestone()->Project->ManagerPerson))); $_ITEM = $objMilestone; $node = QQN::Milestone()->Project->ManagerPerson; $html = $node->GetDataGridHtml(); $val = eval(sprintf('return %s;', $html)); $this->assertEquals($val, "Person Object 7"); }