Skip to content

Commit d1eb5f5

Browse files
committed
✨ Laravel 12 support
1 parent d50cd66 commit d1eb5f5

11 files changed

+84
-62
lines changed

.phpunit.result.cache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":1,"defects":{"HighSolutions\\LaravelEnvironments\\Test\\CopyCommandTest::not_copy_not_existing_environment":6,"HighSolutions\\LaravelEnvironments\\Test\\RemoveCommandTest::remove_existing_environment":4,"HighSolutions\\LaravelEnvironments\\Test\\RemoveCommandTest::not_remove_not_existing_environment":4},"times":{"HighSolutions\\LaravelEnvironments\\Test\\CopyCommandTest::copy_existing_environment":0.668,"HighSolutions\\LaravelEnvironments\\Test\\CopyCommandTest::not_copy_not_existing_environment":0.044,"HighSolutions\\LaravelEnvironments\\Test\\CopyCommandTest::not_copy_when_has_to_overwrite_not_intended":0.067,"HighSolutions\\LaravelEnvironments\\Test\\CopyCommandTest::copy_when_has_to_overwrite_when_intended":0.094,"HighSolutions\\LaravelEnvironments\\Test\\CopyCommandTest::copy_environment_with_nested_files":0.128,"HighSolutions\\LaravelEnvironments\\Test\\CreateCommandTest::create_new_environment":0.054,"HighSolutions\\LaravelEnvironments\\Test\\CreateCommandTest::create_two_environments":0.079,"HighSolutions\\LaravelEnvironments\\Test\\CreateCommandTest::not_overwrite_existing_environment":0.062,"HighSolutions\\LaravelEnvironments\\Test\\CreateCommandTest::overwrite_existing_environment_when_intend_to":0.059,"HighSolutions\\LaravelEnvironments\\Test\\CreateCommandTest::overwrite_existing_environment_when_intend_to_but_not_delete_stored_filed_before":0.051,"HighSolutions\\LaravelEnvironments\\Test\\CreateCommandTest::created_environment_contains_copied_file":0.053,"HighSolutions\\LaravelEnvironments\\Test\\CreateCommandTest::created_environment_without_overwriting_contains_old_version_of_file":0.066,"HighSolutions\\LaravelEnvironments\\Test\\CreateCommandTest::created_environment_with_overwriting_contains_new_version_of_file":0.057,"HighSolutions\\LaravelEnvironments\\Test\\CreateCommandTest::created_environment_contains_copied_files":0.08,"HighSolutions\\LaravelEnvironments\\Test\\ListCommandTest::list_existing_environment":0.06,"HighSolutions\\LaravelEnvironments\\Test\\ListCommandTest::list_existing_many_environments":0.053,"HighSolutions\\LaravelEnvironments\\Test\\MakeCommandTest::create_new_environment":0.045,"HighSolutions\\LaravelEnvironments\\Test\\MakeCommandTest::overwrite_existing_environment_by_default":0.142,"HighSolutions\\LaravelEnvironments\\Test\\RemoveCommandTest::remove_existing_environment":0.091,"HighSolutions\\LaravelEnvironments\\Test\\RemoveCommandTest::not_remove_not_existing_environment":0.075,"HighSolutions\\LaravelEnvironments\\Test\\SetCommandTest::set_empty_environment":0.114,"HighSolutions\\LaravelEnvironments\\Test\\SetCommandTest::set_environment_with_one_file":0.115,"HighSolutions\\LaravelEnvironments\\Test\\SetCommandTest::set_environment_with_multiple_files":0.167,"HighSolutions\\LaravelEnvironments\\Test\\SetCommandTest::sequentional_environment_activation":0.138,"HighSolutions\\LaravelEnvironments\\Test\\SetCommandTest::set_env_without_one_of_files_and_delete_this_missing_file":0.106,"HighSolutions\\LaravelEnvironments\\Test\\SetCommandTest::set_env_without_one_of_files_and_not_delete_this_missing_file_because_of_config":0.089}}
1+
{"version":1,"defects":{"HighSolutions\\LaravelEnvironments\\Test\\CopyCommandTest::not_copy_not_existing_environment":5,"HighSolutions\\LaravelEnvironments\\Test\\RemoveCommandTest::remove_existing_environment":7,"HighSolutions\\LaravelEnvironments\\Test\\RemoveCommandTest::not_remove_not_existing_environment":5,"HighSolutions\\LaravelEnvironments\\Test\\CopyCommandTest::copy_existing_environment":8,"HighSolutions\\LaravelEnvironments\\Test\\CopyCommandTest::not_copy_when_has_to_overwrite_not_intended":8,"HighSolutions\\LaravelEnvironments\\Test\\CopyCommandTest::copy_when_has_to_overwrite_when_intended":8,"HighSolutions\\LaravelEnvironments\\Test\\CopyCommandTest::copy_environment_with_nested_files":5,"HighSolutions\\LaravelEnvironments\\Test\\CreateCommandTest::create_new_environment":7,"HighSolutions\\LaravelEnvironments\\Test\\CreateCommandTest::create_two_environments":7,"HighSolutions\\LaravelEnvironments\\Test\\CreateCommandTest::not_overwrite_existing_environment":7,"HighSolutions\\LaravelEnvironments\\Test\\CreateCommandTest::overwrite_existing_environment_when_intend_to":7,"HighSolutions\\LaravelEnvironments\\Test\\CreateCommandTest::overwrite_existing_environment_when_intend_to_but_not_delete_stored_filed_before":7,"HighSolutions\\LaravelEnvironments\\Test\\CreateCommandTest::created_environment_contains_copied_file":5,"HighSolutions\\LaravelEnvironments\\Test\\CreateCommandTest::created_environment_without_overwriting_contains_old_version_of_file":5,"HighSolutions\\LaravelEnvironments\\Test\\CreateCommandTest::created_environment_with_overwriting_contains_new_version_of_file":5,"HighSolutions\\LaravelEnvironments\\Test\\CreateCommandTest::created_environment_contains_copied_files":5,"HighSolutions\\LaravelEnvironments\\Test\\ListCommandTest::list_existing_environment":7,"HighSolutions\\LaravelEnvironments\\Test\\ListCommandTest::list_existing_many_environments":7,"HighSolutions\\LaravelEnvironments\\Test\\MakeCommandTest::create_new_environment":7,"HighSolutions\\LaravelEnvironments\\Test\\MakeCommandTest::overwrite_existing_environment_by_default":7,"HighSolutions\\LaravelEnvironments\\Test\\SetCommandTest::set_empty_environment":7,"HighSolutions\\LaravelEnvironments\\Test\\SetCommandTest::set_environment_with_one_file":5,"HighSolutions\\LaravelEnvironments\\Test\\SetCommandTest::set_environment_with_multiple_files":5,"HighSolutions\\LaravelEnvironments\\Test\\SetCommandTest::sequentional_environment_activation":5,"HighSolutions\\LaravelEnvironments\\Test\\SetCommandTest::set_env_without_one_of_files_and_delete_this_missing_file":5,"HighSolutions\\LaravelEnvironments\\Test\\SetCommandTest::set_env_without_one_of_files_and_not_delete_this_missing_file_because_of_config":5},"times":{"HighSolutions\\LaravelEnvironments\\Test\\CopyCommandTest::copy_existing_environment":0.161,"HighSolutions\\LaravelEnvironments\\Test\\CopyCommandTest::not_copy_not_existing_environment":0.003,"HighSolutions\\LaravelEnvironments\\Test\\CopyCommandTest::not_copy_when_has_to_overwrite_not_intended":0.008,"HighSolutions\\LaravelEnvironments\\Test\\CopyCommandTest::copy_when_has_to_overwrite_when_intended":0.01,"HighSolutions\\LaravelEnvironments\\Test\\CopyCommandTest::copy_environment_with_nested_files":0.019,"HighSolutions\\LaravelEnvironments\\Test\\CreateCommandTest::create_new_environment":0.004,"HighSolutions\\LaravelEnvironments\\Test\\CreateCommandTest::create_two_environments":0.007,"HighSolutions\\LaravelEnvironments\\Test\\CreateCommandTest::not_overwrite_existing_environment":0.007,"HighSolutions\\LaravelEnvironments\\Test\\CreateCommandTest::overwrite_existing_environment_when_intend_to":0.008,"HighSolutions\\LaravelEnvironments\\Test\\CreateCommandTest::overwrite_existing_environment_when_intend_to_but_not_delete_stored_filed_before":0.007,"HighSolutions\\LaravelEnvironments\\Test\\CreateCommandTest::created_environment_contains_copied_file":0.008,"HighSolutions\\LaravelEnvironments\\Test\\CreateCommandTest::created_environment_without_overwriting_contains_old_version_of_file":0.009,"HighSolutions\\LaravelEnvironments\\Test\\CreateCommandTest::created_environment_with_overwriting_contains_new_version_of_file":0.012,"HighSolutions\\LaravelEnvironments\\Test\\CreateCommandTest::created_environment_contains_copied_files":0.014,"HighSolutions\\LaravelEnvironments\\Test\\ListCommandTest::list_existing_environment":0.007,"HighSolutions\\LaravelEnvironments\\Test\\ListCommandTest::list_existing_many_environments":0.007,"HighSolutions\\LaravelEnvironments\\Test\\MakeCommandTest::create_new_environment":0.004,"HighSolutions\\LaravelEnvironments\\Test\\MakeCommandTest::overwrite_existing_environment_by_default":0.007,"HighSolutions\\LaravelEnvironments\\Test\\RemoveCommandTest::remove_existing_environment":0.005,"HighSolutions\\LaravelEnvironments\\Test\\RemoveCommandTest::not_remove_not_existing_environment":0.003,"HighSolutions\\LaravelEnvironments\\Test\\SetCommandTest::set_empty_environment":0.005,"HighSolutions\\LaravelEnvironments\\Test\\SetCommandTest::set_environment_with_one_file":0.011,"HighSolutions\\LaravelEnvironments\\Test\\SetCommandTest::set_environment_with_multiple_files":0.02,"HighSolutions\\LaravelEnvironments\\Test\\SetCommandTest::sequentional_environment_activation":0.018,"HighSolutions\\LaravelEnvironments\\Test\\SetCommandTest::set_env_without_one_of_files_and_delete_this_missing_file":0.021,"HighSolutions\\LaravelEnvironments\\Test\\SetCommandTest::set_env_without_one_of_files_and_not_delete_this_missing_file_because_of_config":0.013}}

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ vendor/bin/phpunit
132132
Changelog
133133
---------
134134

