Skip to content

Commit 74806ba

Browse files
committed
Laravel 11 support
1 parent 270e8ba commit 74806ba

30 files changed

+340
-342
lines changed

.github/workflows/tests.yml

+6-4
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ jobs:
88
strategy:
99
fail-fast: false
1010
matrix:
11-
php: [8.1, 8.2]
11+
php: [8.2, 8.3, 8.4]
1212
stability: [prefer-lowest, prefer-stable]
1313

1414
name: PHP ${{ matrix.php }} / ${{ matrix.stability }}
1515

1616
steps:
1717
- name: Checkout code
18-
uses: actions/checkout@v2
18+
uses: actions/checkout@v4
1919

2020
- name: Setup PHP
2121
uses: shivammathur/setup-php@v2
@@ -40,6 +40,8 @@ jobs:
4040
run: vendor/bin/phpunit --colors=always --coverage-clover ./build/logs/clover.xml
4141

4242
- name: Code coverage
43-
uses: codecov/codecov-action@v1
43+
uses: codecov/codecov-action@v3
4444
with:
45-
file: ./build/logs/clover.xml
45+
token: ${{ secrets.CODECOV_TOKEN }}
46+
files: ./build/logs/clover.xml
47+
fail_ci_if_error: true

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Laravel-specific and pure PHP Helper Functions.
1717

