1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-31 08:58:20 +01:00

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
This commit is contained in:
Joshua Spence 2014-03-08 19:11:32 -08:00 committed by epriestley
parent 08040ae984
commit e11adc4ad7
30 changed files with 112 additions and 190 deletions

View file

@ -256,8 +256,7 @@ final class PhabricatorAccessControlTestCase
$result = $ex; $result = $ex;
} }
$this->assertEqual( $this->assertTrue(
true,
($result === null), ($result === null),
"Expect user '{$uname}' to be allowed access to '{$label}'."); "Expect user '{$uname}' to be allowed access to '{$label}'.");
} }
@ -272,8 +271,7 @@ final class PhabricatorAccessControlTestCase
$result = $ex; $result = $ex;
} }
$this->assertEqual( $this->assertFalse(
false,
($result === null), ($result === null),
"Expect user '{$uname}' to be denied access to '{$label}'."); "Expect user '{$uname}' to be denied access to '{$label}'.");
} }

View file

@ -7,7 +7,7 @@ final class ConduitCallTestCase extends PhabricatorTestCase {
$call->setForceLocal(true); $call->setForceLocal(true);
$result = $call->execute(); $result = $call->execute();
$this->assertEqual(false, empty($result)); $this->assertFalse(empty($result));
} }
public function testConduitAuth() { public function testConduitAuth() {
@ -21,8 +21,7 @@ final class ConduitCallTestCase extends PhabricatorTestCase {
$caught = $ex; $caught = $ex;
} }
$this->assertEqual( $this->assertTrue(
true,
($caught instanceof ConduitException), ($caught instanceof ConduitException),
"user.whoami should require authentication"); "user.whoami should require authentication");
} }

View file

@ -11,7 +11,7 @@ final class DiffusionSSHMercurialWireTestCase
$raw = explode("\n~~~~~~~~~~\n", $raw, 2); $raw = explode("\n~~~~~~~~~~\n", $raw, 2);
$this->assertEqual(2, count($raw)); $this->assertEqual(2, count($raw));
$expect = json_decode($raw[1], true); $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); $this->assertParserResult($expect, $raw[0], $file);
} }
@ -49,8 +49,7 @@ final class DiffusionSSHMercurialWireTestCase
$caught = $ex; $caught = $ex;
} }
$this->assertEqual( $this->assertTrue(
true,
($caught instanceof Exception), ($caught instanceof Exception),
"No extra messages for '{$file}'."); "No extra messages for '{$file}'.");
} }

View file

@ -56,7 +56,7 @@ final class PhabricatorFileTestCase extends PhabricatorTestCase {
$first_handle = $first_file->getStorageHandle(); $first_handle = $first_file->getStorageHandle();
$second_handle = $second_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; $caught = $ex;
} }
$this->assertEqual(true, $caught instanceof Exception); $this->assertTrue($caught instanceof Exception);
} }
public function testFileStorageDeleteSharedHandle() { public function testFileStorageDeleteSharedHandle() {

View file

@ -16,8 +16,7 @@ final class PhabricatorMailReceiverTestCase extends PhabricatorTestCase {
); );
foreach ($same as $address) { foreach ($same as $address) {
$this->assertEqual( $this->assertTrue(
true,
PhabricatorMailReceiver::matchAddresses($base, $address), PhabricatorMailReceiver::matchAddresses($base, $address),
"Address {$address}"); "Address {$address}");
} }
@ -32,8 +31,7 @@ final class PhabricatorMailReceiverTestCase extends PhabricatorTestCase {
); );
foreach ($diff as $address) { foreach ($diff as $address) {
$this->assertEqual( $this->assertFalse(
false,
PhabricatorMailReceiver::matchAddresses($base, $address), PhabricatorMailReceiver::matchAddresses($base, $address),
"Address: {$address}"); "Address: {$address}");
} }

View file

