Skip to content

Commit

Permalink
Update codebase to PHP 7.4 (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
TavoNiievez committed Nov 21, 2021
1 parent 1cdac18 commit 5fc4c96
Show file tree
Hide file tree
Showing 38 changed files with 221 additions and 148 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

strategy:
matrix:
php: [7.3, 7.4, 8.0]
php: [7.4, 8.0, 8.1]

steps:
- name: Checkout code
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ With [BDD][3] assertions influenced by [Chai][4], [Jasmine][5], and [RSpec][6] y

## Installation

*Requires PHP 7.1 or higher*
*Requires PHP 7.4 or higher*

```
composer require codeception/verify --dev
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
}
],
"require": {
"php": "^7.3 || ^8.0",
"php": "^7.4 || ^8.0",
"ext-dom": "*",
"phpunit/phpunit": "^9.3"
},
Expand Down
4 changes: 3 additions & 1 deletion src/Codeception/Exception/InvalidVerifyException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace Codeception\Exception;

Expand Down
22 changes: 12 additions & 10 deletions src/Codeception/Verify/Asserts/AssertThrows.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace Codeception\Verify\Asserts;

Expand All @@ -18,23 +20,23 @@ public function assertThrows($throws = null, $message = false): self

try {
call_user_func($this->actual);
} catch (Throwable $exception) {
} catch (Throwable $throwable) {
if (!$throws) {
return $this; // it throws
}

$actualThrows = get_class($exception);
$actualMessage = $exception->getMessage();
$actualThrows = get_class($throwable);
$actualMessage = $throwable->getMessage();

Assert::assertSame($throws, $actualThrows, sprintf('exception \'%s\' was expected, but \'%s\' was thrown', $throws, $actualThrows));
Assert::assertSame($throws, $actualThrows, sprintf("exception '%s' was expected, but '%s' was thrown", $throws, $actualThrows));

if ($message) {
Assert::assertSame($message, $actualMessage, sprintf('exception message \'%s\' was expected, but \'%s\' was received', $message, $actualMessage));
Assert::assertSame($message, $actualMessage, sprintf("exception message '%s' was expected, but '%s' was received", $message, $actualMessage));
}
}

if (!isset($exception)) {
throw new ExpectationFailedException(sprintf('exception \'%s\' was not thrown as expected', $throws));
if (!isset($throwable)) {
throw new ExpectationFailedException(sprintf("exception '%s' was not thrown as expected", $throws));
}

return $this;
Expand Down Expand Up @@ -62,11 +64,11 @@ public function assertDoesNotThrow($throws = null, $message = false): self
}

if (!$message) {
throw new ExpectationFailedException(sprintf('exception \'%s\' was not expected to be thrown', $throws));
throw new ExpectationFailedException(sprintf("exception '%s' was not expected to be thrown", $throws));
}

if ($message === $actualMessage) {
throw new ExpectationFailedException(sprintf('exception \'%s\' with message \'%s\' was not expected to be thrown', $throws, $message));
throw new ExpectationFailedException(sprintf("exception '%s' with message '%s' was not expected to be thrown", $throws, $message));
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/Codeception/Verify/Expect.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace Codeception\Verify;

Expand Down

0 comments on commit 5fc4c96

Please sign in to comment.