1818
| Laravel | Helper Functions |
1919
|---------|-----------------------------------------------------------------------------|
20-
| 11.x | _[Support](https://buymeacoffee.com/dmitry.ivanov)_ |
20+
| 11.x | [11.x](https://github.com/dmitry-ivanov/laravel-helper-functions/tree/11.x) |
2121
| 10.x | [10.x](https://github.com/dmitry-ivanov/laravel-helper-functions/tree/10.x) |
2222
| 9.x | [9.x](https://github.com/dmitry-ivanov/laravel-helper-functions/tree/9.x) |
2323
| 8.x | [8.x](https://github.com/dmitry-ivanov/laravel-helper-functions/tree/8.x) |

composer.json

+10-10
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@
1212
"email": "dmitry.g.ivanov@gmail.com"
1313
}],
1414
"require": {
15-
"php": "^8.1",
15+
"php": "^8.2",
1616
"ext-dom": "*",
1717
"ext-simplexml": "*",
18-
"illuminate/support": "^10.0",
19-
"nesbot/carbon": "^2.67",
20-
"symfony/filesystem": "^6.2",
21-
"symfony/finder": "^6.2",
22-
"symfony/process": "^6.2",
23-
"symfony/var-dumper": "^6.2",
18+
"illuminate/support": "^11.0",
19+
"nesbot/carbon": "^2.72.6|^3.8.4",
20+
"symfony/filesystem": "^7.0.3",
21+
"symfony/finder": "^7.0.3",
22+
"symfony/process": "^7.0.3",
23+
"symfony/var-dumper": "^7.0.3",
2424
"spatie/array-to-xml": "^3.0"
2525
},
2626
"require-dev": {
27-
"phpunit/phpunit": "^10.5",
28-
"mockery/mockery": "^1.5.1",
29-
"illuminated/testing-tools": "^10.0"
27+
"phpunit/phpunit": "^11.3.6",
28+
"mockery/mockery": "^1.6.10",
29+
"illuminated/testing-tools": "^11.0"
3030
},
3131
"autoload": {
3232
"files": [

phpunit.xml.dist

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
3-
backupGlobals="false"
4-
backupStaticProperties="false"
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.3/phpunit.xsd"
53
beStrictAboutTestsThatDoNotTestAnything="false"
64
beStrictAboutOutputDuringTests="true"
75
bootstrap="vendor/autoload.php"
8-
cacheDirectory=".phpunit.cache"
96
colors="true"
10-
processIsolation="false"
11-
stopOnError="false"
12-
stopOnFailure="false"
7+
displayDetailsOnPhpunitDeprecations="true"
8+
displayDetailsOnTestsThatTriggerErrors="true"
9+
displayDetailsOnTestsThatTriggerNotices="true"
10+
displayDetailsOnTestsThatTriggerWarnings="true"
1311
>
1412
<testsuites>
1513
<testsuite name="Laravel Helper Functions Test Suite">
16-
<directory suffix="Test.php">./tests</directory>
14+
<directory>./tests</directory>
1715
</testsuite>
1816
</testsuites>
1917

2018
<source>
2119
<include>
22-
<directory suffix=".php">./src</directory>
20+
<directory>./src</directory>
2321
</include>
22+
2423
<exclude>
2524
<file>./src/autoload.php</file>
2625
</exclude>

tests/Helpers/Artisan/CommandTest.php

+21-39
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
namespace Illuminated\Helpers\Artisan;
44

55
use Illuminated\Helpers\Tests\TestCase;
6+
use PHPUnit\Framework\Attributes\PreserveGlobalState;
7+
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
8+
use PHPUnit\Framework\Attributes\Test;
69

710
class CommandTest extends TestCase
811
{
@@ -17,34 +20,30 @@ protected function setUp(): void
1720
$phpBinaryMock->expects('find')->andReturn('php');
1821
}
1922

20-
/** @test */
21-
public function only_one_constructor_argument_is_required()
23+
#[Test]
24+
public function only_one_constructor_argument_is_required(): void
2225
{
2326
$command = new BackgroundCommand('test');
2427
$this->assertInstanceOf(BackgroundCommand::class, $command);
2528
}
2629

27-
/** @test */
28-
public function it_has_static_constructor_named_factory()
30+
#[Test]
31+
public function it_has_static_constructor_named_factory(): void
2932
{
30-
$command = BackgroundCommand::factory('test');
33+
$command = BackgroundCommand::factory('test'); /** @noinspection UnnecessaryAssertionInspection */
3134
$this->assertInstanceOf(BackgroundCommand::class, $command);
3235
}
3336

34-
/**
35-
* @test
36-
* @runInSeparateProcess
37-
* @preserveGlobalState disabled
38-
*/
39-
public function it_can_run_command_in_background()
37+
#[Test] #[RunInSeparateProcess] #[PreserveGlobalState(false)]
38+
public function it_can_run_command_in_background(): void
4039
{
4140
$this->expectsExecWith('(php artisan test:command) > /dev/null 2>&1 &');
4241

4342
BackgroundCommand::factory('test:command')->run();
4443
}
4544

46-
/** @test */
47-
public function which_also_works_for_windows()
45+
#[Test]
46+
public function which_also_works_for_windows(): void
4847
{
4948
require_once 'mocks.php';
5049

@@ -54,48 +53,32 @@ public function which_also_works_for_windows()
5453
BackgroundCommand::factory('test:command')->run();
5554
}
5655

57-
/**
58-
* @test
59-
* @runInSeparateProcess
60-
* @preserveGlobalState disabled
61-
*/
62-
public function run_in_background_supports_the_before_command()
56+
#[Test] #[RunInSeparateProcess] #[PreserveGlobalState(false)]
57+
public function run_in_background_supports_the_before_command(): void
6358
{
6459
$this->expectsExecWith('(before command && php artisan test:command) > /dev/null 2>&1 &');
6560

6661
BackgroundCommand::factory('test:command', 'before command')->run();
6762
}
6863

69-
/**
70-
* @test
71-
* @runInSeparateProcess
72-
* @preserveGlobalState disabled
73-
*/
74-
public function run_in_background_supports_the_after_command()
64+
#[Test] #[RunInSeparateProcess] #[PreserveGlobalState(false)]
65+
public function run_in_background_supports_the_after_command(): void
7566
{
7667
$this->expectsExecWith('(php artisan test:command && after command) > /dev/null 2>&1 &');
7768

7869
BackgroundCommand::factory('test:command', '', 'after command')->run();
7970
}
8071

81-
/**
82-
* @test
83-
* @runInSeparateProcess
84-
* @preserveGlobalState disabled
85-
*/
86-
public function run_in_background_supports_the_before_and_after_commands_together()
72+
#[Test] #[RunInSeparateProcess] #[PreserveGlobalState(false)]
73+
public function run_in_background_supports_the_before_and_after_commands_together(): void
8774
{
8875
$this->expectsExecWith('(before && php artisan test:command && after) > /dev/null 2>&1 &');
8976

9077
BackgroundCommand::factory('test:command', 'before', 'after')->run();
9178
}
9279

93-
/**
94-
* @test
95-
* @runInSeparateProcess
96-
* @preserveGlobalState disabled
97-
*/
98-
public function it_supports_overriding_of_artisan_binary_through_constant()
80+
#[Test] #[RunInSeparateProcess] #[PreserveGlobalState(false)]
81+
public function it_supports_overriding_of_artisan_binary_through_constant(): void
9982
{
10083
$this->expectsExecWith('(before && php custom-artisan test:command && after) > /dev/null 2>&1 &');
10184

@@ -107,11 +90,10 @@ public function it_supports_overriding_of_artisan_binary_through_constant()
10790
if (!function_exists(__NAMESPACE__ . '\exec')) {
10891
/**
10992
* Mock for the `exec` function.
110-
*
111-
* @noinspection PhpUndefinedMethodInspection
11293
*/
11394
function exec(string $command): mixed
11495
{
96+
/** @noinspection PhpUndefinedMethodInspection */
11597
return TestCase::$functions->exec($command);
11698
}
11799
}

tests/Helpers/Artisan/mocks.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@
77
if (!function_exists(__NAMESPACE__ . '\php_uname')) {
88
/**
99
* Mock for the `php_uname` function.
10-
*
11-
* @noinspection PhpUndefinedMethodInspection
1210
*/
1311
function php_uname(): mixed
1412
{
13+
/** @noinspection PhpUndefinedMethodInspection */
1514
return TestCase::$functions->php_uname();
1615
}
1716
}

tests/array/ArrayExceptValueTest.php

+25-24
Original file line numberDiff line numberDiff line change
@@ -3,89 +3,90 @@
33
namespace Illuminated\Helpers\Tests\array;
44

55
use Illuminated\Helpers\Tests\TestCase;
6+
use PHPUnit\Framework\Attributes\Test;
67

78
class ArrayExceptValueTest extends TestCase
89
{
9-
/** @test */
10-
public function it_returns_array_itself_after_excluding_not_existing_value()
10+
#[Test]
11+
public function it_returns_array_itself_after_excluding_not_existing_value(): void
1112
{
1213
$this->assertEquals([], array_except_value([], null));
1314
$this->assertEquals([], array_except_value([], 'foo'));
1415
$this->assertEquals(['foo', 'bar', 'baz'], array_except_value(['foo', 'bar', 'baz'], 'bax'));
1516
}
1617

17-
/** @test */
18-
public function it_preserves_keys_after_excluding_value()
18+
#[Test]
19+
public function it_preserves_keys_after_excluding_value(): void
1920
{
2021
$this->assertEquals(
2122
[0 => 'foo', 2 => 'baz'],
2223
array_except_value(['foo', 'bar', 'baz'], 'bar')
2324
);
2425
}
2526

26-
/** @test */
27-
public function it_excludes_all_occurrences_of_the_value()
27+
#[Test]
28+
public function it_excludes_all_occurrences_of_the_value(): void
2829
{
2930
$this->assertEquals(
3031
[0 => 'foo', 4 => 'bar'],
3132
array_except_value(['foo', 'baz', 'baz', 'baz', 'bar'], 'baz')
3233
);
3334
}
3435

35-
/** @test */
36-
public function it_can_exclude_null_value()
36+
#[Test]
37+
public function it_can_exclude_null_value(): void
3738
{
3839
$this->assertEquals(['foo', 'bar', 'baz'], array_except_value(['foo', 'bar', 'baz', null], null));
3940
}
4041

41-
/** @test */
42-
public function it_can_exclude_boolean_true_value()
42+
#[Test]
43+
public function it_can_exclude_boolean_true_value(): void
4344
{
4445
$this->assertEquals(['foo', 'bar', 'baz'], array_except_value(['foo', 'bar', 'baz', true, true], true));
4546
}
4647

47-
/** @test */
48-
public function it_can_exclude_boolean_false_value()
48+
#[Test]
49+
public function it_can_exclude_boolean_false_value(): void
4950
{
5051
$this->assertEquals(
5152
['foo', 'bar', 'baz', 5 => null],
5253
array_except_value(['foo', 'bar', 'baz', false, false, null], false)
5354
);
5455
}
5556

56-
/** @test */
57-
public function it_can_exclude_integer_value()
57+
#[Test]
58+
public function it_can_exclude_integer_value(): void
5859
{
5960
$this->assertEquals(
6061
[0 => 23, 2 => 14, 3 => 11],
6162
array_except_value([23, 17, 14, 11], 17)
6263
);
6364
}
6465

65-
/** @test */
66-
public function it_can_exclude_float_value()
66+
#[Test]
67+
public function it_can_exclude_float_value(): void
6768
{
6869
$this->assertEquals(
6970
[0 => 23.3, 1 => 17.2, 3 => 11.1],
7071
array_except_value([23.3, 17.2, 14.5, 11.1], 14.5)
7172
);
7273
}
7374

74-
/** @test */
75-
public function it_can_exclude_string_value()
75+
#[Test]
76+
public function it_can_exclude_string_value(): void
7677
{
7778
$this->assertEquals(['foo', 'bar'], array_except_value(['foo', 'bar', 'baz'], 'baz'));
7879
}
7980

80-
/** @test */
81-
public function it_can_exclude_multiple_different_values()
81+
#[Test]
82+
public function it_can_exclude_multiple_different_values(): void
8283
{
8384
$array = ['foo', 'bar', 'baz', 'bax'];
8485
$this->assertEquals([1 => 'bar', 2 => 'baz'], array_except_value($array, ['foo', 'bax']));
8586
}
8687

87-
/** @test */
88-
public function it_works_with_associative_array_and_single_value()
88+
#[Test]
89+
public function it_works_with_associative_array_and_single_value(): void
8990
{
9091
$array = [
9192
'foo' => 'bar',
@@ -95,8 +96,8 @@ public function it_works_with_associative_array_and_single_value()
9596
$this->assertEquals(['foo' => 'bar', 'foz' => 'faz'], array_except_value($array, 'bax'));
9697
}
9798

98-
/** @test */
99-
public function it_works_with_associative_array_and_multiple_values()
99+
#[Test]
100+
public function it_works_with_associative_array_and_multiple_values(): void
100101
{
101102
$array = [
102103
'foo' => 'bar',

0 commit comments

Comments
 (0)