@ -59,8 +59,7 @@ final class PhabricatorMetaMTAMailTestCase extends PhabricatorTestCase {
$mail = new PhabricatorMetaMTAMail(); $mail = new PhabricatorMetaMTAMail();
$mail->addTos(array($phid)); $mail->addTos(array($phid));
$this->assertEqual( $this->assertTrue(
true,
in_array($phid, $mail->buildRecipientList()), in_array($phid, $mail->buildRecipientList()),
'"To" is a recipient.'); '"To" is a recipient.');
@ -68,8 +67,7 @@ final class PhabricatorMetaMTAMailTestCase extends PhabricatorTestCase {
// Test that the "No Self Mail" preference works correctly. // Test that the "No Self Mail" preference works correctly.
$mail->setFrom($phid); $mail->setFrom($phid);
$this->assertEqual( $this->assertTrue(
true,
in_array($phid, $mail->buildRecipientList()), in_array($phid, $mail->buildRecipientList()),
'"From" does not exclude recipients by default.'); '"From" does not exclude recipients by default.');
@ -78,8 +76,7 @@ final class PhabricatorMetaMTAMailTestCase extends PhabricatorTestCase {
true); true);
$prefs->save(); $prefs->save();
$this->assertEqual( $this->assertFalse(
false,
in_array($phid, $mail->buildRecipientList()), in_array($phid, $mail->buildRecipientList()),
'"From" excludes recipients with no-self-mail set.'); '"From" excludes recipients with no-self-mail set.');
@ -87,8 +84,7 @@ final class PhabricatorMetaMTAMailTestCase extends PhabricatorTestCase {
PhabricatorUserPreferences::PREFERENCE_NO_SELF_MAIL); PhabricatorUserPreferences::PREFERENCE_NO_SELF_MAIL);
$prefs->save(); $prefs->save();
$this->assertEqual( $this->assertTrue(
true,
in_array($phid, $mail->buildRecipientList()), in_array($phid, $mail->buildRecipientList()),
'"From" does not exclude recipients by default.'); '"From" does not exclude recipients by default.');
@ -96,8 +92,7 @@ final class PhabricatorMetaMTAMailTestCase extends PhabricatorTestCase {
// Test that explicit exclusion works correctly. // Test that explicit exclusion works correctly.
$mail->setExcludeMailRecipientPHIDs(array($phid)); $mail->setExcludeMailRecipientPHIDs(array($phid));
$this->assertEqual( $this->assertFalse(
false,
in_array($phid, $mail->buildRecipientList()), in_array($phid, $mail->buildRecipientList()),
'Explicit exclude excludes recipients.'); 'Explicit exclude excludes recipients.');
@ -114,16 +109,14 @@ final class PhabricatorMetaMTAMailTestCase extends PhabricatorTestCase {
$mail->setMailTags(array('test-tag')); $mail->setMailTags(array('test-tag'));
$this->assertEqual( $this->assertFalse(
false,
in_array($phid, $mail->buildRecipientList()), in_array($phid, $mail->buildRecipientList()),
'Tag preference excludes recipients.'); 'Tag preference excludes recipients.');
$prefs->unsetPreference(PhabricatorUserPreferences::PREFERENCE_MAILTAGS); $prefs->unsetPreference(PhabricatorUserPreferences::PREFERENCE_MAILTAGS);
$prefs->save(); $prefs->save();
$this->assertEqual( $this->assertTrue(
true,
in_array($phid, $mail->buildRecipientList()), in_array($phid, $mail->buildRecipientList()),
'Recipients restored after tag preference removed.'); 'Recipients restored after tag preference removed.');
} }
@ -166,8 +159,7 @@ final class PhabricatorMetaMTAMailTestCase extends PhabricatorTestCase {
$case = "<message-id = ".($supports_message_id ? 'Y' : 'N').", ". $case = "<message-id = ".($supports_message_id ? 'Y' : 'N').", ".
"first = ".($is_first_mail ? 'Y' : 'N').">"; "first = ".($is_first_mail ? 'Y' : 'N').">";
$this->assertEqual( $this->assertTrue(
true,
isset($dict['Thread-Index']), isset($dict['Thread-Index']),
"Expect Thread-Index header for case {$case}."); "Expect Thread-Index header for case {$case}.");
$this->assertEqual( $this->assertEqual(

View file

@ -16,7 +16,7 @@ final class PhabricatorUserEditorTestCase extends PhabricatorTestCase {
'PhabricatorUserEditorTestCaseOK', 'PhabricatorUserEditorTestCaseOK',
'PhabricatorUserEditorTestCase@example.com'); 'PhabricatorUserEditorTestCase@example.com');
$this->assertEqual(true, true); $this->assertTrue(true);
} }
public function testRegistrationEmailInvalid() { public function testRegistrationEmailInvalid() {
@ -34,7 +34,7 @@ final class PhabricatorUserEditorTestCase extends PhabricatorTestCase {
$caught = $ex; $caught = $ex;
} }
$this->assertEqual(true, ($caught instanceof Exception)); $this->assertTrue($caught instanceof Exception);
} }
public function testRegistrationEmailDomain() { public function testRegistrationEmailDomain() {
@ -50,7 +50,7 @@ final class PhabricatorUserEditorTestCase extends PhabricatorTestCase {
$caught = $ex; $caught = $ex;
} }
$this->assertEqual(true, ($caught instanceof Exception)); $this->assertTrue($caught instanceof Exception);
} }
private function registerUser($username, $email) { private function registerUser($username, $email) {

View file

@ -36,7 +36,7 @@ final class PhabricatorObjectListQueryTestCase extends PhabricatorTestCase {
} catch (Exception $ex) { } catch (Exception $ex) {
$caught = $ex; $caught = $ex;
} }
$this->assertEqual(true, ($caught instanceof Exception)); $this->assertTrue($caught instanceof Exception);
// Expect failure when loading an invalid object. // Expect failure when loading an invalid object.
@ -46,7 +46,7 @@ final class PhabricatorObjectListQueryTestCase extends PhabricatorTestCase {
} catch (Exception $ex) { } catch (Exception $ex) {
$caught = $ex; $caught = $ex;
} }
$this->assertEqual(true, ($caught instanceof Exception)); $this->assertTrue($caught instanceof Exception);
// Expect failure when loading ANY invalid object, by default. // Expect failure when loading ANY invalid object, by default.
@ -56,7 +56,7 @@ final class PhabricatorObjectListQueryTestCase extends PhabricatorTestCase {
} catch (Exception $ex) { } catch (Exception $ex) {
$caught = $ex; $caught = $ex;
} }
$this->assertEqual(true, ($caught instanceof Exception)); $this->assertTrue($caught instanceof Exception);
// With partial results, this should load the valid user. // With partial results, this should load the valid user.

View file

