Skip to content

Commit dd7276d

Browse files
author
farhadzand
committed
fix: switch to PHPUnit to resolve XML parsing errors
- Replace Pest with PHPUnit to avoid configuration issues - Create clean phpunit.xml configuration - Add comprehensive cache cleanup in test script - Remove problematic Pest-specific settings
1 parent 5734654 commit dd7276d

File tree

4 files changed

+97
-4
lines changed

4 files changed

+97
-4
lines changed

.github/workflows/tests.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ jobs:
5959
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
6060
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
6161
62+
- name: Clear Pest cache
63+
run: |
64+
rm -rf vendor/pestphp/pest/cache
65+
rm -rf .phpunit.cache
66+
rm -rf .pest.cache
67+
find . -name "*.cache" -type f -delete 2>/dev/null || true
68+
6269
- name: Wait for RabbitMQ
6370
run: |
6471
echo "Waiting for RabbitMQ to be ready..."
@@ -85,5 +92,4 @@ jobs:
8592
RABBITMQ_USER: laravel
8693
RABBITMQ_PASSWORD: secret
8794
RABBITMQ_VHOST: b2b-field
88-
PEST_CACHE_DIRECTORY: ""
89-
run: ./vendor/bin/pest tests/Unit tests/Feature
95+
run: ./run-tests.sh

pest.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<pest
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:noNamespaceSchemaLocation="./vendor/pestphp/pest/pest.xsd"
53
stopOnFailure="false"
64
stopOnError="false"
75
>

phpunit.xml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd"
5+
backupGlobals="false"
6+
colors="true"
7+
processIsolation="false"
8+
stopOnFailure="false"
9+
stopOnError="false"
10+
bootstrap="vendor/autoload.php"
11+
>
12+
<testsuites>
13+
<testsuite name="Unit">
14+
<directory suffix="Test.php">./tests/Unit</directory>
15+
</testsuite>
16+
<testsuite name="Feature">
17+
<directory suffix="Test.php">./tests/Feature</directory>
18+
</testsuite>
19+
</testsuites>
20+
21+
<source>
22+
<include>
23+
<directory suffix=".php">./src</directory>
24+
</include>
25+
</source>
26+
27+
<php>
28+
<env name="APP_ENV" value="testing"/>
29+
<env name="BCRYPT_ROUNDS" value="4"/>
30+
<env name="CACHE_DRIVER" value="array"/>
31+
<env name="DB_CONNECTION" value="testing"/>
32+
<env name="MAIL_MAILER" value="array"/>
33+
<env name="QUEUE_CONNECTION" value="sync"/>
34+
<env name="SESSION_DRIVER" value="array"/>
35+
<env name="TELESCOPE_ENABLED" value="false"/>
36+
<env name="RABBITMQ_HOST" value="127.0.0.1"/>
37+
<env name="RABBITMQ_PORT" value="5673"/>
38+
<env name="RABBITMQ_USER" value="laravel"/>
39+
<env name="RABBITMQ_PASSWORD" value="secret"/>
40+
<env name="RABBITMQ_VHOST" value="b2b-field"/>
41+
</php>
42+
</phpunit>

run-tests.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
3+
# Simple test runner using PHPUnit directly to avoid Pest configuration issues
4+
echo "Running LaravelRabbitMQ Tests..."
5+
6+
# Set environment variables
7+
export APP_ENV=testing
8+
export BCRYPT_ROUNDS=4
9+
export CACHE_DRIVER=array
10+
export DB_CONNECTION=testing
11+
export MAIL_MAILER=array
12+
export QUEUE_CONNECTION=sync
13+
export SESSION_DRIVER=array
14+
export TELESCOPE_ENABLED=false
15+
export RABBITMQ_HOST=127.0.0.1
16+
export RABBITMQ_PORT=5673
17+
export RABBITMQ_USER=laravel
18+
export RABBITMQ_PASSWORD=secret
19+
export RABBITMQ_VHOST=b2b-field
20+
21+
echo "Checking AMQP extension..."
22+
if php -m | grep -q amqp; then
23+
echo "AMQP extension is available"
24+
else
25+
echo "AMQP extension is not available - this is expected in some environments"
26+
fi
27+
28+
# Clear any cache files that might cause issues
29+
rm -rf .phpunit.cache
30+
rm -rf .pest.cache
31+
find . -name "*.cache" -type f -delete 2>/dev/null || true
32+
33+
# Run tests with PHPUnit directly
34+
echo "Running Unit Tests..."
35+
if ./vendor/bin/phpunit --testsuite Unit --no-coverage --colors=never; then
36+
echo "Unit tests passed, running Feature tests..."
37+
if ./vendor/bin/phpunit --testsuite Feature --no-coverage --colors=never; then
38+
echo "All tests passed!"
39+
exit 0
40+
else
41+
echo "Feature tests failed"
42+
exit 1
43+
fi
44+
else
45+
echo "Unit tests failed"
46+
exit 1
47+
fi

0 commit comments

Comments
 (0)