Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/testing/PhabricatorTestCase.php
| Show First 20 Lines • Show All 178 Lines • ▼ Show 20 Lines | protected function getNextObjectSeed() { | ||||
| self::$storageFixtureObjectSeed += mt_rand(1, 100); | self::$storageFixtureObjectSeed += mt_rand(1, 100); | ||||
| return self::$storageFixtureObjectSeed; | return self::$storageFixtureObjectSeed; | ||||
| } | } | ||||
| protected function generateNewTestUser() { | protected function generateNewTestUser() { | ||||
| $seed = $this->getNextObjectSeed(); | $seed = $this->getNextObjectSeed(); | ||||
| $user = id(new PhabricatorUser()) | $user = id(new PhabricatorUser()) | ||||
| ->setRealName("Test User {$seed}}") | ->setRealName(pht('Test User %s', $seed)) | ||||
epriestley: Completely nitpicking, but maybe use `%s`, since `$seed` isn't necessarily numeric in the… | |||||
| ->setUserName("test{$seed}") | ->setUserName("test{$seed}") | ||||
| ->setIsApproved(1); | ->setIsApproved(1); | ||||
| $email = id(new PhabricatorUserEmail()) | $email = id(new PhabricatorUserEmail()) | ||||
| ->setAddress("testuser{$seed}@example.com") | ->setAddress("testuser{$seed}@example.com") | ||||
| ->setIsVerified(1); | ->setIsVerified(1); | ||||
| $editor = new PhabricatorUserEditor(); | $editor = new PhabricatorUserEditor(); | ||||
| Show All 10 Lines | abstract class PhabricatorTestCase extends PhutilTestCase { | ||||
| * reachable. | * reachable. | ||||
| * | * | ||||
| * If tests aren't currently being executed, throws an exception. | * If tests aren't currently being executed, throws an exception. | ||||
| */ | */ | ||||
| public static function assertExecutingUnitTests() { | public static function assertExecutingUnitTests() { | ||||
| if (!self::$testsAreRunning) { | if (!self::$testsAreRunning) { | ||||
| throw new Exception( | throw new Exception( | ||||
| pht( | pht( | ||||
| 'Executing test code outside of test execution! This code path can '. | 'Executing test code outside of test execution! '. | ||||
| 'only be run during unit tests.')); | 'This code path can only be run during unit tests.')); | ||||
| } | } | ||||
| } | } | ||||
| protected function requireBinaryForTest($binary) { | protected function requireBinaryForTest($binary) { | ||||
| if (!Filesystem::binaryExists($binary)) { | if (!Filesystem::binaryExists($binary)) { | ||||
| $this->assertSkipped( | $this->assertSkipped( | ||||
| pht('No binary "%s" found on this system, skipping test.', $binary)); | pht( | ||||
| 'No binary "%s" found on this system, skipping test.', | |||||
| $binary)); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
Completely nitpicking, but maybe use %s, since $seed isn't necessarily numeric in the future, even though it is today.