@ -86,7 +86,7 @@ final class PhortuneCurrencyTestCase extends PhabricatorTestCase {
} catch (Exception $ex) { } catch (Exception $ex) {
$caught = $ex; $caught = $ex;
} }
$this->assertEqual(true, ($caught instanceof Exception), "{$input}"); $this->assertTrue($caught instanceof Exception, "{$input}");
} }
} }

View file

@ -22,8 +22,7 @@ final class PhortunePaymentProviderTestCase extends PhabricatorTestCase {
$caught = $ex; $caught = $ex;
} }
$this->assertEqual( $this->assertTrue(
true,
($caught instanceof PhortuneNoPaymentProviderException), ($caught instanceof PhortuneNoPaymentProviderException),
'No provider should accept hugs; they are not a currency.'); 'No provider should accept hugs; they are not a currency.');
} }
@ -42,8 +41,7 @@ final class PhortunePaymentProviderTestCase extends PhabricatorTestCase {
$caught = $ex; $caught = $ex;
} }
$this->assertEqual( $this->assertTrue(
true,
($caught instanceof PhortuneMultiplePaymentProvidersException), ($caught instanceof PhortuneMultiplePaymentProvidersException),
'Expect exception when more than one provider handles a payment method.'); 'Expect exception when more than one provider handles a payment method.');
} }

View file

@ -41,7 +41,7 @@ final class PhrictionDocumentTestCase extends PhabricatorTestCase {
} }
if ($expect === null) { if ($expect === null) {
$this->assertEqual(true, (bool)$ex, "Slug '{$slug}' is invalid."); $this->assertTrue((bool)$ex, "Slug '{$slug}' is invalid.");
} else { } else {
$this->assertEqual($expect, $result, "Slug '{$slug}' identifier."); $this->assertEqual($expect, $result, "Slug '{$slug}' identifier.");
} }

View file

@ -57,14 +57,14 @@ final class PhabricatorPolicyDataTestCase extends PhabricatorTestCase {
$task, $task,
PhabricatorPolicyCapability::CAN_VIEW); PhabricatorPolicyCapability::CAN_VIEW);
$this->assertEqual(true, $can_a_view); $this->assertTrue($can_a_view);
$can_b_view = PhabricatorPolicyFilter::hasCapability( $can_b_view = PhabricatorPolicyFilter::hasCapability(
$user_b, $user_b,
$task, $task,
PhabricatorPolicyCapability::CAN_VIEW); PhabricatorPolicyCapability::CAN_VIEW);
$this->assertEqual(false, $can_b_view); $this->assertFalse($can_b_view);
} }
public function testCustomPolicyRuleAdministrators() { public function testCustomPolicyRuleAdministrators() {
@ -93,14 +93,14 @@ final class PhabricatorPolicyDataTestCase extends PhabricatorTestCase {
$task, $task,
PhabricatorPolicyCapability::CAN_VIEW); PhabricatorPolicyCapability::CAN_VIEW);
$this->assertEqual(true, $can_a_view); $this->assertTrue($can_a_view);
$can_b_view = PhabricatorPolicyFilter::hasCapability( $can_b_view = PhabricatorPolicyFilter::hasCapability(
$user_b, $user_b,
$task, $task,
PhabricatorPolicyCapability::CAN_VIEW); PhabricatorPolicyCapability::CAN_VIEW);
$this->assertEqual(false, $can_b_view); $this->assertFalse($can_b_view);
} }
public function testCustomPolicyRuleLunarPhase() { public function testCustomPolicyRuleLunarPhase() {
@ -128,7 +128,7 @@ final class PhabricatorPolicyDataTestCase extends PhabricatorTestCase {
$user_a, $user_a,
$task, $task,
PhabricatorPolicyCapability::CAN_VIEW); PhabricatorPolicyCapability::CAN_VIEW);
$this->assertEqual(true, $can_a_view); $this->assertTrue($can_a_view);
unset($time_a); unset($time_a);
@ -139,7 +139,7 @@ final class PhabricatorPolicyDataTestCase extends PhabricatorTestCase {
$user_a, $user_a,
$task, $task,
PhabricatorPolicyCapability::CAN_VIEW); PhabricatorPolicyCapability::CAN_VIEW);
$this->assertEqual(false, $can_a_view); $this->assertFalse($can_a_view);
unset($time_b); unset($time_b);
} }

View file

@ -220,8 +220,7 @@ final class PhabricatorPolicyTestCase extends PhabricatorTestCase {
if (!$class) { if (!$class) {
continue; continue;
} }
$this->assertEqual( $this->assertTrue(
true,
(bool)PhabricatorApplication::getByClass($class), (bool)PhabricatorApplication::getByClass($class),
"Application class '{$class}' for query '{$qclass}'"); "Application class '{$class}' for query '{$qclass}'");
} }
@ -284,8 +283,7 @@ final class PhabricatorPolicyTestCase extends PhabricatorTestCase {
$result, $result,
"{$description} with user {$spec} should succeed."); "{$description} with user {$spec} should succeed.");
} else { } else {
$this->assertEqual( $this->assertTrue(
true,
$caught instanceof PhabricatorPolicyException, $caught instanceof PhabricatorPolicyException,
"{$description} with user {$spec} should fail."); "{$description} with user {$spec} should fail.");
} }

View file

