From e11adc4ad76c127ebed415ac034a5c5df9db4ebe Mon Sep 17 00:00:00 2001 From: Joshua Spence Date: Sat, 8 Mar 2014 19:11:32 -0800 Subject: [PATCH] Added some additional assertion methods. Summary: There are quite a few tests in Arcanist, libphutil and Phabricator that do something similar to `$this->assertEqual(false, ...)` or `$this->assertEqual(true, ...)`. This is unnecessarily verbose and it would be cleaner if we had `assertFalse` and `assertTrue` methods. Test Plan: I contemplated adding a unit test for the `getCallerInfo` method but wasn't sure if it was required / where it should live. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley CC: Korvin, epriestley, aran Differential Revision: https://secure.phabricator.com/D8460 --- .../PhabricatorAccessControlTestCase.php | 6 +- .../call/__tests__/ConduitCallTestCase.php | 5 +- .../DiffusionSSHMercurialWireTestCase.php | 5 +- .../__tests__/PhabricatorFileTestCase.php | 4 +- .../PhabricatorMailReceiverTestCase.php | 6 +- .../PhabricatorMetaMTAMailTestCase.php | 24 +++----- .../PhabricatorUserEditorTestCase.php | 6 +- .../PhabricatorObjectListQueryTestCase.php | 6 +- .../__tests__/PhortuneCurrencyTestCase.php | 2 +- .../PhortunePaymentProviderTestCase.php | 6 +- .../__tests__/PhrictionDocumentTestCase.php | 2 +- .../PhabricatorPolicyDataTestCase.php | 12 ++-- .../__tests__/PhabricatorPolicyTestCase.php | 6 +- .../PhabricatorProjectEditorTestCase.php | 59 +++++++------------ .../PhabricatorWorkingCopyPullTestCase.php | 12 +--- .../PhabricatorRepositoryTestCase.php | 9 +-- .../PhabricatorChangeParserTestCase.php | 9 +-- .../PhabricatorInfrastructureTestCase.php | 8 +-- .../__tests__/PhabricatorWorkerTestCase.php | 34 ++++------- .../__tests__/PhabricatorEdgeTestCase.php | 8 +-- .../env/__tests__/PhabricatorEnvTestCase.php | 9 ++- ...rontIsolatedDatabaseConnectionTestCase.php | 11 ++-- ...AphrontMySQLDatabaseConnectionTestCase.php | 2 +- .../__tests__/QueryFormattingTestCase.php | 3 +- .../lisk/__tests__/LiskFixtureTestCase.php | 7 +-- .../lisk/__tests__/LiskIsolationTestCase.php | 15 ++--- .../__tests__/PhabricatorTimeTestCase.php | 8 +-- .../PhabricatorPasswordHasherTestCase.php | 6 +- .../PhabricatorAphrontViewTestCase.php | 6 +- .../layout/__tests__/PHUIListViewTestCase.php | 6 +- 30 files changed, 112 insertions(+), 190 deletions(-) diff --git a/src/applications/base/controller/__tests__/PhabricatorAccessControlTestCase.php b/src/applications/base/controller/__tests__/PhabricatorAccessControlTestCase.php index 1f5c94a498..0901613021 100644 --- a/src/applications/base/controller/__tests__/PhabricatorAccessControlTestCase.php +++ b/src/applications/base/controller/__tests__/PhabricatorAccessControlTestCase.php @@ -256,8 +256,7 @@ final class PhabricatorAccessControlTestCase $result = $ex; } - $this->assertEqual( - true, + $this->assertTrue( ($result === null), "Expect user '{$uname}' to be allowed access to '{$label}'."); } @@ -272,8 +271,7 @@ final class PhabricatorAccessControlTestCase $result = $ex; } - $this->assertEqual( - false, + $this->assertFalse( ($result === null), "Expect user '{$uname}' to be denied access to '{$label}'."); } diff --git a/src/applications/conduit/call/__tests__/ConduitCallTestCase.php b/src/applications/conduit/call/__tests__/ConduitCallTestCase.php index 51bef15039..e33f7866fa 100644 --- a/src/applications/conduit/call/__tests__/ConduitCallTestCase.php +++ b/src/applications/conduit/call/__tests__/ConduitCallTestCase.php @@ -7,7 +7,7 @@ final class ConduitCallTestCase extends PhabricatorTestCase { $call->setForceLocal(true); $result = $call->execute(); - $this->assertEqual(false, empty($result)); + $this->assertFalse(empty($result)); } public function testConduitAuth() { @@ -21,8 +21,7 @@ final class ConduitCallTestCase extends PhabricatorTestCase { $caught = $ex; } - $this->assertEqual( - true, + $this->assertTrue( ($caught instanceof ConduitException), "user.whoami should require authentication"); } diff --git a/src/applications/diffusion/ssh/__tests__/DiffusionSSHMercurialWireTestCase.php b/src/applications/diffusion/ssh/__tests__/DiffusionSSHMercurialWireTestCase.php index d1e8f8766c..89588d6ecb 100644 --- a/src/applications/diffusion/ssh/__tests__/DiffusionSSHMercurialWireTestCase.php +++ b/src/applications/diffusion/ssh/__tests__/DiffusionSSHMercurialWireTestCase.php @@ -11,7 +11,7 @@ final class DiffusionSSHMercurialWireTestCase $raw = explode("\n~~~~~~~~~~\n", $raw, 2); $this->assertEqual(2, count($raw)); $expect = json_decode($raw[1], true); - $this->assertEqual(true, is_array($expect), $file); + $this->assertTrue(is_array($expect), $file); $this->assertParserResult($expect, $raw[0], $file); } @@ -49,8 +49,7 @@ final class DiffusionSSHMercurialWireTestCase $caught = $ex; } - $this->assertEqual( - true, + $this->assertTrue( ($caught instanceof Exception), "No extra messages for '{$file}'."); } diff --git a/src/applications/files/storage/__tests__/PhabricatorFileTestCase.php b/src/applications/files/storage/__tests__/PhabricatorFileTestCase.php index b9922ac2cb..eee9bbf949 100644 --- a/src/applications/files/storage/__tests__/PhabricatorFileTestCase.php +++ b/src/applications/files/storage/__tests__/PhabricatorFileTestCase.php @@ -56,7 +56,7 @@ final class PhabricatorFileTestCase extends PhabricatorTestCase { $first_handle = $first_file->getStorageHandle(); $second_handle = $second_file->getStorageHandle(); - $this->assertEqual(true, ($first_handle != $second_handle)); + $this->assertTrue($first_handle != $second_handle); } @@ -107,7 +107,7 @@ final class PhabricatorFileTestCase extends PhabricatorTestCase { $caught = $ex; } - $this->assertEqual(true, $caught instanceof Exception); + $this->assertTrue($caught instanceof Exception); } public function testFileStorageDeleteSharedHandle() { diff --git a/src/applications/metamta/receiver/__tests__/PhabricatorMailReceiverTestCase.php b/src/applications/metamta/receiver/__tests__/PhabricatorMailReceiverTestCase.php index 53a5a5d459..ff7647bc17 100644 --- a/src/applications/metamta/receiver/__tests__/PhabricatorMailReceiverTestCase.php +++ b/src/applications/metamta/receiver/__tests__/PhabricatorMailReceiverTestCase.php @@ -16,8 +16,7 @@ final class PhabricatorMailReceiverTestCase extends PhabricatorTestCase { ); foreach ($same as $address) { - $this->assertEqual( - true, + $this->assertTrue( PhabricatorMailReceiver::matchAddresses($base, $address), "Address {$address}"); } @@ -32,8 +31,7 @@ final class PhabricatorMailReceiverTestCase extends PhabricatorTestCase { ); foreach ($diff as $address) { - $this->assertEqual( - false, + $this->assertFalse( PhabricatorMailReceiver::matchAddresses($base, $address), "Address: {$address}"); } diff --git a/src/applications/metamta/storage/__tests__/PhabricatorMetaMTAMailTestCase.php b/src/applications/metamta/storage/__tests__/PhabricatorMetaMTAMailTestCase.php index a9dc9069d4..a64b302c1a 100644 --- a/src/applications/metamta/storage/__tests__/PhabricatorMetaMTAMailTestCase.php +++ b/src/applications/metamta/storage/__tests__/PhabricatorMetaMTAMailTestCase.php @@ -59,8 +59,7 @@ final class PhabricatorMetaMTAMailTestCase extends PhabricatorTestCase { $mail = new PhabricatorMetaMTAMail(); $mail->addTos(array($phid)); - $this->assertEqual( - true, + $this->assertTrue( in_array($phid, $mail->buildRecipientList()), '"To" is a recipient.'); @@ -68,8 +67,7 @@ final class PhabricatorMetaMTAMailTestCase extends PhabricatorTestCase { // Test that the "No Self Mail" preference works correctly. $mail->setFrom($phid); - $this->assertEqual( - true, + $this->assertTrue( in_array($phid, $mail->buildRecipientList()), '"From" does not exclude recipients by default.'); @@ -78,8 +76,7 @@ final class PhabricatorMetaMTAMailTestCase extends PhabricatorTestCase { true); $prefs->save(); - $this->assertEqual( - false, + $this->assertFalse( in_array($phid, $mail->buildRecipientList()), '"From" excludes recipients with no-self-mail set.'); @@ -87,8 +84,7 @@ final class PhabricatorMetaMTAMailTestCase extends PhabricatorTestCase { PhabricatorUserPreferences::PREFERENCE_NO_SELF_MAIL); $prefs->save(); - $this->assertEqual( - true, + $this->assertTrue( in_array($phid, $mail->buildRecipientList()), '"From" does not exclude recipients by default.'); @@ -96,8 +92,7 @@ final class PhabricatorMetaMTAMailTestCase extends PhabricatorTestCase { // Test that explicit exclusion works correctly. $mail->setExcludeMailRecipientPHIDs(array($phid)); - $this->assertEqual( - false, + $this->assertFalse( in_array($phid, $mail->buildRecipientList()), 'Explicit exclude excludes recipients.'); @@ -114,16 +109,14 @@ final class PhabricatorMetaMTAMailTestCase extends PhabricatorTestCase { $mail->setMailTags(array('test-tag')); - $this->assertEqual( - false, + $this->assertFalse( in_array($phid, $mail->buildRecipientList()), 'Tag preference excludes recipients.'); $prefs->unsetPreference(PhabricatorUserPreferences::PREFERENCE_MAILTAGS); $prefs->save(); - $this->assertEqual( - true, + $this->assertTrue( in_array($phid, $mail->buildRecipientList()), 'Recipients restored after tag preference removed.'); } @@ -166,8 +159,7 @@ final class PhabricatorMetaMTAMailTestCase extends PhabricatorTestCase { $case = ""; - $this->assertEqual( - true, + $this->assertTrue( isset($dict['Thread-Index']), "Expect Thread-Index header for case {$case}."); $this->assertEqual( diff --git a/src/applications/people/editor/__tests__/PhabricatorUserEditorTestCase.php b/src/applications/people/editor/__tests__/PhabricatorUserEditorTestCase.php index ec5e699aa0..cbd2a938ed 100644 --- a/src/applications/people/editor/__tests__/PhabricatorUserEditorTestCase.php +++ b/src/applications/people/editor/__tests__/PhabricatorUserEditorTestCase.php @@ -16,7 +16,7 @@ final class PhabricatorUserEditorTestCase extends PhabricatorTestCase { 'PhabricatorUserEditorTestCaseOK', 'PhabricatorUserEditorTestCase@example.com'); - $this->assertEqual(true, true); + $this->assertTrue(true); } public function testRegistrationEmailInvalid() { @@ -34,7 +34,7 @@ final class PhabricatorUserEditorTestCase extends PhabricatorTestCase { $caught = $ex; } - $this->assertEqual(true, ($caught instanceof Exception)); + $this->assertTrue($caught instanceof Exception); } public function testRegistrationEmailDomain() { @@ -50,7 +50,7 @@ final class PhabricatorUserEditorTestCase extends PhabricatorTestCase { $caught = $ex; } - $this->assertEqual(true, ($caught instanceof Exception)); + $this->assertTrue($caught instanceof Exception); } private function registerUser($username, $email) { diff --git a/src/applications/phid/query/__tests__/PhabricatorObjectListQueryTestCase.php b/src/applications/phid/query/__tests__/PhabricatorObjectListQueryTestCase.php index 5d0cdb968c..419e47672c 100644 --- a/src/applications/phid/query/__tests__/PhabricatorObjectListQueryTestCase.php +++ b/src/applications/phid/query/__tests__/PhabricatorObjectListQueryTestCase.php @@ -36,7 +36,7 @@ final class PhabricatorObjectListQueryTestCase extends PhabricatorTestCase { } catch (Exception $ex) { $caught = $ex; } - $this->assertEqual(true, ($caught instanceof Exception)); + $this->assertTrue($caught instanceof Exception); // Expect failure when loading an invalid object. @@ -46,7 +46,7 @@ final class PhabricatorObjectListQueryTestCase extends PhabricatorTestCase { } catch (Exception $ex) { $caught = $ex; } - $this->assertEqual(true, ($caught instanceof Exception)); + $this->assertTrue($caught instanceof Exception); // Expect failure when loading ANY invalid object, by default. @@ -56,7 +56,7 @@ final class PhabricatorObjectListQueryTestCase extends PhabricatorTestCase { } catch (Exception $ex) { $caught = $ex; } - $this->assertEqual(true, ($caught instanceof Exception)); + $this->assertTrue($caught instanceof Exception); // With partial results, this should load the valid user. diff --git a/src/applications/phortune/currency/__tests__/PhortuneCurrencyTestCase.php b/src/applications/phortune/currency/__tests__/PhortuneCurrencyTestCase.php index d52f5e0e78..b9a3127f93 100644 --- a/src/applications/phortune/currency/__tests__/PhortuneCurrencyTestCase.php +++ b/src/applications/phortune/currency/__tests__/PhortuneCurrencyTestCase.php @@ -86,7 +86,7 @@ final class PhortuneCurrencyTestCase extends PhabricatorTestCase { } catch (Exception $ex) { $caught = $ex; } - $this->assertEqual(true, ($caught instanceof Exception), "{$input}"); + $this->assertTrue($caught instanceof Exception, "{$input}"); } } diff --git a/src/applications/phortune/provider/__tests__/PhortunePaymentProviderTestCase.php b/src/applications/phortune/provider/__tests__/PhortunePaymentProviderTestCase.php index 5b8d061825..cc5324d114 100644 --- a/src/applications/phortune/provider/__tests__/PhortunePaymentProviderTestCase.php +++ b/src/applications/phortune/provider/__tests__/PhortunePaymentProviderTestCase.php @@ -22,8 +22,7 @@ final class PhortunePaymentProviderTestCase extends PhabricatorTestCase { $caught = $ex; } - $this->assertEqual( - true, + $this->assertTrue( ($caught instanceof PhortuneNoPaymentProviderException), 'No provider should accept hugs; they are not a currency.'); } @@ -42,8 +41,7 @@ final class PhortunePaymentProviderTestCase extends PhabricatorTestCase { $caught = $ex; } - $this->assertEqual( - true, + $this->assertTrue( ($caught instanceof PhortuneMultiplePaymentProvidersException), 'Expect exception when more than one provider handles a payment method.'); } diff --git a/src/applications/phriction/storage/__tests__/PhrictionDocumentTestCase.php b/src/applications/phriction/storage/__tests__/PhrictionDocumentTestCase.php index bca9507284..1d1c22c77f 100644 --- a/src/applications/phriction/storage/__tests__/PhrictionDocumentTestCase.php +++ b/src/applications/phriction/storage/__tests__/PhrictionDocumentTestCase.php @@ -41,7 +41,7 @@ final class PhrictionDocumentTestCase extends PhabricatorTestCase { } if ($expect === null) { - $this->assertEqual(true, (bool)$ex, "Slug '{$slug}' is invalid."); + $this->assertTrue((bool)$ex, "Slug '{$slug}' is invalid."); } else { $this->assertEqual($expect, $result, "Slug '{$slug}' identifier."); } diff --git a/src/applications/policy/__tests__/PhabricatorPolicyDataTestCase.php b/src/applications/policy/__tests__/PhabricatorPolicyDataTestCase.php index 145cbe1f90..89b303b0d9 100644 --- a/src/applications/policy/__tests__/PhabricatorPolicyDataTestCase.php +++ b/src/applications/policy/__tests__/PhabricatorPolicyDataTestCase.php @@ -57,14 +57,14 @@ final class PhabricatorPolicyDataTestCase extends PhabricatorTestCase { $task, PhabricatorPolicyCapability::CAN_VIEW); - $this->assertEqual(true, $can_a_view); + $this->assertTrue($can_a_view); $can_b_view = PhabricatorPolicyFilter::hasCapability( $user_b, $task, PhabricatorPolicyCapability::CAN_VIEW); - $this->assertEqual(false, $can_b_view); + $this->assertFalse($can_b_view); } public function testCustomPolicyRuleAdministrators() { @@ -93,14 +93,14 @@ final class PhabricatorPolicyDataTestCase extends PhabricatorTestCase { $task, PhabricatorPolicyCapability::CAN_VIEW); - $this->assertEqual(true, $can_a_view); + $this->assertTrue($can_a_view); $can_b_view = PhabricatorPolicyFilter::hasCapability( $user_b, $task, PhabricatorPolicyCapability::CAN_VIEW); - $this->assertEqual(false, $can_b_view); + $this->assertFalse($can_b_view); } public function testCustomPolicyRuleLunarPhase() { @@ -128,7 +128,7 @@ final class PhabricatorPolicyDataTestCase extends PhabricatorTestCase { $user_a, $task, PhabricatorPolicyCapability::CAN_VIEW); - $this->assertEqual(true, $can_a_view); + $this->assertTrue($can_a_view); unset($time_a); @@ -139,7 +139,7 @@ final class PhabricatorPolicyDataTestCase extends PhabricatorTestCase { $user_a, $task, PhabricatorPolicyCapability::CAN_VIEW); - $this->assertEqual(false, $can_a_view); + $this->assertFalse($can_a_view); unset($time_b); } diff --git a/src/applications/policy/__tests__/PhabricatorPolicyTestCase.php b/src/applications/policy/__tests__/PhabricatorPolicyTestCase.php index 860ca52f69..d54ca73651 100644 --- a/src/applications/policy/__tests__/PhabricatorPolicyTestCase.php +++ b/src/applications/policy/__tests__/PhabricatorPolicyTestCase.php @@ -220,8 +220,7 @@ final class PhabricatorPolicyTestCase extends PhabricatorTestCase { if (!$class) { continue; } - $this->assertEqual( - true, + $this->assertTrue( (bool)PhabricatorApplication::getByClass($class), "Application class '{$class}' for query '{$qclass}'"); } @@ -284,8 +283,7 @@ final class PhabricatorPolicyTestCase extends PhabricatorTestCase { $result, "{$description} with user {$spec} should succeed."); } else { - $this->assertEqual( - true, + $this->assertTrue( $caught instanceof PhabricatorPolicyException, "{$description} with user {$spec} should fail."); } diff --git a/src/applications/project/editor/__tests__/PhabricatorProjectEditorTestCase.php b/src/applications/project/editor/__tests__/PhabricatorProjectEditorTestCase.php index 3e88fe8e91..13f9527cd9 100644 --- a/src/applications/project/editor/__tests__/PhabricatorProjectEditorTestCase.php +++ b/src/applications/project/editor/__tests__/PhabricatorProjectEditorTestCase.php @@ -28,12 +28,8 @@ final class PhabricatorProjectEditorTestCase extends PhabricatorTestCase { $can_view = PhabricatorPolicyCapability::CAN_VIEW; // When the view policy is set to "users", any user can see the project. - $this->assertEqual( - true, - (bool)$this->refreshProject($proj, $user)); - $this->assertEqual( - true, - (bool)$this->refreshProject($proj, $user2)); + $this->assertTrue((bool)$this->refreshProject($proj, $user)); + $this->assertTrue((bool)$this->refreshProject($proj, $user2)); // When the view policy is set to "no one", members can still see the @@ -41,12 +37,8 @@ final class PhabricatorProjectEditorTestCase extends PhabricatorTestCase { $proj->setViewPolicy(PhabricatorPolicies::POLICY_NOONE); $proj->save(); - $this->assertEqual( - true, - (bool)$this->refreshProject($proj, $user)); - $this->assertEqual( - false, - (bool)$this->refreshProject($proj, $user2)); + $this->assertTrue((bool)$this->refreshProject($proj, $user)); + $this->assertFalse((bool)$this->refreshProject($proj, $user2)); } public function testEditProject() { @@ -66,9 +58,7 @@ final class PhabricatorProjectEditorTestCase extends PhabricatorTestCase { $proj->setEditPolicy(PhabricatorPolicies::POLICY_USER); $proj->save(); - $this->assertEqual( - true, - $this->attemptProjectEdit($proj, $user)); + $this->assertTrue($this->attemptProjectEdit($proj, $user)); // When edit policy is set to "no one", no one can edit. @@ -81,7 +71,7 @@ final class PhabricatorProjectEditorTestCase extends PhabricatorTestCase { } catch (Exception $ex) { $caught = $ex; } - $this->assertEqual(true, ($caught instanceof Exception)); + $this->assertTrue($caught instanceof Exception); } private function attemptProjectEdit( @@ -113,13 +103,11 @@ final class PhabricatorProjectEditorTestCase extends PhabricatorTestCase { $proj->save(); $proj = $this->refreshProject($proj, $user, true); - $this->assertEqual( - true, + $this->assertTrue( (bool)$proj, 'Assumption that projects are default visible to any user when created.'); - $this->assertEqual( - false, + $this->assertFalse( $proj->isUserMember($user->getPHID()), 'Arbitrary user not member of project.'); @@ -127,10 +115,9 @@ final class PhabricatorProjectEditorTestCase extends PhabricatorTestCase { $this->joinProject($proj, $user); $proj = $this->refreshProject($proj, $user, true); - $this->assertEqual(true, (bool)$proj); + $this->assertTrue((bool)$proj); - $this->assertEqual( - true, + $this->assertTrue( $proj->isUserMember($user->getPHID()), 'Join works.'); @@ -139,10 +126,9 @@ final class PhabricatorProjectEditorTestCase extends PhabricatorTestCase { $this->joinProject($proj, $user); $proj = $this->refreshProject($proj, $user, true); - $this->assertEqual(true, (bool)$proj); + $this->assertTrue((bool)$proj); - $this->assertEqual( - true, + $this->assertTrue( $proj->isUserMember($user->getPHID()), 'Joining an already-joined project is a no-op.'); @@ -151,10 +137,9 @@ final class PhabricatorProjectEditorTestCase extends PhabricatorTestCase { $this->leaveProject($proj, $user); $proj = $this->refreshProject($proj, $user, true); - $this->assertEqual(true, (bool)$proj); + $this->assertTrue((bool)$proj); - $this->assertEqual( - false, + $this->assertFalse( $proj->isUserMember($user->getPHID()), 'Leave works.'); @@ -163,10 +148,9 @@ final class PhabricatorProjectEditorTestCase extends PhabricatorTestCase { $this->leaveProject($proj, $user); $proj = $this->refreshProject($proj, $user, true); - $this->assertEqual(true, (bool)$proj); + $this->assertTrue((bool)$proj); - $this->assertEqual( - false, + $this->assertFalse( $proj->isUserMember($user->getPHID()), 'Leaving an already-left project is a no-op.'); @@ -183,7 +167,7 @@ final class PhabricatorProjectEditorTestCase extends PhabricatorTestCase { } catch (Exception $ex) { $caught = $ex; } - $this->assertEqual(true, ($ex instanceof Exception)); + $this->assertTrue($ex instanceof Exception); // If a user can edit a project, they can join. @@ -194,8 +178,7 @@ final class PhabricatorProjectEditorTestCase extends PhabricatorTestCase { $proj = $this->refreshProject($proj, $user, true); $this->joinProject($proj, $user); $proj = $this->refreshProject($proj, $user, true); - $this->assertEqual( - true, + $this->assertTrue( $proj->isUserMember($user->getPHID()), 'Join allowed with edit permission.'); $this->leaveProject($proj, $user); @@ -209,8 +192,7 @@ final class PhabricatorProjectEditorTestCase extends PhabricatorTestCase { $proj = $this->refreshProject($proj, $user, true); $this->joinProject($proj, $user); $proj = $this->refreshProject($proj, $user, true); - $this->assertEqual( - true, + $this->assertTrue( $proj->isUserMember($user->getPHID()), 'Join allowed with join permission.'); @@ -223,8 +205,7 @@ final class PhabricatorProjectEditorTestCase extends PhabricatorTestCase { $proj = $this->refreshProject($proj, $user, true); $this->leaveProject($proj, $user); $proj = $this->refreshProject($proj, $user, true); - $this->assertEqual( - false, + $this->assertFalse( $proj->isUserMember($user->getPHID()), 'Leave allowed without any permission.'); } diff --git a/src/applications/repository/engine/__tests__/PhabricatorWorkingCopyPullTestCase.php b/src/applications/repository/engine/__tests__/PhabricatorWorkingCopyPullTestCase.php index ac3ce297a3..58a6590871 100644 --- a/src/applications/repository/engine/__tests__/PhabricatorWorkingCopyPullTestCase.php +++ b/src/applications/repository/engine/__tests__/PhabricatorWorkingCopyPullTestCase.php @@ -6,17 +6,13 @@ final class PhabricatorWorkingCopyPullTestCase public function testGitPullBasic() { $repo = $this->buildPulledRepository('GT'); - $this->assertEqual( - true, - Filesystem::pathExists($repo->getLocalPath().'/HEAD')); + $this->assertTrue(Filesystem::pathExists($repo->getLocalPath().'/HEAD')); } public function testHgPullBasic() { $repo = $this->buildPulledRepository('HT'); - $this->assertEqual( - true, - Filesystem::pathExists($repo->getLocalPath().'/.hg')); + $this->assertTrue(Filesystem::pathExists($repo->getLocalPath().'/.hg')); } public function testSVNPullBasic() { @@ -24,9 +20,7 @@ final class PhabricatorWorkingCopyPullTestCase // We don't pull local clones for SVN, so we don't expect there to be // a working copy. - $this->assertEqual( - false, - Filesystem::pathExists($repo->getLocalPath())); + $this->assertFalse(Filesystem::pathExists($repo->getLocalPath())); } } diff --git a/src/applications/repository/storage/__tests__/PhabricatorRepositoryTestCase.php b/src/applications/repository/storage/__tests__/PhabricatorRepositoryTestCase.php index 5b60b2968e..2ab824abfa 100644 --- a/src/applications/repository/storage/__tests__/PhabricatorRepositoryTestCase.php +++ b/src/applications/repository/storage/__tests__/PhabricatorRepositoryTestCase.php @@ -33,8 +33,7 @@ final class PhabricatorRepositoryTestCase $repo = new PhabricatorRepository(); $repo->setVersionControlSystem($git); - $this->assertEqual( - true, + $this->assertTrue( $repo->shouldTrackBranch('imaginary'), 'Track all branches by default.'); @@ -44,13 +43,11 @@ final class PhabricatorRepositoryTestCase 'master' => true, )); - $this->assertEqual( - true, + $this->assertTrue( $repo->shouldTrackBranch('master'), 'Track listed branches.'); - $this->assertEqual( - false, + $this->assertFalse( $repo->shouldTrackBranch('imaginary'), 'Do not track unlisted branches.'); } diff --git a/src/applications/repository/worker/__tests__/PhabricatorChangeParserTestCase.php b/src/applications/repository/worker/__tests__/PhabricatorChangeParserTestCase.php index 37c697f4ba..bcb21a6de8 100644 --- a/src/applications/repository/worker/__tests__/PhabricatorChangeParserTestCase.php +++ b/src/applications/repository/worker/__tests__/PhabricatorChangeParserTestCase.php @@ -1072,8 +1072,7 @@ final class PhabricatorChangeParserTestCase $caught = $ex; } - $this->assertEqual( - false, + $this->assertFalse( ($caught instanceof Exception), pht('Natural SVN root should work properly.')); @@ -1097,8 +1096,7 @@ final class PhabricatorChangeParserTestCase $caught = $ex; } - $this->assertEqual( - true, + $this->assertTrue( ($caught instanceof Exception), pht('Artificial SVN root should fail.')); } @@ -1136,8 +1134,7 @@ final class PhabricatorChangeParserTestCase $commits = mpull($commits, null, 'getCommitIdentifier'); - $this->assertEqual( - true, + $this->assertTrue( isset($commits['2']), 'Expect rCHE2 to exist as a foreign stub.'); diff --git a/src/infrastructure/__tests__/PhabricatorInfrastructureTestCase.php b/src/infrastructure/__tests__/PhabricatorInfrastructureTestCase.php index d397788f20..fba21b7d5d 100644 --- a/src/infrastructure/__tests__/PhabricatorInfrastructureTestCase.php +++ b/src/infrastructure/__tests__/PhabricatorInfrastructureTestCase.php @@ -16,7 +16,7 @@ final class PhabricatorInfrastructureTestCase */ public function testEverythingImplemented() { id(new PhutilSymbolLoader())->selectAndLoadSymbols(); - $this->assertEqual(true, true); + $this->assertTrue(true); } public function testApplicationsInstalled() { @@ -66,7 +66,7 @@ final class PhabricatorInfrastructureTestCase } $this->assertEqual(194431, strlen($buf)); - $this->assertEqual(true, phutil_is_utf8_with_only_bmp_characters($buf)); + $this->assertTrue(phutil_is_utf8_with_only_bmp_characters($buf)); $write = id(new HarbormasterScratchTable()) ->setData('all.utf8.bmp') @@ -96,9 +96,7 @@ final class PhabricatorInfrastructureTestCase $caught = $ex; } - $this->assertEqual( - true, - ($caught instanceof AphrontQueryCharacterSetException)); + $this->assertTrue($caught instanceof AphrontQueryCharacterSetException); } } diff --git a/src/infrastructure/daemon/workers/__tests__/PhabricatorWorkerTestCase.php b/src/infrastructure/daemon/workers/__tests__/PhabricatorWorkerTestCase.php index 7e5c5f9416..90950c613a 100644 --- a/src/infrastructure/daemon/workers/__tests__/PhabricatorWorkerTestCase.php +++ b/src/infrastructure/daemon/workers/__tests__/PhabricatorWorkerTestCase.php @@ -76,10 +76,8 @@ final class PhabricatorWorkerTestCase extends PhabricatorTestCase { 'doWork' => 'fail-temporary', )); - $this->assertEqual(false, $task->isArchived()); - $this->assertEqual( - true, - ($task->getExecutionException() instanceof Exception)); + $this->assertFalse($task->isArchived()); + $this->assertTrue($task->getExecutionException() instanceof Exception); } public function testTooManyTaskFailures() { @@ -92,43 +90,35 @@ final class PhabricatorWorkerTestCase extends PhabricatorTestCase { )); // Temporary... - $this->assertEqual(false, $task->isArchived()); - $this->assertEqual( - true, - ($task->getExecutionException() instanceof Exception)); + $this->assertFalse($task->isArchived()); + $this->assertTrue($task->getExecutionException() instanceof Exception); $this->assertEqual(1, $task->getFailureCount()); // Temporary... $task = $this->expectNextLease($task); $task = $task->executeTask(); - $this->assertEqual(false, $task->isArchived()); - $this->assertEqual( - true, - ($task->getExecutionException() instanceof Exception)); + $this->assertFalse($task->isArchived()); + $this->assertTrue($task->getExecutionException() instanceof Exception); $this->assertEqual(2, $task->getFailureCount()); // Temporary... $task = $this->expectNextLease($task); $task = $task->executeTask(); - $this->assertEqual(false, $task->isArchived()); - $this->assertEqual( - true, - ($task->getExecutionException() instanceof Exception)); + $this->assertFalse($task->isArchived()); + $this->assertTrue($task->getExecutionException() instanceof Exception); $this->assertEqual(3, $task->getFailureCount()); // Temporary... $task = $this->expectNextLease($task); $task = $task->executeTask(); - $this->assertEqual(false, $task->isArchived()); - $this->assertEqual( - true, - ($task->getExecutionException() instanceof Exception)); + $this->assertFalse($task->isArchived()); + $this->assertTrue($task->getExecutionException() instanceof Exception); $this->assertEqual(4, $task->getFailureCount()); // Permanent. $task = $this->expectNextLease($task); $task = $task->executeTask(); - $this->assertEqual(true, $task->isArchived()); + $this->assertTrue($task->isArchived()); $this->assertEqual( PhabricatorWorkerArchiveTask::RESULT_FAILURE, $task->getResult()); @@ -151,7 +141,7 @@ final class PhabricatorWorkerTestCase extends PhabricatorTestCase { 'getRequiredLeaseTime' => 1000000, )); - $this->assertEqual(true, ($task->getLeaseExpires() - time()) > 1000); + $this->assertTrue(($task->getLeaseExpires() - time()) > 1000); } public function testLeasedIsOldestFirst() { diff --git a/src/infrastructure/edges/__tests__/PhabricatorEdgeTestCase.php b/src/infrastructure/edges/__tests__/PhabricatorEdgeTestCase.php index 221a493579..d15ed23c61 100644 --- a/src/infrastructure/edges/__tests__/PhabricatorEdgeTestCase.php +++ b/src/infrastructure/edges/__tests__/PhabricatorEdgeTestCase.php @@ -32,9 +32,7 @@ final class PhabricatorEdgeTestCase extends PhabricatorTestCase { $caught = $ex; } - $this->assertEqual( - true, - $caught instanceof Exception); + $this->assertTrue($caught instanceof Exception); // The first edit should go through (no cycle), bu the second one should @@ -56,9 +54,7 @@ final class PhabricatorEdgeTestCase extends PhabricatorTestCase { $caught = $ex; } - $this->assertEqual( - true, - $caught instanceof Exception); + $this->assertTrue($caught instanceof Exception); } diff --git a/src/infrastructure/env/__tests__/PhabricatorEnvTestCase.php b/src/infrastructure/env/__tests__/PhabricatorEnvTestCase.php index 4828b0acb1..0097a5bef4 100644 --- a/src/infrastructure/env/__tests__/PhabricatorEnvTestCase.php +++ b/src/infrastructure/env/__tests__/PhabricatorEnvTestCase.php @@ -104,7 +104,7 @@ final class PhabricatorEnvTestCase extends PhabricatorTestCase { $caught = $ex; } - $this->assertEqual(true, ($caught instanceof Exception)); + $this->assertTrue($caught instanceof Exception); } public function testOverrides() { @@ -139,8 +139,7 @@ final class PhabricatorEnvTestCase extends PhabricatorTestCase { $caught = $ex; } - $this->assertEqual( - true, + $this->assertTrue( $caught instanceof Exception, "Destroying a scoped environment which is not on the top of the stack ". "should throw."); @@ -163,7 +162,7 @@ final class PhabricatorEnvTestCase extends PhabricatorTestCase { } catch (Exception $ex) { $caught = $ex; } - $this->assertEqual(true, $caught instanceof Exception); + $this->assertTrue($caught instanceof Exception); $caught = null; try { @@ -171,7 +170,7 @@ final class PhabricatorEnvTestCase extends PhabricatorTestCase { } catch (Exception $ex) { $caught = $ex; } - $this->assertEqual(false, $caught instanceof Exception); + $this->assertFalse($caught instanceof Exception); } } diff --git a/src/infrastructure/storage/__tests__/AphrontIsolatedDatabaseConnectionTestCase.php b/src/infrastructure/storage/__tests__/AphrontIsolatedDatabaseConnectionTestCase.php index 29f230b563..56457ceceb 100644 --- a/src/infrastructure/storage/__tests__/AphrontIsolatedDatabaseConnectionTestCase.php +++ b/src/infrastructure/storage/__tests__/AphrontIsolatedDatabaseConnectionTestCase.php @@ -18,7 +18,7 @@ final class AphrontIsolatedDatabaseConnectionTestCase $this->newIsolatedConnection(), 'INSERT INVALID SYNTAX'); - $this->assertEqual(true, true); + $this->assertTrue(true); } public function testInsertGeneratesID() { @@ -30,10 +30,9 @@ final class AphrontIsolatedDatabaseConnectionTestCase queryfx($conn, 'INSERT'); $id2 = $conn->getInsertID(); - $this->assertEqual(true, (bool)$id1, 'ID1 exists.'); - $this->assertEqual(true, (bool)$id2, 'ID2 exists.'); - $this->assertEqual( - true, + $this->assertTrue((bool)$id1, 'ID1 exists.'); + $this->assertTrue((bool)$id2, 'ID2 exists.'); + $this->assertTrue( $id1 != $id2, "IDs '{$id1}' and '{$id2}' are distinct."); } @@ -42,7 +41,7 @@ final class AphrontIsolatedDatabaseConnectionTestCase $conn = $this->newIsolatedConnection(); queryfx($conn, 'DELETE'); - $this->assertEqual(true, true); + $this->assertTrue(true); } public function testTransactionStack() { diff --git a/src/infrastructure/storage/__tests__/AphrontMySQLDatabaseConnectionTestCase.php b/src/infrastructure/storage/__tests__/AphrontMySQLDatabaseConnectionTestCase.php index ccffbc2093..d78737c2f6 100644 --- a/src/infrastructure/storage/__tests__/AphrontMySQLDatabaseConnectionTestCase.php +++ b/src/infrastructure/storage/__tests__/AphrontMySQLDatabaseConnectionTestCase.php @@ -31,7 +31,7 @@ final class AphrontMySQLDatabaseConnectionTestCase } catch (AphrontQueryConnectionLostException $ex) { $caught = $ex; } - $this->assertEqual(true, $caught instanceof Exception); + $this->assertTrue($caught instanceof Exception); } } diff --git a/src/infrastructure/storage/__tests__/QueryFormattingTestCase.php b/src/infrastructure/storage/__tests__/QueryFormattingTestCase.php index c583497751..b81484f7b2 100644 --- a/src/infrastructure/storage/__tests__/QueryFormattingTestCase.php +++ b/src/infrastructure/storage/__tests__/QueryFormattingTestCase.php @@ -23,9 +23,8 @@ final class QueryFormattingTestCase extends PhabricatorTestCase { } catch (Exception $ex) { $raised = $ex; } - $this->assertEqual( + $this->assertTrue( (bool)$raised, - true, 'qsprintf should raise exception for invalid %d conversion.'); $this->assertEqual( diff --git a/src/infrastructure/storage/lisk/__tests__/LiskFixtureTestCase.php b/src/infrastructure/storage/lisk/__tests__/LiskFixtureTestCase.php index 25e0208ebb..0aae94d444 100644 --- a/src/infrastructure/storage/lisk/__tests__/LiskFixtureTestCase.php +++ b/src/infrastructure/storage/lisk/__tests__/LiskFixtureTestCase.php @@ -65,8 +65,7 @@ final class LiskFixtureTestCase extends PhabricatorTestCase { $obj->killTransaction(); - $this->assertEqual( - true, + $this->assertTrue( ($loaded !== null), "Reads inside transactions should have transaction visibility."); @@ -91,8 +90,8 @@ final class LiskFixtureTestCase extends PhabricatorTestCase { $this->assertEqual(null, $load->load('cow')); $this->assertEqual(null, $load->load($id."cow")); - $this->assertEqual(true, (bool)$load->load((int)$id)); - $this->assertEqual(true, (bool)$load->load((string)$id)); + $this->assertTrue((bool)$load->load((int)$id)); + $this->assertTrue((bool)$load->load((string)$id)); } public function testCounters() { diff --git a/src/infrastructure/storage/lisk/__tests__/LiskIsolationTestCase.php b/src/infrastructure/storage/lisk/__tests__/LiskIsolationTestCase.php index 67128e82da..844f3ffc09 100644 --- a/src/infrastructure/storage/lisk/__tests__/LiskIsolationTestCase.php +++ b/src/infrastructure/storage/lisk/__tests__/LiskIsolationTestCase.php @@ -13,8 +13,8 @@ final class LiskIsolationTestCase extends PhabricatorTestCase { $id = $dao->getID(); $phid = $dao->getPHID(); - $this->assertEqual(true, (bool)$id, 'Expect ID generated.'); - $this->assertEqual(true, (bool)$phid, 'Expect PHID generated.'); + $this->assertTrue((bool)$id, 'Expect ID generated.'); + $this->assertTrue((bool)$phid, 'Expect PHID generated.'); $dao->save(); // Effects update @@ -54,7 +54,7 @@ final class LiskIsolationTestCase extends PhabricatorTestCase { // Expected, pass. } - $this->assertEqual(true, true); + $this->assertTrue(true); } public function testMagicMethods() { @@ -82,8 +82,7 @@ final class LiskIsolationTestCase extends PhabricatorTestCase { } catch (Exception $thrown) { $ex = $thrown; } - $this->assertEqual( - true, + $this->assertTrue( (bool)$ex, 'Typoing "get" should throw.'); @@ -93,8 +92,7 @@ final class LiskIsolationTestCase extends PhabricatorTestCase { } catch (Exception $thrown) { $ex = $thrown; } - $this->assertEqual( - true, + $this->assertTrue( (bool)$ex, 'Typoing "set" should throw.'); @@ -104,8 +102,7 @@ final class LiskIsolationTestCase extends PhabricatorTestCase { } catch (Exception $thrown) { $ex = $thrown; } - $this->assertEqual( - true, + $this->assertTrue( (bool)$ex, 'Made up method should throw.'); } diff --git a/src/infrastructure/time/__tests__/PhabricatorTimeTestCase.php b/src/infrastructure/time/__tests__/PhabricatorTimeTestCase.php index 54f10d875c..ef2db5cd66 100644 --- a/src/infrastructure/time/__tests__/PhabricatorTimeTestCase.php +++ b/src/infrastructure/time/__tests__/PhabricatorTimeTestCase.php @@ -6,15 +6,11 @@ final class PhabricatorTimeTestCase extends PhabricatorTestCase { $t = 1370202281; $time = PhabricatorTime::pushTime($t, 'UTC'); - $this->assertEqual( - true, - (PhabricatorTime::getNow() === $t)); + $this->assertTrue(PhabricatorTime::getNow() === $t); unset($time); - $this->assertEqual( - false, - (PhabricatorTime::getNow() === $t)); + $this->assertFalse(PhabricatorTime::getNow() === $t); } public function testParseLocalTime() { diff --git a/src/infrastructure/util/password/__tests__/PhabricatorPasswordHasherTestCase.php b/src/infrastructure/util/password/__tests__/PhabricatorPasswordHasherTestCase.php index 32acf4cb9a..053acea4fc 100644 --- a/src/infrastructure/util/password/__tests__/PhabricatorPasswordHasherTestCase.php +++ b/src/infrastructure/util/password/__tests__/PhabricatorPasswordHasherTestCase.php @@ -11,8 +11,7 @@ final class PhabricatorPasswordHasherTestCase extends PhabricatorTestCase { $caught = $ex; } - $this->assertEqual( - true, + $this->assertTrue( ($caught instanceof Exception), pht('Exception on unparseable hash format.')); @@ -24,8 +23,7 @@ final class PhabricatorPasswordHasherTestCase extends PhabricatorTestCase { $caught = $ex; } - $this->assertEqual( - true, + $this->assertTrue( ($caught instanceof PhabricatorPasswordHasherUnavailableException), pht('Fictional hasher unavailable.')); } diff --git a/src/view/__tests__/PhabricatorAphrontViewTestCase.php b/src/view/__tests__/PhabricatorAphrontViewTestCase.php index 2d05151d75..4d0d67c690 100644 --- a/src/view/__tests__/PhabricatorAphrontViewTestCase.php +++ b/src/view/__tests__/PhabricatorAphrontViewTestCase.php @@ -4,7 +4,7 @@ final class PhabricatorAphrontViewTestCase extends PhabricatorTestCase { public function testHasChildren() { $view = new AphrontNullView(); - $this->assertEqual(false, $view->hasChildren()); + $this->assertFalse($view->hasChildren()); $values = array( null, @@ -15,11 +15,11 @@ final class PhabricatorAphrontViewTestCase extends PhabricatorTestCase { foreach ($values as $value) { $view->appendChild($value); - $this->assertEqual(false, $view->hasChildren()); + $this->assertFalse($view->hasChildren()); } $view->appendChild("!"); - $this->assertEqual(true, $view->hasChildren()); + $this->assertTrue($view->hasChildren()); } } diff --git a/src/view/layout/__tests__/PHUIListViewTestCase.php b/src/view/layout/__tests__/PHUIListViewTestCase.php index 57b8d8e381..78e1e6ea54 100644 --- a/src/view/layout/__tests__/PHUIListViewTestCase.php +++ b/src/view/layout/__tests__/PHUIListViewTestCase.php @@ -23,7 +23,7 @@ final class PHUIListViewTestCase extends PhabricatorTestCase { } catch (Exception $ex) { $caught = $ex; } - $this->assertEqual(true, $caught instanceof Exception); + $this->assertTrue($caught instanceof Exception); $menu->addMenuItemAfter('a', $this->newLink('test2')); $menu->addMenuItemAfter(null, $this->newLink('test3')); @@ -52,7 +52,7 @@ final class PHUIListViewTestCase extends PhabricatorTestCase { } catch (Exception $ex) { $caught = $ex; } - $this->assertEqual(true, $caught instanceof Exception); + $this->assertTrue($caught instanceof Exception); $menu->addMenuItemBefore('b', $this->newLink('test2')); $menu->addMenuItemBefore(null, $this->newLink('test3')); @@ -83,7 +83,7 @@ final class PHUIListViewTestCase extends PhabricatorTestCase { } catch (Exception $ex) { $caught = $ex; } - $this->assertEqual(true, $caught instanceof Exception); + $this->assertTrue($caught instanceof Exception); $menu->addMenuItemToLabel('fruit', $this->newLink('apple')); $menu->addMenuItemToLabel('fruit', $this->newLink('banana'));