diff --git a/.github/workflows/continous-integration.yml b/.github/workflows/continous-integration.yml index 950626e..f2607b4 100644 --- a/.github/workflows/continous-integration.yml +++ b/.github/workflows/continous-integration.yml @@ -17,7 +17,7 @@ jobs: php-versions: ['7.3', '7.4', '8.0'] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -29,7 +29,7 @@ jobs: - name: Cache Composer packages id: composer-cache - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: vendor key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} @@ -40,13 +40,13 @@ jobs: run: composer update --prefer-dist --no-interaction - name: Run phpunit - run: XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-text --configuration=phpunit-ci.xml + run: XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-text --configuration=phpunit-ci-old-versions.xml - name: Install lowest dependencies run: composer update --prefer-dist --no-interaction --prefer-lowest - name: Run phpunit with lowest dependencies - run: XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-text --configuration=phpunit-ci.xml + run: XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-text --configuration=phpunit-ci-old-versions.xml build-new-php-version: @@ -62,7 +62,7 @@ jobs: php-versions: ['8.1', '8.2', '8.3'] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -74,7 +74,7 @@ jobs: - name: Cache Composer packages id: composer-cache - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: vendor key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} @@ -85,4 +85,4 @@ jobs: run: composer update --prefer-dist --no-interaction - name: Run phpunit - run: XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-text --configuration=phpunit-ci.xml \ No newline at end of file + run: XDEBUG_MODE=coverage vendor/bin/phpunit --color="always" --coverage-text --configuration=phpunit-ci.xml \ No newline at end of file diff --git a/.gitignore b/.gitignore index f2baa9f..6c5658e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ .idea .phpunit.result.cache +.phpunit.cache +test.results vendor/ coverage/ .coverage/ diff --git a/composer.json b/composer.json index 4c52c94..eea7a6e 100644 --- a/composer.json +++ b/composer.json @@ -21,13 +21,13 @@ "ext-json": "*", "ext-sockets": "*", "php-amqplib/php-amqplib": "^3.1", - "laravel/framework": "^6.20.12|^7.30.4|>=8.22.1|>=9.2|^10.0" + "laravel/framework": "^6.20.12|^7.30.4|>=8.22.1|>=9.2|^10.0|^11.0" }, "require-dev": { "ext-curl": "*", - "phpunit/phpunit": "^9.5", + "phpunit/phpunit": "^9.5|^10.0", "squizlabs/php_codesniffer": "^2.5", - "orchestra/testbench": "^4.18|^6.21|^8.0", + "orchestra/testbench": "^4.18|^6.21|^8.0|^9.0", "mockery/mockery": "^1.3" }, "autoload": { diff --git a/phpunit-ci-old-versions.xml b/phpunit-ci-old-versions.xml new file mode 100644 index 0000000..9b4a2a6 --- /dev/null +++ b/phpunit-ci-old-versions.xml @@ -0,0 +1,31 @@ + + + + + src/ + + + + + ./tests/Unit + + + ./tests/Integration + + + ./tests/Bugs + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/phpunit-ci.xml b/phpunit-ci.xml index 2971165..ada9de4 100644 --- a/phpunit-ci.xml +++ b/phpunit-ci.xml @@ -1,10 +1,5 @@ - - - - src/ - - + ./tests/Unit @@ -28,4 +23,9 @@ + + + src/ + + diff --git a/phpunit.xml.dist b/phpunit.xml.dist index bb64c35..f535194 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,10 +1,5 @@ - - - - src/ - - + ./tests/Unit @@ -28,4 +23,9 @@ + + + src/ + + diff --git a/tests/Unit/PigeonFakeTest.php b/tests/Unit/PigeonFakeTest.php index 1ace09e..8dd6421 100644 --- a/tests/Unit/PigeonFakeTest.php +++ b/tests/Unit/PigeonFakeTest.php @@ -8,7 +8,7 @@ use Convenia\Pigeon\Resolver\ResolverContract; use Convenia\Pigeon\Tests\TestCase; use Illuminate\Foundation\Testing\WithFaker; -use PHPUnit\Framework\Constraint\ExceptionMessage; +use PHPUnit\Framework\Constraint\StringContains; use PHPUnit\Framework\ExpectationFailedException; class PigeonFakeTest extends TestCase @@ -56,7 +56,10 @@ public function test_it_should_call_consumer_callback() $this->fail(); } catch (ExpectationFailedException $e) { - $this->assertThat($e, new ExceptionMessage("The queue [$queue] has no consumer")); + $this->assertThat( + $e->getMessage(), + new StringContains("The queue [$queue] has no consumer") + ); } // act @@ -87,7 +90,10 @@ public function test_it_should_call_consumer_fallback() $this->fail(); } catch (ExpectationFailedException $e) { - $this->assertThat($e, new ExceptionMessage("The queue [$queue] has no consumer")); + $this->assertThat( + $e->getMessage(), + new StringContains("The queue [$queue] has no consumer") + ); } // act @@ -150,7 +156,10 @@ public function test_it_should_assert_a_queue_has_consumers() $this->fail(); } catch (ExpectationFailedException $e) { - $this->assertThat($e, new ExceptionMessage("The queue [$queue] has no consumer")); + $this->assertThat( + $e->getMessage(), + new StringContains("The queue [$queue] has no consumer") + ); } // act @@ -180,7 +189,10 @@ public function test_it_should_assert_a_queue_has_consumers_with_specific_timeou $this->fail(); } catch (ExpectationFailedException $e) { - $this->assertThat($e, new ExceptionMessage("The queue [$queue] does not match consumer timeout")); + $this->assertThat( + $e->getMessage(), + new StringContains("The queue [$queue] does not match consumer timeout") + ); } $this->fake->assertConsuming($queue, 5); @@ -202,7 +214,10 @@ public function test_it_should_assert_a_queue_has_consumers_with_specific_multip $this->fail(); } catch (ExpectationFailedException $e) { - $this->assertThat($e, new ExceptionMessage("The queue [$queue] does not match consumer multiplicity")); + $this->assertThat( + $e->getMessage(), + new StringContains("The queue [$queue] does not match consumer multiplicity") + ); } $this->fake->assertConsuming($queue, 5, false); @@ -226,7 +241,10 @@ public function test_it_should_assert_message_published_using_routing() $this->fake->assertPublished($routing, $data); $this->fail(); } catch (ExpectationFailedException $e) { - $this->assertThat($e, new ExceptionMessage("No message published in [$routing] with body")); + $this->assertThat( + $e->getMessage(), + new StringContains("No message published in [$routing] with body") + ); } $this->fake->routing($routing) ->publish($data); @@ -252,7 +270,10 @@ public function test_it_should_fail_assert_message_published_using_routing_wrong $this->fake->assertPublished($routing, $data); $this->fail(); } catch (ExpectationFailedException $e) { - $this->assertThat($e, new ExceptionMessage("No message published in [$routing] with body")); + $this->assertThat( + $e->getMessage(), + new StringContains("No message published in [$routing] with body") + ); } $this->fake->routing($routing) ->publish([ @@ -263,7 +284,10 @@ public function test_it_should_fail_assert_message_published_using_routing_wrong $this->fake->assertPublished($routing, $data); $this->fail(); } catch (ExpectationFailedException $e) { - $this->assertThat($e, new ExceptionMessage("No message published in [$routing] with body")); + $this->assertThat( + $e->getMessage(), + new StringContains("No message published in [$routing] with body") + ); } } @@ -280,7 +304,10 @@ public function test_it_should_assert_event_emitted() $this->fake->assertDispatched($category, $data); $this->fail(); } catch (ExpectationFailedException $e) { - $this->assertThat($e, new ExceptionMessage("No event [$category] emitted with body")); + $this->assertThat( + $e->getMessage(), + new StringContains("No event [$category] emitted with body") + ); } $this->fake->dispatch($category, $data); @@ -297,7 +324,10 @@ public function test_it_should_assert_consuming_event() $this->fake->assertConsumingEvent($category); $this->fail(); } catch (ExpectationFailedException $e) { - $this->assertThat($e, new ExceptionMessage("No event consumer for [$category] event")); + $this->assertThat( + $e->getMessage(), + new StringContains("No event consumer for [$category] event") + ); } $this->fake->events($category) ->callback(function () { @@ -321,7 +351,10 @@ public function test_it_should_assert_consuming_event_with_specific_timeout() $this->fake->assertConsumingEvent($category, 3); $this->fail(); } catch (ExpectationFailedException $e) { - $this->assertThat($e, new ExceptionMessage("The event [$category] does not match consumer timeout")); + $this->assertThat( + $e->getMessage(), + new StringContains("The event [$category] does not match consumer timeout") + ); } $this->fake->assertConsumingEvent($category, 5); @@ -341,7 +374,10 @@ public function test_it_should_assert_consuming_event_with_specific_multiplicity $this->fake->assertConsumingEvent($category, 5, true); $this->fail(); } catch (ExpectationFailedException $e) { - $this->assertThat($e, new ExceptionMessage("The event [$category] does not match consumer multiplicity")); + $this->assertThat( + $e->getMessage(), + new StringContains("The event [$category] does not match consumer multiplicity") + ); } $this->fake->assertConsumingEvent($category, 5, false); @@ -361,7 +397,10 @@ public function test_it_should_call_event_callback() $this->fail(); } catch (ExpectationFailedException $e) { - $this->assertThat($e, new ExceptionMessage("The event [$event] has no listeners")); + $this->assertThat( + $e->getMessage(), + new StringContains("The event [$event] has no listeners") + ); } // act @@ -433,7 +472,10 @@ public function test_it_should_assert_event_not_dispatched() $this->fail(); } catch (ExpectationFailedException $e) { - $this->assertThat($e, new ExceptionMessage("Event [$category] emitted with body: ".json_encode($data))); + $this->assertThat( + $e->getMessage(), + new StringContains("Event [$category] emitted with body: ".json_encode($data)) + ); } $data = [