@ -28,12 +28,8 @@ final class PhabricatorProjectEditorTestCase extends PhabricatorTestCase {
$can_view = PhabricatorPolicyCapability::CAN_VIEW; $can_view = PhabricatorPolicyCapability::CAN_VIEW;
// When the view policy is set to "users", any user can see the project. // When the view policy is set to "users", any user can see the project.
$this->assertEqual( $this->assertTrue((bool)$this->refreshProject($proj, $user));
true, $this->assertTrue((bool)$this->refreshProject($proj, $user2));
(bool)$this->refreshProject($proj, $user));
$this->assertEqual(
true,
(bool)$this->refreshProject($proj, $user2));
// When the view policy is set to "no one", members can still see the // 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->setViewPolicy(PhabricatorPolicies::POLICY_NOONE);
$proj->save(); $proj->save();
$this->assertEqual( $this->assertTrue((bool)$this->refreshProject($proj, $user));
true, $this->assertFalse((bool)$this->refreshProject($proj, $user2));
(bool)$this->refreshProject($proj, $user));
$this->assertEqual(
false,
(bool)$this->refreshProject($proj, $user2));
} }
public function testEditProject() { public function testEditProject() {
@ -66,9 +58,7 @@ final class PhabricatorProjectEditorTestCase extends PhabricatorTestCase {
$proj->setEditPolicy(PhabricatorPolicies::POLICY_USER); $proj->setEditPolicy(PhabricatorPolicies::POLICY_USER);
$proj->save(); $proj->save();
$this->assertEqual( $this->assertTrue($this->attemptProjectEdit($proj, $user));
true,
$this->attemptProjectEdit($proj, $user));
// When edit policy is set to "no one", no one can edit. // When edit policy is set to "no one", no one can edit.
@ -81,7 +71,7 @@ final class PhabricatorProjectEditorTestCase extends PhabricatorTestCase {
} catch (Exception $ex) { } catch (Exception $ex) {
$caught = $ex; $caught = $ex;
} }
$this->assertEqual(true, ($caught instanceof Exception)); $this->assertTrue($caught instanceof Exception);
} }
private function attemptProjectEdit( private function attemptProjectEdit(
@ -113,13 +103,11 @@ final class PhabricatorProjectEditorTestCase extends PhabricatorTestCase {
$proj->save(); $proj->save();
$proj = $this->refreshProject($proj, $user, true); $proj = $this->refreshProject($proj, $user, true);
$this->assertEqual( $this->assertTrue(
true,
(bool)$proj, (bool)$proj,
'Assumption that projects are default visible to any user when created.'); 'Assumption that projects are default visible to any user when created.');
$this->assertEqual( $this->assertFalse(
false,
$proj->isUserMember($user->getPHID()), $proj->isUserMember($user->getPHID()),
'Arbitrary user not member of project.'); 'Arbitrary user not member of project.');
@ -127,10 +115,9 @@ final class PhabricatorProjectEditorTestCase extends PhabricatorTestCase {
$this->joinProject($proj, $user); $this->joinProject($proj, $user);
$proj = $this->refreshProject($proj, $user, true); $proj = $this->refreshProject($proj, $user, true);
$this->assertEqual(true, (bool)$proj); $this->assertTrue((bool)$proj);
$this->assertEqual( $this->assertTrue(
true,
$proj->isUserMember($user->getPHID()), $proj->isUserMember($user->getPHID()),
'Join works.'); 'Join works.');
@ -139,10 +126,9 @@ final class PhabricatorProjectEditorTestCase extends PhabricatorTestCase {
$this->joinProject($proj, $user); $this->joinProject($proj, $user);
$proj = $this->refreshProject($proj, $user, true); $proj = $this->refreshProject($proj, $user, true);
$this->assertEqual(true, (bool)$proj); $this->assertTrue((bool)$proj);
$this->assertEqual( $this->assertTrue(
true,
$proj->isUserMember($user->getPHID()), $proj->isUserMember($user->getPHID()),
'Joining an already-joined project is a no-op.'); 'Joining an already-joined project is a no-op.');
@ -151,10 +137,9 @@ final class PhabricatorProjectEditorTestCase extends PhabricatorTestCase {
$this->leaveProject($proj, $user); $this->leaveProject($proj, $user);
$proj = $this->refreshProject($proj, $user, true); $proj = $this->refreshProject($proj, $user, true);
$this->assertEqual(true, (bool)$proj); $this->assertTrue((bool)$proj);
$this->assertEqual( $this->assertFalse(
false,
$proj->isUserMember($user->getPHID()), $proj->isUserMember($user->getPHID()),
'Leave works.'); 'Leave works.');
@ -163,10 +148,9 @@ final class PhabricatorProjectEditorTestCase extends PhabricatorTestCase {
$this->leaveProject($proj, $user); $this->leaveProject($proj, $user);
$proj = $this->refreshProject($proj, $user, true); $proj = $this->refreshProject($proj, $user, true);
$this->assertEqual(true, (bool)$proj); $this->assertTrue((bool)$proj);
$this->assertEqual( $this->assertFalse(
false,
$proj->isUserMember($user->getPHID()), $proj->isUserMember($user->getPHID()),
'Leaving an already-left project is a no-op.'); 'Leaving an already-left project is a no-op.');
@ -183,7 +167,7 @@ final class PhabricatorProjectEditorTestCase extends PhabricatorTestCase {
} catch (Exception $ex) { } catch (Exception $ex) {
$caught = $ex; $caught = $ex;
} }
$this->assertEqual(true, ($ex instanceof Exception)); $this->assertTrue($ex instanceof Exception);
// If a user can edit a project, they can join. // 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); $proj = $this->refreshProject($proj, $user, true);
$this->joinProject($proj, $user); $this->joinProject($proj, $user);
$proj = $this->refreshProject($proj, $user, true); $proj = $this->refreshProject($proj, $user, true);
$this->assertEqual( $this->assertTrue(
true,
$proj->isUserMember($user->getPHID()), $proj->isUserMember($user->getPHID()),
'Join allowed with edit permission.'); 'Join allowed with edit permission.');
$this->leaveProject($proj, $user); $this->leaveProject($proj, $user);
@ -209,8 +192,7 @@ final class PhabricatorProjectEditorTestCase extends PhabricatorTestCase {
$proj = $this->refreshProject($proj, $user, true); $proj = $this->refreshProject($proj, $user, true);
$this->joinProject($proj, $user); $this->joinProject($proj, $user);
$proj = $this->refreshProject($proj, $user, true); $proj = $this->refreshProject($proj, $user, true);
$this->assertEqual( $this->assertTrue(
true,
$proj->isUserMember($user->getPHID()), $proj->isUserMember($user->getPHID()),
'Join allowed with join permission.'); 'Join allowed with join permission.');
@ -223,8 +205,7 @@ final class PhabricatorProjectEditorTestCase extends PhabricatorTestCase {
$proj = $this->refreshProject($proj, $user, true); $proj = $this->refreshProject($proj, $user, true);
$this->leaveProject($proj, $user); $this->leaveProject($proj, $user);
$proj = $this->refreshProject($proj, $user, true); $proj = $this->refreshProject($proj, $user, true);
$this->assertEqual( $this->assertFalse(
false,
$proj->isUserMember($user->getPHID()), $proj->isUserMember($user->getPHID()),
'Leave allowed without any permission.'); 'Leave allowed without any permission.');
} }

View file

@ -6,17 +6,13 @@ final class PhabricatorWorkingCopyPullTestCase
public function testGitPullBasic() { public function testGitPullBasic() {
$repo = $this->buildPulledRepository('GT'); $repo = $this->buildPulledRepository('GT');
$this->assertEqual( $this->assertTrue(Filesystem::pathExists($repo->getLocalPath().'/HEAD'));
true,
Filesystem::pathExists($repo->getLocalPath().'/HEAD'));
} }
public function testHgPullBasic() { public function testHgPullBasic() {
$repo = $this->buildPulledRepository('HT'); $repo = $this->buildPulledRepository('HT');
$this->assertEqual( $this->assertTrue(Filesystem::pathExists($repo->getLocalPath().'/.hg'));
true,
Filesystem::pathExists($repo->getLocalPath().'/.hg'));
} }
public function testSVNPullBasic() { 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 // We don't pull local clones for SVN, so we don't expect there to be
// a working copy. // a working copy.
$this->assertEqual( $this->assertFalse(Filesystem::pathExists($repo->getLocalPath()));
false,
Filesystem::pathExists($repo->getLocalPath()));
} }
} }

View file

@ -33,8 +33,7 @@ final class PhabricatorRepositoryTestCase
$repo = new PhabricatorRepository(); $repo = new PhabricatorRepository();
$repo->setVersionControlSystem($git); $repo->setVersionControlSystem($git);
$this->assertEqual( $this->assertTrue(
true,
$repo->shouldTrackBranch('imaginary'), $repo->shouldTrackBranch('imaginary'),
'Track all branches by default.'); 'Track all branches by default.');
@ -44,13 +43,11 @@ final class PhabricatorRepositoryTestCase
'master' => true, 'master' => true,
)); ));
$this->assertEqual( $this->assertTrue(
true,
$repo->shouldTrackBranch('master'), $repo->shouldTrackBranch('master'),
'Track listed branches.'); 'Track listed branches.');
$this->assertEqual( $this->assertFalse(
false,
$repo->shouldTrackBranch('imaginary'), $repo->shouldTrackBranch('imaginary'),
'Do not track unlisted branches.'); 'Do not track unlisted branches.');
} }

