Skip to content

Commit d47264a

Browse files
authored
Finalize L11 (#16)
* Tests for L11 and PHP8.3 * Fix styling * Fix * No PHP 8.1 * Update pest * Update psalm * ergh matrixes are hard… * Latest only for tests * wip --------- Co-authored-by: slashequip <slashequip@users.noreply.github.com>
1 parent 35cccbb commit d47264a

File tree

10 files changed

+84
-63
lines changed

10 files changed

+84
-63
lines changed

.github/workflows/run-tests.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,12 @@ jobs:
99
fail-fast: true
1010
matrix:
1111
os: [ubuntu-latest]
12-
php: [8.1, 8.2]
13-
laravel: [9.*, 10.*]
12+
php: [8.3]
13+
laravel: [11.*]
1414
stability: [prefer-stable]
1515
include:
16-
- laravel: 9.*
17-
testbench: 7.*
18-
- laravel: 10.*
19-
testbench: 8.*
16+
- laravel: 11.*
17+
testbench: 9.*
2018

2119
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
2220

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
/composer.lock
55
/build
66
/.php_cs.cache
7+
/.phpunit.cache

composer.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@
2222
"laravel/pint": "^1.10",
2323
"mockery/mockery": "^1.4",
2424
"nunomaduro/larastan": "^2.0",
25-
"orchestra/testbench": "^7.25|^8.5",
26-
"pestphp/pest": "^1.0",
27-
"phpunit/phpunit": "^9.3",
28-
"vimeo/psalm": "^4.6"
25+
"orchestra/testbench": "^7.25|^8.5|^9.0",
26+
"pestphp/pest": "^2.0",
27+
"vimeo/psalm": "^5.24"
2928
},
3029
"autoload": {
3130
"psr-4": {

phpunit.xml.dist

Lines changed: 21 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,23 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
5-
backupGlobals="false"
6-
backupStaticAttributes="false"
7-
bootstrap="vendor/autoload.php"
8-
colors="true"
9-
convertErrorsToExceptions="true"
10-
convertNoticesToExceptions="true"
11-
convertWarningsToExceptions="true"
12-
processIsolation="false"
13-
stopOnFailure="false"
14-
executionOrder="random"
15-
failOnWarning="true"
16-
failOnRisky="true"
17-
failOnEmptyTestSuite="true"
18-
beStrictAboutOutputDuringTests="true"
19-
verbose="true"
20-
>
21-
<testsuites>
22-
<testsuite name="Laravel Segment Test Suite">
23-
<directory>tests</directory>
24-
</testsuite>
25-
</testsuites>
26-
<coverage>
27-
<include>
28-
<directory suffix=".php">./src</directory>
29-
</include>
30-
<report>
31-
<html outputDirectory="build/coverage"/>
32-
<text outputFile="build/coverage.txt"/>
33-
<clover outputFile="build/logs/clover.xml"/>
34-
</report>
35-
</coverage>
36-
<logging>
37-
<junit outputFile="build/report.junit.xml"/>
38-
</logging>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" executionOrder="random" failOnWarning="true" failOnRisky="true" failOnEmptyTestSuite="true" beStrictAboutOutputDuringTests="true" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
3+
<testsuites>
4+
<testsuite name="Laravel Segment Test Suite">
5+
<directory>tests</directory>
6+
</testsuite>
7+
</testsuites>
8+
<coverage>
9+
<report>
10+
<html outputDirectory="build/coverage"/>
11+
<text outputFile="build/coverage.txt"/>
12+
<clover outputFile="build/logs/clover.xml"/>
13+
</report>
14+
</coverage>
15+
<logging>
16+
<junit outputFile="build/report.junit.xml"/>
17+
</logging>
18+
<source>
19+
<include>
20+
<directory suffix=".php">./src</directory>
21+
</include>
22+
</source>
3923
</phpunit>

phpunit.xml.dist.bak

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
5+
backupGlobals="false"
6+
backupStaticAttributes="false"
7+
bootstrap="vendor/autoload.php"
8+
colors="true"
9+
convertErrorsToExceptions="true"
10+
convertNoticesToExceptions="true"
11+
convertWarningsToExceptions="true"
12+
processIsolation="false"
13+
stopOnFailure="false"
14+
executionOrder="random"
15+
failOnWarning="true"
16+
failOnRisky="true"
17+
failOnEmptyTestSuite="true"
18+
beStrictAboutOutputDuringTests="true"
19+
verbose="true"
20+
>
21+
<testsuites>
22+
<testsuite name="Laravel Segment Test Suite">
23+
<directory>tests</directory>
24+
</testsuite>
25+
</testsuites>
26+
<coverage>
27+
<include>
28+
<directory suffix=".php">./src</directory>
29+
</include>
30+
<report>
31+
<html outputDirectory="build/coverage"/>
32+
<text outputFile="build/coverage.txt"/>
33+
<clover outputFile="build/logs/clover.xml"/>
34+
</report>
35+
</coverage>
36+
<logging>
37+
<junit outputFile="build/report.junit.xml"/>
38+
</logging>
39+
</phpunit>

src/Contracts/SegmentServiceContract.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ public function setGlobalContext(array $globalContext): void;
1616
/**
1717
* @param array<string, mixed> $eventData
1818
*/
19-
public function track(string $event, array $eventData = null): void;
19+
public function track(string $event, ?array $eventData = null): void;
2020

2121
/**
2222
* @param array<string, mixed> $identifyData
2323
*/
24-
public function identify(array $identifyData = null): void;
24+
public function identify(?array $identifyData = null): void;
2525

2626
public function forUser(CanBeIdentifiedForSegment $user): PendingUserSegment;
2727

src/Facades/Fakes/SegmentFake.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function identify(?array $identifyData = []): void
4949
/**
5050
* @param array<string, mixed> $eventData
5151
*/
52-
public function track(string $event, array $eventData = null): void
52+
public function track(string $event, ?array $eventData = null): void
5353
{
5454
$this->events[] = new SimpleSegmentEvent($this->user, $event, $eventData);
5555
}
@@ -76,7 +76,7 @@ public function terminate(): void
7676
{
7777
}
7878

79-
public function assertIdentified(Closure|int $callback = null): void
79+
public function assertIdentified(Closure|int|null $callback = null): void
8080
{
8181
if (is_numeric($callback)) {
8282
$this->assertIdentifiedTimes($callback);
@@ -100,7 +100,7 @@ public function assertIdentifiedTimes(int $times = 1): void
100100
);
101101
}
102102

103-
public function assertNotIdentified(Closure $callback = null): void
103+
public function assertNotIdentified(?Closure $callback = null): void
104104
{
105105
PHPUnit::assertCount(
106106
0, $this->identities($callback),
@@ -115,7 +115,7 @@ public function assertNothingIdentified(): void
115115
PHPUnit::assertEmpty($identities, $identities->count().' events were found unexpectedly.');
116116
}
117117

118-
public function assertTracked(Closure|int $callback = null): void
118+
public function assertTracked(Closure|int|null $callback = null): void
119119
{
120120
if (is_numeric($callback)) {
121121
$this->assertTrackedTimes($callback);
@@ -139,23 +139,23 @@ public function assertTrackedTimes(int $times = 1): void
139139
);
140140
}
141141

142-
public function assertEventTracked(string $event, Closure|int $callback = null): void
142+
public function assertEventTracked(string $event, Closure|int|null $callback = null): void
143143
{
144144
PHPUnit::assertTrue(
145145
$this->events($callback, $event)->count() > 0,
146146
'The expected events were not called.'
147147
);
148148
}
149149

150-
public function assertNotTracked(Closure $callback = null): void
150+
public function assertNotTracked(?Closure $callback = null): void
151151
{
152152
PHPUnit::assertCount(
153153
0, $this->events($callback),
154154
'The unexpected event was called.'
155155
);
156156
}
157157

158-
public function assertEventNotTracked(string $event, Closure|int $callback = null): void
158+
public function assertEventNotTracked(string $event, Closure|int|null $callback = null): void
159159
{
160160
PHPUnit::assertCount(
161161
0, $this->events($callback, $event),
@@ -178,7 +178,7 @@ public function getContext(): ?array
178178
return $this->context;
179179
}
180180

181-
private function identities(Closure $callback = null): Collection
181+
private function identities(?Closure $callback = null): Collection
182182
{
183183
$identities = collect($this->identities);
184184

@@ -191,7 +191,7 @@ private function identities(Closure $callback = null): Collection
191191
return $identities->filter(fn (SimpleSegmentIdentify $identity) => $callback($identity));
192192
}
193193

194-
private function events(Closure $callback = null, string $event = null): Collection
194+
private function events(?Closure $callback = null, ?string $event = null): Collection
195195
{
196196
$events = collect($this->events);
197197

src/PendingUserSegment.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function __construct(SegmentServiceContract $service, CanBeIdentifiedForS
2020
/**
2121
* @param array<string, mixed>|null $eventData
2222
*/
23-
public function track(string $event, array $eventData = null): void
23+
public function track(string $event, ?array $eventData = null): void
2424
{
2525
$this->service->push(
2626
new SimpleSegmentEvent($this->user, $event, $eventData)
@@ -30,7 +30,7 @@ public function track(string $event, array $eventData = null): void
3030
/**
3131
* @param array<string, mixed>|null $identifyData
3232
*/
33-
public function identify(array $identifyData = null): void
33+
public function identify(?array $identifyData = null): void
3434
{
3535
$this->service->push(
3636
new SimpleSegmentIdentify($this->user, $identifyData)

src/SegmentService.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function setGlobalContext(array $globalContext): void
4747
/**
4848
* @param array<string, mixed> $eventData
4949
*/
50-
public function track(string $event, array $eventData = null): void
50+
public function track(string $event, ?array $eventData = null): void
5151
{
5252
$this->push(
5353
new SimpleSegmentEvent($this->globalUser, $event, $eventData)
@@ -57,7 +57,7 @@ public function track(string $event, array $eventData = null): void
5757
/**
5858
* @param array<string, mixed> $identifyData
5959
*/
60-
public function identify(array $identifyData = null): void
60+
public function identify(?array $identifyData = null): void
6161
{
6262
$this->push(
6363
new SimpleSegmentIdentify($this->globalUser, $identifyData)

src/ValueObjects/SegmentPayload.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function __construct(
1919
public readonly SegmentPayloadType $type,
2020
public readonly ?string $event = null,
2121
public readonly array $data = [],
22-
DateTime $timestamp = null
22+
?DateTime $timestamp = null
2323
) {
2424
$this->timestamp = $timestamp ?: new DateTime();
2525
$this->timestamp->setTimezone(new DateTimeZone('UTC'));

0 commit comments

Comments
 (0)