Page MenuHomeDevCentral

D1546.id3945.diff
No OneTemporary

D1546.id3945.diff

diff --git a/tests/Console/Commands/ConfigShowTest.php b/tests/Console/Commands/ConfigShowTest.php
--- a/tests/Console/Commands/ConfigShowTest.php
+++ b/tests/Console/Commands/ConfigShowTest.php
@@ -31,9 +31,9 @@
$this->tester->execute(['command' => $this->command->getName()]);
- $this->assertRegexp('/Gates/', $this->tester->getDisplay());
- $this->assertRegexp('/Features/', $this->tester->getDisplay());
- $this->assertRegexp('/Services declared/', $this->tester->getDisplay());
+ $this->assertRegexpInDisplay('/Gates/');
+ $this->assertRegexpInDisplay('/Features/');
+ $this->assertRegexpInDisplay('/Services declared/');
}
public function testRegularExecuteWithService () {
@@ -44,7 +44,7 @@
->andReturn([$service]);
$this->tester->execute(['command' => $this->command->getName()]);
- $this->assertRegexp('/Storm/', $this->tester->getDisplay());
+ $this->assertRegexpInDisplay('/Storm/');
}
public function testRegularExecuteWithPhabricatorService () {
@@ -60,7 +60,9 @@
->shouldReceive('findServiceByProperty');
$this->tester->execute(['command' => $this->command->getName()]);
- $this->assertRegexp('/Phabricator.*Projects map not cached./', $this->tester->getDisplay());
+ $this->assertRegexpInDisplay(
+ '/Phabricator.*Projects map not cached./'
+ );
}
protected function mockProjectsMap () {
@@ -81,7 +83,7 @@
->shouldReceive('fetch->isCached')->once()->andReturn(true);
$this->tester->execute(['command' => $this->command->getName()]);
- $this->assertRegexp('/Phabricator.*✓/', $this->tester->getDisplay());
+ $this->assertRegexpInDisplay('/Phabricator.*✓/');
}
public function testExecuteWhenSomeFeatureIsDisabled () {
@@ -90,8 +92,12 @@
$this->servicesMock->shouldReceive('get')->once()->andReturn([]);
$this->tester->execute(['command' => $this->command->getName()]);
- $this->assertRegexp('/Gate *\| *✓ *\|/', $this->tester->getDisplay());
- $this->assertRegexp('/ActionsReport *\| *\|/', $this->tester->getDisplay());
+ $this->assertRegexpInDisplay(
+ '/Gate *\| *✓ *\|/'
+ );
+ $this->assertRegexpInDisplay(
+ '/ActionsReport *\| *\|/'
+ );
}
}
diff --git a/tests/Console/Commands/ConfigValidateTest.php b/tests/Console/Commands/ConfigValidateTest.php
--- a/tests/Console/Commands/ConfigValidateTest.php
+++ b/tests/Console/Commands/ConfigValidateTest.php
@@ -29,7 +29,7 @@
$this->tester->execute(['command' => $this->command->getName()]);
// When all files are valid, nothing is displayed
- $this->assertRegexp("/$error/", $this->tester->getDisplay());
+ $this->assertRegexpInDisplay("/$error/");
}
/**
diff --git a/tests/Console/Commands/InspireTest.php b/tests/Console/Commands/InspireTest.php
--- a/tests/Console/Commands/InspireTest.php
+++ b/tests/Console/Commands/InspireTest.php
@@ -12,7 +12,7 @@
public function testExecute () {
// A quote contain a - character and is embedded by PHP_EOL
$this->tester->execute(['command' => $this->command->getName()]);
- $this->assertRegexp('/\n.*-.*\n/', $this->tester->getDisplay());
+ $this->assertRegexpInDisplay('/\n.*-.*\n/');
}
}
diff --git a/tests/Console/Commands/NotificationsPayloadTest.php b/tests/Console/Commands/NotificationsPayloadTest.php
--- a/tests/Console/Commands/NotificationsPayloadTest.php
+++ b/tests/Console/Commands/NotificationsPayloadTest.php
@@ -23,9 +23,9 @@
],
]);
- $this->assertContains('"service": "DockerHub"', $this->tester->getDisplay());
- $this->assertContains('"project": "Acme"', $this->tester->getDisplay());
- $this->assertContains('svendowideit\/testhook', $this->tester->getDisplay());
+ $this->assertDisplayContains('"service": "DockerHub"');
+ $this->assertDisplayContains('"project": "Acme"');
+ $this->assertDisplayContains('svendowideit\/testhook');
}
public function testPhabricatorPayload () {
@@ -39,9 +39,9 @@
],
]);
- $this->assertContains('"service": "Phabricator"', $this->tester->getDisplay());
- $this->assertContains('"project": "Acme"', $this->tester->getDisplay());
- $this->assertContains('"type": "PSTE"', $this->tester->getDisplay());
+ $this->assertDisplayContains('"service": "Phabricator"');
+ $this->assertDisplayContains('"project": "Acme"');
+ $this->assertDisplayContains('"type": "PSTE"');
}
/**
@@ -62,11 +62,7 @@
],
]);
- $this->assertContains(
- 'File not found: /tmp/not.found',
- $this->tester->getDisplay()
- );
-
+ $this->assertDisplayContains('File not found: /tmp/not.found');
}
public function testServiceNotFound () {
@@ -81,9 +77,8 @@
],
]);
- $this->assertContains(
- 'Unknown service: InterdimensionalTeleport',
- $this->tester->getDisplay()
+ $this->assertDisplayContains(
+ 'Unknown service: InterdimensionalTeleport'
);
}
diff --git a/tests/Console/Commands/PhabricatorProjectsMapTest.php b/tests/Console/Commands/PhabricatorProjectsMapTest.php
--- a/tests/Console/Commands/PhabricatorProjectsMapTest.php
+++ b/tests/Console/Commands/PhabricatorProjectsMapTest.php
@@ -25,7 +25,9 @@
public function testRegularExecute () {
$this->tester->execute(['command' => $this->command->getName()]);
- $this->assertRegexp('/PHID.*Project name/', $this->tester->getDisplay());
- $this->assertRegexp('/PHID-PROJ-cztcgpvqr6smnnekotq7.*Agora/', $this->tester->getDisplay());
+ $this->assertRegexpInDisplay('/PHID.*Project name/');
+ $this->assertRegexpInDisplay(
+ '/PHID-PROJ-cztcgpvqr6smnnekotq7.*Agora/'
+ );
}
}
diff --git a/tests/Console/Commands/TestCase.php b/tests/Console/Commands/TestCase.php
--- a/tests/Console/Commands/TestCase.php
+++ b/tests/Console/Commands/TestCase.php
@@ -34,4 +34,19 @@
$this->tester = new CommandTester($this->command);
}
+ ///
+ /// Display assertions
+ ///
+
+ public function assertDisplayContains(string $expectedNeedle) {
+ $this->assertContains(
+ $expectedNeedle,
+ $this->tester->getDisplay()
+ );
+ }
+
+ public function assertRegexpInDisplay (string $pattern) {
+ $this->assertRegexp($pattern, $this->tester->getDisplay());
+ }
+
}

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 17, 02:37 (20 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2248557
Default Alt Text
D1546.id3945.diff (6 KB)

Event Timeline