View file

@ -1072,8 +1072,7 @@ final class PhabricatorChangeParserTestCase
$caught = $ex; $caught = $ex;
} }
$this->assertEqual( $this->assertFalse(
false,
($caught instanceof Exception), ($caught instanceof Exception),
pht('Natural SVN root should work properly.')); pht('Natural SVN root should work properly.'));
@ -1097,8 +1096,7 @@ final class PhabricatorChangeParserTestCase
$caught = $ex; $caught = $ex;
} }
$this->assertEqual( $this->assertTrue(
true,
($caught instanceof Exception), ($caught instanceof Exception),
pht('Artificial SVN root should fail.')); pht('Artificial SVN root should fail.'));
} }
@ -1136,8 +1134,7 @@ final class PhabricatorChangeParserTestCase
$commits = mpull($commits, null, 'getCommitIdentifier'); $commits = mpull($commits, null, 'getCommitIdentifier');
$this->assertEqual( $this->assertTrue(
true,
isset($commits['2']), isset($commits['2']),
'Expect rCHE2 to exist as a foreign stub.'); 'Expect rCHE2 to exist as a foreign stub.');

View file

@ -16,7 +16,7 @@ final class PhabricatorInfrastructureTestCase
*/ */
public function testEverythingImplemented() { public function testEverythingImplemented() {
id(new PhutilSymbolLoader())->selectAndLoadSymbols(); id(new PhutilSymbolLoader())->selectAndLoadSymbols();
$this->assertEqual(true, true); $this->assertTrue(true);
} }
public function testApplicationsInstalled() { public function testApplicationsInstalled() {
@ -66,7 +66,7 @@ final class PhabricatorInfrastructureTestCase
} }
$this->assertEqual(194431, strlen($buf)); $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()) $write = id(new HarbormasterScratchTable())
->setData('all.utf8.bmp') ->setData('all.utf8.bmp')
@ -96,9 +96,7 @@ final class PhabricatorInfrastructureTestCase
$caught = $ex; $caught = $ex;
} }
$this->assertEqual( $this->assertTrue($caught instanceof AphrontQueryCharacterSetException);
true,
($caught instanceof AphrontQueryCharacterSetException));
} }
} }

