Differential D15911 Diff 38327 src/applications/phid/query/__tests__/PhabricatorObjectListQueryTestCase.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phid/query/__tests__/PhabricatorObjectListQueryTestCase.php
| <?php | <?php | ||||
| final class PhabricatorObjectListQueryTestCase extends PhabricatorTestCase { | final class PhabricatorObjectListQueryTestCase extends PhabricatorTestCase { | ||||
| protected function getPhabricatorTestCaseConfiguration() { | protected function getPhabricatorTestCaseConfiguration() { | ||||
| return array( | return array( | ||||
| self::PHABRICATOR_TESTCONFIG_BUILD_STORAGE_FIXTURES => true, | self::PHABRICATOR_TESTCONFIG_BUILD_STORAGE_FIXTURES => true, | ||||
| ); | ); | ||||
| } | } | ||||
| public function testObjectListQuery() { | public function testObjectListQuery() { | ||||
| $user = $this->generateNewTestUser(); | $user = $this->generateNewTestUser(); | ||||
| $name = $user->getUsername(); | $name = $user->getUsername(); | ||||
| $phid = $user->getPHID(); | $phid = $user->getPHID(); | ||||
| $result = $this->parseObjectList("@{$name}"); | $result = $this->parseObjectList("@{$name}"); | ||||
| $this->assertEqual(array($phid), $result); | $this->assertEqual(array($phid), $result); | ||||
| $result = $this->parseObjectList("{$name}"); | $result = $this->parseObjectList("{$name}"); | ||||
| $this->assertEqual(array($phid), $result); | $this->assertEqual(array($phid), $result); | ||||
| $result = $this->parseObjectList("{$name}, {$name}"); | $result = $this->parseObjectList("{$name}, {$name}"); | ||||
| $this->assertEqual(array($phid), $result); | $this->assertEqual(array($phid), $result); | ||||
| $result = $this->parseObjectList("@{$name}, {$name}"); | $result = $this->parseObjectList("@{$name}, {$name}"); | ||||
| $this->assertEqual(array($phid), $result); | $this->assertEqual(array($phid), $result); | ||||
| $result = $this->parseObjectList(''); | $result = $this->parseObjectList(''); | ||||
| $this->assertEqual(array(), $result); | $this->assertEqual(array(), $result); | ||||
| $package = PhabricatorOwnersPackage::initializeNewPackage($user) | |||||
| ->setName(pht('Query Test Package')) | |||||
| ->save(); | |||||
| $package_phid = $package->getPHID(); | |||||
| $package_mono = $package->getMonogram(); | |||||
| $result = $this->parseObjectList("{$package_mono} Any Ignored Text"); | |||||
| $this->assertEqual(array($package_phid), $result); | |||||
| $result = $this->parseObjectList("{$package_mono} Any Text, {$name}"); | |||||
| $this->assertEqual(array($package_phid, $phid), $result); | |||||
| // Expect failure when loading a user if objects must be of type "DUCK". | // Expect failure when loading a user if objects must be of type "DUCK". | ||||
| $caught = null; | $caught = null; | ||||
| try { | try { | ||||
| $result = $this->parseObjectList("{$name}", array('DUCK')); | $result = $this->parseObjectList("{$name}", array('DUCK')); | ||||
| } catch (Exception $ex) { | } catch (Exception $ex) { | ||||
| $caught = $ex; | $caught = $ex; | ||||
| } | } | ||||
| $this->assertTrue($caught instanceof Exception); | $this->assertTrue($caught instanceof Exception); | ||||
| ▲ Show 20 Lines • Show All 48 Lines • Show Last 20 Lines | |||||