Skip to content

Commit

Permalink
Merge pull request #37 from markwalet/laravel-upgrade
Browse files Browse the repository at this point in the history
Laravel upgrade
  • Loading branch information
markwalet authored Jan 31, 2025
2 parents e80947e + c8a0b0d commit b4b2561
Show file tree
Hide file tree
Showing 14 changed files with 102 additions and 85 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,20 @@ jobs:
fail-fast: false
matrix:
php: [ 8.1, 8.2, 8.3, 8.4 ]
illuminate: [^10.0, ^11.0]
illuminate: [^10.0, ^11.0, ^12.0]
stability: [prefer-lowest, prefer-stable]
include:
- illuminate: ^10.0
testbench: 8.*
- illuminate: ^11.0
testbench: 9.*
- illuminate: ^12.0
testbench: 10.*
exclude:
- php: 8.1
illuminate: ^11.0
- php: 8.1
illuminate: ^12.0

name: P${{ matrix.php }} - I${{ matrix.illuminate }} - ${{ matrix.stability }}

Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## [Unreleased](https://github.com/markwalet/laravel-git-state/compare/v1.9.1...master)

### Added
- Added support for Laravel 12

## [v1.9.1 (2024-11-19)](https://github.com/markwalet/laravel-git-state/compare/v1.9.0...v1.9.1)

Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
],
"require": {
"php": "^8.1",
"laravel/framework": "^10.0|^11.0",
"laravel/framework": "^10.0|^11.0|^12.0",
"phpoption/phpoption": ">=1.8",
"webmozart/assert": "^1.10"
},
"require-dev": {
"phpunit/phpunit": "^10.5",
"orchestra/testbench": "8.*|9.*"
"phpunit/phpunit": "^10.5|^11.0",
"orchestra/testbench": "8.*|9.*|10.*"
},
"autoload": {
"psr-4": {
Expand All @@ -37,7 +37,7 @@
"config": {
"sort-packages": true
},
"minimum-stability": "beta",
"minimum-stability": "dev",
"extra": {
"laravel": {
"providers": [
Expand Down
25 changes: 13 additions & 12 deletions tests/Drivers/DriverTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use MarkWalet\GitState\Drivers\GitDriver;
use MarkWalet\GitState\Exceptions\RuntimeException;
use PHPUnit\Framework\Attributes\Test;

trait DriverTests
{
Expand All @@ -15,8 +16,8 @@ trait DriverTests
*/
abstract protected function driver(string $folder): GitDriver;

/** @test */
public function it_can_get_the_latest_branch_of_a_git_repository()
#[Test]
public function it_can_get_the_latest_branch_of_a_git_repository(): void
{
$git = $this->driver('on-master');

Expand All @@ -25,8 +26,8 @@ public function it_can_get_the_latest_branch_of_a_git_repository()
$this->assertEquals('master', $branch);
}

/** @test */
public function it_does_not_escape_forward_slashes_in_the_branch_name()
#[Test]
public function it_does_not_escape_forward_slashes_in_the_branch_name(): void
{
$git = $this->driver('on-nested-feature');

Expand All @@ -35,8 +36,8 @@ public function it_does_not_escape_forward_slashes_in_the_branch_name()
$this->assertEquals('feature/issue-12', $branch);
}

/** @test */
public function it_throws_an_exception_when_the_head_file_is_not_found()
#[Test]
public function it_throws_an_exception_when_the_head_file_is_not_found(): void
{
$git = $this->driver('no-head');

Expand All @@ -45,8 +46,8 @@ public function it_throws_an_exception_when_the_head_file_is_not_found()
$git->currentBranch();
}

/** @test */
public function it_can_get_the_latest_short_commit_hash_of_a_git_repository()
#[Test]
public function it_can_get_the_latest_short_commit_hash_of_a_git_repository(): void
{
$git = $this->driver('with-commits');

Expand All @@ -55,8 +56,8 @@ public function it_can_get_the_latest_short_commit_hash_of_a_git_repository()
$this->assertEquals('202131f', $commit);
}

/** @test */
public function it_can_get_the_latest_long_commit_hash_of_a_git_repository()
#[Test]
public function it_can_get_the_latest_long_commit_hash_of_a_git_repository(): void
{
$git = $this->driver('with-commits');

Expand All @@ -65,8 +66,8 @@ public function it_can_get_the_latest_long_commit_hash_of_a_git_repository()
$this->assertEquals('202131f0ba24d03d75667ce586be1c1ce3983ce8', $commit);
}

/** @test */
public function it_throws_an_exception_when_the_head_file_is_not_found_for_the_latest_commit()
#[Test]
public function it_throws_an_exception_when_the_head_file_is_not_found_for_the_latest_commit(): void
{
$this->expectException(RuntimeException::class);

Expand Down
13 changes: 7 additions & 6 deletions tests/Drivers/ExecGitDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use MarkWalet\GitState\Drivers\ExecGitDriver;
use MarkWalet\GitState\Drivers\GitDriver;
use MarkWalet\GitState\Exceptions\NoGitRepositoryException;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;

class ExecGitDriverTest extends TestCase
Expand All @@ -20,16 +21,16 @@ protected function driver(string $folder): GitDriver
return new ExecGitDriver(['path' => __DIR__.'/../test-data/'.$folder]);
}

/** @test */
public function it_throws_an_exception_when_the_path_configuration_is_not_given()
#[Test]
public function it_throws_an_exception_when_the_path_configuration_is_not_given(): void
{
$this->expectException(InvalidArgumentException::class);

new ExecGitDriver([]);
}

/** @test */
public function it_throws_an_exception_while_fetching_the_current_branch_name_when_the_folder_is_not_found()
#[Test]
public function it_throws_an_exception_while_fetching_the_current_branch_name_when_the_folder_is_not_found(): void
{
$this->expectException(NoGitRepositoryException::class);

Expand All @@ -38,8 +39,8 @@ public function it_throws_an_exception_while_fetching_the_current_branch_name_wh
$driver->currentBranch();
}

/** @test */
public function it_throws_an_exception_while_fetching_the_commit_hash_when_the_folder_is_not_found()
#[Test]
public function it_throws_an_exception_while_fetching_the_commit_hash_when_the_folder_is_not_found(): void
{
$this->expectException(NoGitRepositoryException::class);

Expand Down
13 changes: 7 additions & 6 deletions tests/Drivers/FakeGitDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
namespace MarkWalet\GitState\Tests\Drivers;

use MarkWalet\GitState\Drivers\FakeGitDriver;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;

class FakeGitDriverTest extends TestCase
{
/** @test */
public function it_can_set_the_current_branch_from_configuration()
#[Test]
public function it_can_set_the_current_branch_from_configuration(): void
{
$git = new FakeGitDriver(['branch' => 'feature-12']);

Expand All @@ -17,8 +18,8 @@ public function it_can_set_the_current_branch_from_configuration()
$this->assertEquals('feature-12', $branch);
}

/** @test */
public function the_current_branch_defaults_to_master()
#[Test]
public function the_current_branch_defaults_to_master(): void
{
$git = new FakeGitDriver;

Expand All @@ -27,8 +28,8 @@ public function the_current_branch_defaults_to_master()
$this->assertEquals('master', $branch);
}

/** @test */
public function it_can_update_the_current_branch()
#[Test]
public function it_can_update_the_current_branch(): void
{
$git = new FakeGitDriver;
$git->updateCurrentBranch('new-feature');
Expand Down
13 changes: 7 additions & 6 deletions tests/Drivers/FileGitDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use MarkWalet\GitState\Drivers\FileGitDriver;
use MarkWalet\GitState\Drivers\GitDriver;
use MarkWalet\GitState\Exceptions\NoGitRepositoryException;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;

class FileGitDriverTest extends TestCase
Expand All @@ -20,16 +21,16 @@ protected function driver(string $folder): GitDriver
return new FileGitDriver(['path' => __DIR__.'/../test-data/'.$folder]);
}

/** @test */
public function it_throws_an_exception_when_the_path_configuration_is_not_given()
#[Test]
public function it_throws_an_exception_when_the_path_configuration_is_not_given(): void
{
$this->expectException(InvalidArgumentException::class);

new FileGitDriver([]);
}

/** @test */
public function it_throws_an_exception_while_fetching_the_current_branch_name_when_the_folder_is_not_found()
#[Test]
public function it_throws_an_exception_while_fetching_the_current_branch_name_when_the_folder_is_not_found(): void
{
$this->expectException(NoGitRepositoryException::class);

Expand All @@ -38,8 +39,8 @@ public function it_throws_an_exception_while_fetching_the_current_branch_name_wh
$driver->currentBranch();
}

/** @test */
public function it_throws_an_exception_while_fetching_the_commit_hash_when_the_folder_is_not_found()
#[Test]
public function it_throws_an_exception_while_fetching_the_commit_hash_when_the_folder_is_not_found(): void
{
$this->expectException(NoGitRepositoryException::class);

Expand Down
3 changes: 2 additions & 1 deletion tests/Exceptions/MissingConfigurationExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
namespace MarkWalet\GitState\Tests\Exceptions;

use MarkWalet\GitState\Exceptions\MissingConfigurationException;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;

class MissingConfigurationExceptionTest extends TestCase
{
/** @test */
#[Test]
public function it_can_create_an_exception_instance(): void
{
$exception = new MissingConfigurationException('config');
Expand Down
3 changes: 2 additions & 1 deletion tests/Exceptions/MissingDriverExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
namespace MarkWalet\GitState\Tests\Exceptions;

use MarkWalet\GitState\Exceptions\MissingDriverException;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;

class MissingDriverExceptionTest extends TestCase
{
/** @test */
#[Test]
public function it_can_create_an_exception_instance(): void
{
$exception = new MissingDriverException('invalid-driver');
Expand Down
3 changes: 2 additions & 1 deletion tests/Exceptions/NoGitRepositoryExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
namespace MarkWalet\GitState\Tests\Exceptions;

use MarkWalet\GitState\Exceptions\NoGitRepositoryException;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;

class NoGitRepositoryExceptionTest extends TestCase
{
/** @test */
#[Test]
public function it_can_create_an_exception_instance(): void
{
$exception = new NoGitRepositoryException('example-path');
Expand Down
21 changes: 11 additions & 10 deletions tests/GitDriverFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
use MarkWalet\GitState\Drivers\FileGitDriver;
use MarkWalet\GitState\Exceptions\MissingDriverException;
use MarkWalet\GitState\GitDriverFactory;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;

class GitDriverFactoryTest extends TestCase
{
/** @test */
public function it_can_create_a_fake_driver()
#[Test]
public function it_can_create_a_fake_driver(): void
{
$factory = new GitDriverFactory();

Expand All @@ -24,8 +25,8 @@ public function it_can_create_a_fake_driver()
$this->assertInstanceOf(FakeGitDriver::class, $driver);
}

/** @test */
public function it_can_create_an_exec_driver()
#[Test]
public function it_can_create_an_exec_driver(): void
{
$factory = new GitDriverFactory();

Expand All @@ -37,8 +38,8 @@ public function it_can_create_an_exec_driver()
$this->assertInstanceOf(ExecGitDriver::class, $driver);
}

/** @test */
public function it_can_create_a_file_driver()
#[Test]
public function it_can_create_a_file_driver(): void
{
$factory = new GitDriverFactory();

Expand All @@ -50,8 +51,8 @@ public function it_can_create_a_file_driver()
$this->assertInstanceOf(FileGitDriver::class, $driver);
}

/** @test */
public function it_throws_an_exception_when_the_driver_is_not_defined()
#[Test]
public function it_throws_an_exception_when_the_driver_is_not_defined(): void
{
$factory = new GitDriverFactory();

Expand All @@ -60,8 +61,8 @@ public function it_throws_an_exception_when_the_driver_is_not_defined()
$factory->make([]);
}

/** @test */
public function it_throws_an_exception_when_the_driver_does_not_exist()
#[Test]
public function it_throws_an_exception_when_the_driver_does_not_exist(): void
{
$factory = new GitDriverFactory();

Expand Down
Loading

0 comments on commit b4b2561

Please sign in to comment.