View file

@ -76,10 +76,8 @@ final class PhabricatorWorkerTestCase extends PhabricatorTestCase {
'doWork' => 'fail-temporary', 'doWork' => 'fail-temporary',
)); ));
$this->assertEqual(false, $task->isArchived()); $this->assertFalse($task->isArchived());
$this->assertEqual( $this->assertTrue($task->getExecutionException() instanceof Exception);
true,
($task->getExecutionException() instanceof Exception));
} }
public function testTooManyTaskFailures() { public function testTooManyTaskFailures() {
@ -92,43 +90,35 @@ final class PhabricatorWorkerTestCase extends PhabricatorTestCase {
)); ));
// Temporary... // Temporary...
$this->assertEqual(false, $task->isArchived()); $this->assertFalse($task->isArchived());
$this->assertEqual( $this->assertTrue($task->getExecutionException() instanceof Exception);
true,
($task->getExecutionException() instanceof Exception));
$this->assertEqual(1, $task->getFailureCount()); $this->assertEqual(1, $task->getFailureCount());
// Temporary... // Temporary...
$task = $this->expectNextLease($task); $task = $this->expectNextLease($task);
$task = $task->executeTask(); $task = $task->executeTask();
$this->assertEqual(false, $task->isArchived()); $this->assertFalse($task->isArchived());
$this->assertEqual( $this->assertTrue($task->getExecutionException() instanceof Exception);
true,
($task->getExecutionException() instanceof Exception));
$this->assertEqual(2, $task->getFailureCount()); $this->assertEqual(2, $task->getFailureCount());
// Temporary... // Temporary...
$task = $this->expectNextLease($task); $task = $this->expectNextLease($task);
$task = $task->executeTask(); $task = $task->executeTask();
$this->assertEqual(false, $task->isArchived()); $this->assertFalse($task->isArchived());
$this->assertEqual( $this->assertTrue($task->getExecutionException() instanceof Exception);
true,
($task->getExecutionException() instanceof Exception));
$this->assertEqual(3, $task->getFailureCount()); $this->assertEqual(3, $task->getFailureCount());
// Temporary... // Temporary...
$task = $this->expectNextLease($task); $task = $this->expectNextLease($task);
$task = $task->executeTask(); $task = $task->executeTask();
$this->assertEqual(false, $task->isArchived()); $this->assertFalse($task->isArchived());
$this->assertEqual( $this->assertTrue($task->getExecutionException() instanceof Exception);
true,
($task->getExecutionException() instanceof Exception));
$this->assertEqual(4, $task->getFailureCount()); $this->assertEqual(4, $task->getFailureCount());
// Permanent. // Permanent.
$task = $this->expectNextLease($task); $task = $this->expectNextLease($task);
$task = $task->executeTask(); $task = $task->executeTask();
$this->assertEqual(true, $task->isArchived()); $this->assertTrue($task->isArchived());
$this->assertEqual( $this->assertEqual(
PhabricatorWorkerArchiveTask::RESULT_FAILURE, PhabricatorWorkerArchiveTask::RESULT_FAILURE,
$task->getResult()); $task->getResult());
@ -151,7 +141,7 @@ final class PhabricatorWorkerTestCase extends PhabricatorTestCase {
'getRequiredLeaseTime' => 1000000, 'getRequiredLeaseTime' => 1000000,
)); ));
$this->assertEqual(true, ($task->getLeaseExpires() - time()) > 1000); $this->assertTrue(($task->getLeaseExpires() - time()) > 1000);
} }
public function testLeasedIsOldestFirst() { public function testLeasedIsOldestFirst() {

View file

@ -32,9 +32,7 @@ final class PhabricatorEdgeTestCase extends PhabricatorTestCase {
$caught = $ex; $caught = $ex;
} }
$this->assertEqual( $this->assertTrue($caught instanceof Exception);
true,
$caught instanceof Exception);
// The first edit should go through (no cycle), bu the second one should // The first edit should go through (no cycle), bu the second one should
@ -56,9 +54,7 @@ final class PhabricatorEdgeTestCase extends PhabricatorTestCase {
$caught = $ex; $caught = $ex;
} }
$this->assertEqual( $this->assertTrue($caught instanceof Exception);
true,
$caught instanceof Exception);
} }

View file