135+
3.6.0
136+
* Laravel 12.0 support
137+
135138
3.5.0
136139
* Laravel 11.0 support
137140

composer.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
],
1111
"license": "MIT",
1212
"require": {
13-
"php": ">=5.4.0|>=8.0.2",
14-
"illuminate/console": "5.*|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0",
15-
"illuminate/support": "5.*|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0"
13+
"php": "^5.4|^7.3|^8.0.2",
14+
"illuminate/console": "5.*|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0",
15+
"illuminate/support": "5.*|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0"
1616
},
1717
"require-dev": {
18-
"phpunit/phpunit": "6.*|7.*|8.*|9.*|10.*|11.*",
18+
"phpunit/phpunit": "6.*|7.*|8.*|9.*|10.*|11.*|12.*",
1919
"orchestra/testbench" : "3.*|4.*|5.*|6.*|7.*|8.*|9.*|10.*",
2020
"mockery/mockery": "^1.0"
2121
},
@@ -52,7 +52,8 @@
5252
"Laravel 8.0",
5353
"Laravel 9.0",
5454
"Laravel 10.0",
55-
"Laravel 11.0"
55+
"Laravel 11.0",
56+
"Laravel 12.0"
5657
],
5758
"laravel": {
5859
"providers": [

phpunit.xml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit backupGlobals="false"
3-
backupStaticAttributes="false"
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
44
bootstrap="vendor/autoload.php"
55
colors="true"
6-
convertErrorsToExceptions="true"
7-
convertNoticesToExceptions="true"
8-
convertWarningsToExceptions="true"
9-
processIsolation="false"
10-
stopOnFailure="false"
116
>
127
<testsuites>
138
<testsuite name="Package Test Suite">
149
<directory suffix=".php">./tests/</directory>
10+
<exclude>./tests/TestCase.php</exclude>
1511
</testsuite>
1612
</testsuites>
1713
</phpunit>

tests/TestCase.php

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
use Orchestra\Testbench\TestCase as OrchestraTestCase;
77
use HighSolutions\LaravelEnvironments\EnvironmentServiceProvider;
88

9-
abstract class TestCase extends OrchestraTestCase
9+
class TestCase extends OrchestraTestCase
1010
{
11+
1112
protected function getPackageProviders($app)
1213
{
1314
return [
@@ -48,18 +49,32 @@ protected function basePath()
4849
public function setUp(): void
4950
{
5051
parent::setUp();
51-
52-
File::cleanDirectory(config('environments.path'));
52+
53+
$tempDir = $this->getTempDirectory();
54+
if (!File::exists($tempDir)) {
55+
File::makeDirectory($tempDir, 0755, true);
56+
}
57+
File::cleanDirectory($tempDir);
5358
}
5459

5560
public function tearDown(): void
5661
{
57-
File::cleanDirectory(config('environments.path'));
62+
if (File::exists($this->getTempDirectory())) {
63+
File::cleanDirectory($this->getTempDirectory());
64+
}
65+
66+
parent::tearDown();
5867
}
5968

60-
public static function assertDirectoryExists($directoryName, $message = ''):void
69+
public static function assertDoesDirectoryExist($directoryName, $message = ''): void
6170
{
62-
$temp = (new static)->getTempDirectory($directoryName);
71+
$instance = new static('dummy'); // Pass required argument to constructor
72+
$temp = $instance->getTempDirectory($directoryName);
73+
74+
if (!File::exists($temp)) {
75+
File::makeDirectory($temp, 0755, true);
76+
}
77+
6378
static::assertTrue(File::isDirectory($temp), $message);
6479
}
6580

tests/unit/CopyCommandTest.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace HighSolutions\LaravelEnvironments\Test;
44

55
use Illuminate\Support\Facades\File;
6+
use PHPUnit\Framework\Attributes\Test;
67

78
class CopyCommandTest extends TestCase
89
{
@@ -16,24 +17,24 @@ protected function executeCopy($params)
1617
return $this->artisan('env:copy', $params);
1718
}
1819

19-
/** @test */
20+
#[Test]
2021
public function copy_existing_environment()
2122
{
2223
$this->executeCreate([
2324
'name' => 'local',
2425
]);
2526

26-
$this->assertDirectoryExists('local');
27+
$this->assertDoesDirectoryExist('local');
2728

2829
$this->executeCopy([
2930
'old' => 'local',
3031
'new' => 'production',
3132
]);
3233

33-
$this->assertDirectoryExists('production');
34+
$this->assertDoesDirectoryExist('production');
3435
}
3536

36-
/** @test */
37+
#[Test]
3738
public function not_copy_not_existing_environment()
3839
{
3940
$this->assertDirectoryDoesNotExist('local');
@@ -46,7 +47,7 @@ public function not_copy_not_existing_environment()
4647
$this->assertDirectoryDoesNotExist('production');
4748
}
4849

49-
/** @test */
50+
#[Test]
5051
public function not_copy_when_has_to_overwrite_not_intended()
5152
{
5253
$this->executeCreate([
@@ -66,12 +67,12 @@ public function not_copy_when_has_to_overwrite_not_intended()
6667
'--overwrite' => false,
6768
]);
6869

69-
$this->assertDirectoryExists('staging');
70+
$this->assertDoesDirectoryExist('staging');
7071

7172
$this->assertTrue(File::exists($testFile));
7273
}
7374

74-
/** @test */
75+
#[Test]
7576
public function copy_when_has_to_overwrite_when_intended()
7677
{
7778
$this->executeCreate([
@@ -91,12 +92,12 @@ public function copy_when_has_to_overwrite_when_intended()
9192
'--overwrite' => true,
9293
]);
9394

94-
$this->assertDirectoryExists('staging');
95+
$this->assertDoesDirectoryExist('staging');
9596

9697
$this->assertFalse(File::exists($testFile));
9798
}
9899

99-
/** @test **/
100+
#[Test]
100101
public function copy_environment_with_nested_files()
101102
{
102103
$this->executeCreate([

tests/unit/CreateCommandTest.php

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace HighSolutions\LaravelEnvironments\Test;
44

55
use Illuminate\Support\Facades\File;
6+
use PHPUnit\Framework\Attributes\Test;
67

78
class CreateCommandTest extends TestCase
89
{
@@ -11,18 +12,18 @@ protected function executeCreate($params)
1112
return $this->artisan('env:create', $params);
1213
}
1314

14-
/** @test */
15+
#[Test]
1516
public function create_new_environment()
1617
{
1718
$code = $this->executeCreate([
1819
'name' => 'local',
1920
]);
2021

2122
$this->assertEquals(0, $code);
22-
$this->assertDirectoryExists('local');
23+
$this->assertDoesDirectoryExist('local');
2324
}
2425

25-
/** @test */
26+
#[Test]
2627
public function create_two_environments()
2728
{
2829
$this->executeCreate([
@@ -33,11 +34,11 @@ public function create_two_environments()
3334
'name' => 'staging',
3435
]);
3536

36-
$this->assertDirectoryExists('local');
37-
$this->assertDirectoryExists('staging');
37+
$this->assertDoesDirectoryExist('local');
38+
$this->assertDoesDirectoryExist('staging');
3839
}
3940

40-
/** @test */
41+
#[Test]
4142
public function not_overwrite_existing_environment()
4243
{
4344
$this->executeCreate([
@@ -47,7 +48,7 @@ public function not_overwrite_existing_environment()
4748
$testFile = $this->getTempDirectory('local').'testfile.php';
4849
File::put($testFile, 'test');
4950

50-
$this->assertDirectoryExists('local');
51+
$this->assertDoesDirectoryExist('local');
5152

5253
$code = $this->executeCreate([
5354
'name' => 'local',
@@ -57,7 +58,7 @@ public function not_overwrite_existing_environment()
5758
$this->assertTrue(File::exists($testFile));
5859
}
5960

60-
/** @test */
61+
#[Test]
6162
public function overwrite_existing_environment_when_intend_to()
6263
{
6364
config([
@@ -71,7 +72,7 @@ public function overwrite_existing_environment_when_intend_to()
7172
$testFile = $this->getTempDirectory('local').'testfile.php';
7273
File::put($testFile, 'test');
7374

74-
$this->assertDirectoryExists('local');
75+
$this->assertDoesDirectoryExist('local');
7576

7677
$code = $this->executeCreate([
7778
'name' => 'local',
@@ -81,7 +82,7 @@ public function overwrite_existing_environment_when_intend_to()
8182
$this->assertFalse(File::exists($testFile));
8283
}
8384

84-
/** @test */
85+
#[Test]
8586
public function overwrite_existing_environment_when_intend_to_but_not_delete_stored_filed_before()
8687
{
8788
config([
@@ -95,7 +96,7 @@ public function overwrite_existing_environment_when_intend_to_but_not_delete_sto
9596
$testFile = $this->getTempDirectory('local').'testfile.php';
9697
File::put($testFile, 'test');
9798

98-
$this->assertDirectoryExists('local');
99+
$this->assertDoesDirectoryExist('local');
99100

100101
$code = $this->executeCreate([
101102
'name' => 'local',
@@ -105,7 +106,7 @@ public function overwrite_existing_environment_when_intend_to_but_not_delete_sto
105106
$this->assertTrue(File::exists($testFile));
106107
}
107108

108-
/** @test **/
109+
#[Test]
109110
public function created_environment_contains_copied_file()
110111
{
111112
config([
@@ -124,7 +125,7 @@ public function created_environment_contains_copied_file()
124125
});
125126
}
126127

127-
/** @test **/
128+
#[Test]
128129
public function created_environment_without_overwriting_contains_old_version_of_file()
129130
{
130131
config([
@@ -155,7 +156,7 @@ public function created_environment_without_overwriting_contains_old_version_of_
155156
});
156157
}
157158

158-
/** @test **/
159+
#[Test]
159160
public function created_environment_with_overwriting_contains_new_version_of_file()
160161
{
161162
config([
@@ -186,7 +187,7 @@ public function created_environment_with_overwriting_contains_new_version_of_fil
186187
});
187188
}
188189

189-
/** @test **/
190+
#[Test]
190191
public function created_environment_contains_copied_files()
191192
{
192193
config([

tests/unit/ListCommandTest.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace HighSolutions\LaravelEnvironments\Test;
44

55
use HighSolutions\LaravelEnvironments\Contracts\EnvironmentManagerContract;
6+
use PHPUnit\Framework\Attributes\Test;
67

78
class ListCommandTest extends TestCase
89
{
@@ -16,21 +17,21 @@ protected function getList()
1617
return resolve(EnvironmentManagerContract::class)->getList();
1718
}
1819

19-
/** @test */
20+
#[Test]
2021
public function list_existing_environment()
2122
{
2223
$this->executeCreate([
2324
'name' => 'local',
2425
]);
2526

26-
$this->assertDirectoryExists('local');
27+
$this->assertDoesDirectoryExist('local');
2728

2829
$list = $this->getList();
2930

3031
$this->assertNestedArrayContains('local', $list);
3132
}
3233

33-
/** @test */
34+
#[Test]
3435
public function list_existing_many_environments()
3536
{
3637
$this->executeCreate([
@@ -41,8 +42,8 @@ public function list_existing_many_environments()
4142
'name' => 'master',
4243
]);
4344

44-
$this->assertDirectoryExists('local');
45-
$this->assertDirectoryExists('master');
45+
$this->assertDoesDirectoryExist('local');
46+
$this->assertDoesDirectoryExist('master');
4647

4748
$list = $this->getList();
4849

0 commit comments

Comments
 (0)