Skip to content

Commit

Permalink
upgrade laravel and PHPunit
Browse files Browse the repository at this point in the history
  • Loading branch information
jleonardolemos committed Mar 29, 2024
1 parent 8185661 commit eb80b23
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/continous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
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:

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.idea
.phpunit.result.cache
.phpunit.cache
test.results
vendor/
coverage/
.coverage/
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
31 changes: 31 additions & 0 deletions phpunit-ci-old-versions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" bootstrap="vendor/autoload.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" verbose="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage includeUncoveredFiles="false">
<include>
<directory suffix=".php">src/</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
<testsuite name="Integration">
<directory suffix="Test.php">./tests/Integration</directory>
</testsuite>
<testsuite name="Bugs">
<directory prefix="Bug" suffix=".php">./tests/Bugs</directory>
</testsuite>
</testsuites>
<php>
<env name="APP_ENV" value="testing"/>
<env name="APP_KEY" value="AckfSECXIvnK5r28GVIWUAxmbBSjTsmF"/>
<env name="PIGEON_DRIVER" value="rabbit"/>
<env name="PIGEON_ADDRESS" value="localhost"/>
<env name="PIGEON_PORT" value="5672"/>
<env name="PIGEON_USER" value="guest"/>
<env name="PIGEON_PASSWORD" value="guest"/>
<env name="PIGEON_VHOST" value="/"/>
<env name="PIGEON_KEEPALIVE" value="true"/>
<env name="PIGEON_HEARTBEAT" value="60"/>
</php>
</phpunit>
12 changes: 6 additions & 6 deletions phpunit-ci.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" bootstrap="vendor/autoload.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" verbose="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage includeUncoveredFiles="false">
<include>
<directory suffix=".php">src/</directory>
</include>
</coverage>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd">
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
Expand All @@ -28,4 +23,9 @@
<env name="PIGEON_KEEPALIVE" value="true"/>
<env name="PIGEON_HEARTBEAT" value="60"/>
</php>
<source>
<include>
<directory suffix=".php">src/</directory>
</include>
</source>
</phpunit>
12 changes: 6 additions & 6 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" bootstrap="vendor/autoload.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" verbose="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage includeUncoveredFiles="false">
<include>
<directory suffix=".php">src/</directory>
</include>
</coverage>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd">
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
Expand All @@ -28,4 +23,9 @@
<env name="PIGEON_KEEPALIVE" value="true"/>
<env name="PIGEON_HEARTBEAT" value="60"/>
</php>
<source>
<include>
<directory suffix=".php">src/</directory>
</include>
</source>
</phpunit>
72 changes: 57 additions & 15 deletions tests/Unit/PigeonFakeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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([
Expand All @@ -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")
);
}
}

Expand All @@ -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);

Expand All @@ -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 () {
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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
Expand Down Expand Up @@ -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 = [
Expand Down

0 comments on commit eb80b23

Please sign in to comment.