@ -104,7 +104,7 @@ final class PhabricatorEnvTestCase extends PhabricatorTestCase {
$caught = $ex; $caught = $ex;
} }
$this->assertEqual(true, ($caught instanceof Exception)); $this->assertTrue($caught instanceof Exception);
} }
public function testOverrides() { public function testOverrides() {
@ -139,8 +139,7 @@ final class PhabricatorEnvTestCase extends PhabricatorTestCase {
$caught = $ex; $caught = $ex;
} }
$this->assertEqual( $this->assertTrue(
true,
$caught instanceof Exception, $caught instanceof Exception,
"Destroying a scoped environment which is not on the top of the stack ". "Destroying a scoped environment which is not on the top of the stack ".
"should throw."); "should throw.");
@ -163,7 +162,7 @@ final class PhabricatorEnvTestCase extends PhabricatorTestCase {
} catch (Exception $ex) { } catch (Exception $ex) {
$caught = $ex; $caught = $ex;
} }
$this->assertEqual(true, $caught instanceof Exception); $this->assertTrue($caught instanceof Exception);
$caught = null; $caught = null;
try { try {
@ -171,7 +170,7 @@ final class PhabricatorEnvTestCase extends PhabricatorTestCase {
} catch (Exception $ex) { } catch (Exception $ex) {
$caught = $ex; $caught = $ex;
} }
$this->assertEqual(false, $caught instanceof Exception); $this->assertFalse($caught instanceof Exception);
} }
} }

View file

@ -18,7 +18,7 @@ final class AphrontIsolatedDatabaseConnectionTestCase
$this->newIsolatedConnection(), $this->newIsolatedConnection(),
'INSERT INVALID SYNTAX'); 'INSERT INVALID SYNTAX');
$this->assertEqual(true, true); $this->assertTrue(true);
} }
public function testInsertGeneratesID() { public function testInsertGeneratesID() {
@ -30,10 +30,9 @@ final class AphrontIsolatedDatabaseConnectionTestCase
queryfx($conn, 'INSERT'); queryfx($conn, 'INSERT');
$id2 = $conn->getInsertID(); $id2 = $conn->getInsertID();
$this->assertEqual(true, (bool)$id1, 'ID1 exists.'); $this->assertTrue((bool)$id1, 'ID1 exists.');
$this->assertEqual(true, (bool)$id2, 'ID2 exists.'); $this->assertTrue((bool)$id2, 'ID2 exists.');
$this->assertEqual( $this->assertTrue(
true,
$id1 != $id2, $id1 != $id2,
"IDs '{$id1}' and '{$id2}' are distinct."); "IDs '{$id1}' and '{$id2}' are distinct.");
} }
@ -42,7 +41,7 @@ final class AphrontIsolatedDatabaseConnectionTestCase
$conn = $this->newIsolatedConnection(); $conn = $this->newIsolatedConnection();
queryfx($conn, 'DELETE'); queryfx($conn, 'DELETE');
$this->assertEqual(true, true); $this->assertTrue(true);
} }
public function testTransactionStack() { public function testTransactionStack() {

View file

@ -31,7 +31,7 @@ final class AphrontMySQLDatabaseConnectionTestCase
} catch (AphrontQueryConnectionLostException $ex) { } catch (AphrontQueryConnectionLostException $ex) {
$caught = $ex; $caught = $ex;
} }
$this->assertEqual(true, $caught instanceof Exception); $this->assertTrue($caught instanceof Exception);
} }
} }

View file

@ -23,9 +23,8 @@ final class QueryFormattingTestCase extends PhabricatorTestCase {
} catch (Exception $ex) { } catch (Exception $ex) {
$raised = $ex; $raised = $ex;
} }
$this->assertEqual( $this->assertTrue(
(bool)$raised, (bool)$raised,
true,
'qsprintf should raise exception for invalid %d conversion.'); 'qsprintf should raise exception for invalid %d conversion.');
$this->assertEqual( $this->assertEqual(

View file

@ -65,8 +65,7 @@ final class LiskFixtureTestCase extends PhabricatorTestCase {
$obj->killTransaction(); $obj->killTransaction();
$this->assertEqual( $this->assertTrue(
true,
($loaded !== null), ($loaded !== null),
"Reads inside transactions should have transaction visibility."); "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('cow'));
$this->assertEqual(null, $load->load($id."cow")); $this->assertEqual(null, $load->load($id."cow"));
$this->assertEqual(true, (bool)$load->load((int)$id)); $this->assertTrue((bool)$load->load((int)$id));
$this->assertEqual(true, (bool)$load->load((string)$id)); $this->assertTrue((bool)$load->load((string)$id));
} }
public function testCounters() { public function testCounters() {

View file

@ -13,8 +13,8 @@ final class LiskIsolationTestCase extends PhabricatorTestCase {
$id = $dao->getID(); $id = $dao->getID();
$phid = $dao->getPHID(); $phid = $dao->getPHID();
$this->assertEqual(true, (bool)$id, 'Expect ID generated.'); $this->assertTrue((bool)$id, 'Expect ID generated.');
$this->assertEqual(true, (bool)$phid, 'Expect PHID generated.'); $this->assertTrue((bool)$phid, 'Expect PHID generated.');
$dao->save(); // Effects update $dao->save(); // Effects update
@ -54,7 +54,7 @@ final class LiskIsolationTestCase extends PhabricatorTestCase {
// Expected, pass. // Expected, pass.
} }
$this->assertEqual(true, true); $this->assertTrue(true);
} }
public function testMagicMethods() { public function testMagicMethods() {
@ -82,8 +82,7 @@ final class LiskIsolationTestCase extends PhabricatorTestCase {
} catch (Exception $thrown) { } catch (Exception $thrown) {
$ex = $thrown; $ex = $thrown;
} }
$this->assertEqual( $this->assertTrue(
true,
(bool)$ex, (bool)$ex,
'Typoing "get" should throw.'); 'Typoing "get" should throw.');
@ -93,8 +92,7 @@ final class LiskIsolationTestCase extends PhabricatorTestCase {
} catch (Exception $thrown) { } catch (Exception $thrown) {
$ex = $thrown; $ex = $thrown;
} }
$this->assertEqual( $this->assertTrue(
true,
(bool)$ex, (bool)$ex,
'Typoing "set" should throw.'); 'Typoing "set" should throw.');
@ -104,8 +102,7 @@ final class LiskIsolationTestCase extends PhabricatorTestCase {
} catch (Exception $thrown) { } catch (Exception $thrown) {
$ex = $thrown; $ex = $thrown;
} }
$this->assertEqual( $this->assertTrue(
true,
(bool)$ex, (bool)$ex,
'Made up method should throw.'); 'Made up method should throw.');
} }

