Skip to content

Commit 305695d

Browse files
Fix tests for phpunit 11
1 parent 8c511c0 commit 305695d

File tree

7 files changed

+52
-22
lines changed

7 files changed

+52
-22
lines changed

.github/workflows/tests.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ jobs:
4747
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
4848
4949
- name: Execute tests
50+
env:
51+
XDEBUG_MODE: coverage
5052
run: vendor/bin/phpunit
5153

5254
- name: PHPStan Static Analysis
@@ -97,7 +99,7 @@ jobs:
9799
- name: Find pint version
98100
id: find_pint_version
99101
run: |
100-
PINT_VERSION='v1.13'
102+
PINT_VERSION='v1.25.1'
101103
echo "Attempting to load pint version from composer.lock"
102104
if [ -f composer.lock ]; then
103105
PINT_VERSION=$(jq '.["packages-dev"][] | select(.name == "laravel/pint") | .version' composer.lock)

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ tests/coverage
33
vendor
44
composer.lock
55
.phpstorm.meta.php
6-
tests/reports
6+
tests/reports/*
7+
!tests/reports/.gitignore
78
.phpunit.result.cache

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"mockery/mockery": "^1.5",
2828
"laravel/framework": "^11.0|^12.0",
2929
"phpunit/phpunit": "^10.0|^11.0",
30-
"squizlabs/php_codesniffer": "^3.5",
30+
"squizlabs/php_codesniffer": "^3.5",
3131
"phpstan/phpstan": "^1.9",
3232
"nunomaduro/larastan": "^1|^2",
3333
"orchestra/testbench": "^9.0|^10.0",

phpunit.xml.dist

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" backupStaticAttributes="false" colors="true" verbose="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
3-
<coverage processUncoveredFiles="true">
4-
<include>
5-
<directory suffix=".php">src/</directory>
6-
</include>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd">
3+
<coverage>
74
<report>
85
<clover outputFile="tests/reports/clover.xml"/>
9-
<text outputFile=""/>
106
</report>
117
</coverage>
8+
<source>
9+
<include>
10+
<directory suffix=".php">src/</directory>
11+
</include>
12+
</source>
1213
<testsuites>
1314
<testsuite name=":vendor Test Suite">
1415
<directory>tests</directory>

tests/BatchJobTest.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,38 @@
33
namespace LukeWaite\LaravelQueueAwsBatch\Tests;
44

55
use LukeWaite\LaravelQueueAwsBatch\Exceptions\UnsupportedException;
6+
use LukeWaite\LaravelQueueAwsBatch\Jobs\BatchJob;
67
use Mockery\Adapter\Phpunit\MockeryTestCase as TestCase;
78
use Mockery as m;
9+
use Mockery\MockInterface;
810

911
class BatchJobTest extends TestCase
1012
{
11-
public function setUp(): void
13+
protected \stdClass $job;
14+
15+
protected MockInterface $batchQueue;
16+
17+
protected BatchJob $batchJob;
18+
19+
protected function setUp(): void
1220
{
21+
parent::setUp();
22+
1323
$this->job = new \stdClass();
1424
$this->job->payload = '{"job":"foo","data":["data"]}';
1525
$this->job->id = 4;
1626
$this->job->queue = 'default';
1727
$this->job->attempts = 1;
1828

19-
/** @var \LukeWaite\LaravelQueueAwsBatch\Jobs\BatchJob $batchJob */
20-
$this->batchJob = $this->getMockBuilder('LukeWaite\LaravelQueueAwsBatch\Jobs\BatchJob')->setMethods(null)->setConstructorArgs([
21-
m::mock('Illuminate\Container\Container'),
22-
$this->batchQueue = m::mock('LukeWaite\LaravelQueueAwsBatch\Queues\BatchQueue'),
29+
$this->batchQueue = m::mock('LukeWaite\LaravelQueueAwsBatch\Queues\BatchQueue');
30+
31+
$this->batchJob = new BatchJob(
32+
new \Illuminate\Container\Container(),
33+
$this->batchQueue,
2334
$this->job,
2435
'testConnection',
2536
'defaultQueue',
26-
])->getMock();
37+
);
2738
}
2839

2940
public function testReleaseDoesntDeleteButDoesUpdate()

tests/BatchQueueTest.php

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,36 @@
44

55
use Carbon\Carbon;
66
use LukeWaite\LaravelQueueAwsBatch\Exceptions\UnsupportedException;
7+
use LukeWaite\LaravelQueueAwsBatch\Queues\BatchQueue;
78
use Mockery\Adapter\Phpunit\MockeryTestCase as TestCase;
89
use Mockery as m;
10+
use Mockery\MockInterface;
911

1012
class BatchQueueTest extends TestCase
1113
{
12-
public function setUp(): void
14+
protected MockInterface $database;
15+
16+
protected MockInterface $batch;
17+
18+
protected BatchQueue $queue;
19+
20+
protected function setUp(): void
1321
{
14-
$this->queue = $this->getMockBuilder('LukeWaite\LaravelQueueAwsBatch\Queues\BatchQueue')->setMethods(null)->setConstructorArgs([
15-
$this->database = m::mock('Illuminate\Database\Connection'),
22+
parent::setUp();
23+
24+
$this->database = m::mock('Illuminate\Database\Connection');
25+
$this->batch = m::mock('Aws\Batch\BatchClient');
26+
27+
$this->queue = new BatchQueue(
28+
$this->database,
1629
'table',
1730
'default',
1831
'60',
1932
'jobdefinition',
20-
$this->batch = m::mock('Aws\Batch\BatchClient'),
21-
])->getMock();
33+
$this->batch,
34+
);
2235

23-
$this->queue->setContainer(m::mock('Illuminate\Container\Container'));
36+
$this->queue->setContainer(new \Illuminate\Container\Container());
2437
}
2538

2639
public function testPushProperlyPushesJobOntoDatabase()
@@ -84,7 +97,7 @@ public function testGetJobById()
8497

8598
$this->database->shouldReceive('commit')->once();
8699

87-
$this->queue->getJobById(1, 'default');
100+
$this->queue->getJobById(1);
88101

89102
Carbon::setTestNow();
90103
}

tests/reports/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore

0 commit comments

Comments
 (0)