View file

@ -6,15 +6,11 @@ final class PhabricatorTimeTestCase extends PhabricatorTestCase {
$t = 1370202281; $t = 1370202281;
$time = PhabricatorTime::pushTime($t, 'UTC'); $time = PhabricatorTime::pushTime($t, 'UTC');
$this->assertEqual( $this->assertTrue(PhabricatorTime::getNow() === $t);
true,
(PhabricatorTime::getNow() === $t));
unset($time); unset($time);
$this->assertEqual( $this->assertFalse(PhabricatorTime::getNow() === $t);
false,
(PhabricatorTime::getNow() === $t));
} }
public function testParseLocalTime() { public function testParseLocalTime() {

View file

@ -11,8 +11,7 @@ final class PhabricatorPasswordHasherTestCase extends PhabricatorTestCase {
$caught = $ex; $caught = $ex;
} }
$this->assertEqual( $this->assertTrue(
true,
($caught instanceof Exception), ($caught instanceof Exception),
pht('Exception on unparseable hash format.')); pht('Exception on unparseable hash format.'));
@ -24,8 +23,7 @@ final class PhabricatorPasswordHasherTestCase extends PhabricatorTestCase {
$caught = $ex; $caught = $ex;
} }
$this->assertEqual( $this->assertTrue(
true,
($caught instanceof PhabricatorPasswordHasherUnavailableException), ($caught instanceof PhabricatorPasswordHasherUnavailableException),
pht('Fictional hasher unavailable.')); pht('Fictional hasher unavailable.'));
} }

View file

@ -4,7 +4,7 @@ final class PhabricatorAphrontViewTestCase extends PhabricatorTestCase {
public function testHasChildren() { public function testHasChildren() {
$view = new AphrontNullView(); $view = new AphrontNullView();
$this->assertEqual(false, $view->hasChildren()); $this->assertFalse($view->hasChildren());
$values = array( $values = array(
null, null,
@ -15,11 +15,11 @@ final class PhabricatorAphrontViewTestCase extends PhabricatorTestCase {
foreach ($values as $value) { foreach ($values as $value) {
$view->appendChild($value); $view->appendChild($value);
$this->assertEqual(false, $view->hasChildren()); $this->assertFalse($view->hasChildren());
} }
$view->appendChild("!"); $view->appendChild("!");
$this->assertEqual(true, $view->hasChildren()); $this->assertTrue($view->hasChildren());
} }
} }

View file

@ -23,7 +23,7 @@ final class PHUIListViewTestCase extends PhabricatorTestCase {
} catch (Exception $ex) { } catch (Exception $ex) {
$caught = $ex; $caught = $ex;
} }
$this->assertEqual(true, $caught instanceof Exception); $this->assertTrue($caught instanceof Exception);
$menu->addMenuItemAfter('a', $this->newLink('test2')); $menu->addMenuItemAfter('a', $this->newLink('test2'));
$menu->addMenuItemAfter(null, $this->newLink('test3')); $menu->addMenuItemAfter(null, $this->newLink('test3'));
@ -52,7 +52,7 @@ final class PHUIListViewTestCase extends PhabricatorTestCase {
} catch (Exception $ex) { } catch (Exception $ex) {
$caught = $ex; $caught = $ex;
} }
$this->assertEqual(true, $caught instanceof Exception); $this->assertTrue($caught instanceof Exception);
$menu->addMenuItemBefore('b', $this->newLink('test2')); $menu->addMenuItemBefore('b', $this->newLink('test2'));
$menu->addMenuItemBefore(null, $this->newLink('test3')); $menu->addMenuItemBefore(null, $this->newLink('test3'));
@ -83,7 +83,7 @@ final class PHUIListViewTestCase extends PhabricatorTestCase {
} catch (Exception $ex) { } catch (Exception $ex) {
$caught = $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('apple'));
$menu->addMenuItemToLabel('fruit', $this->newLink('banana')); $menu->addMenuItemToLabel('fruit', $this->newLink('banana'));