Skip to content

Commit

Permalink
Merge pull request #39 from lunarstorm/laravel11-support
Browse files Browse the repository at this point in the history
Adding Laravel 11 support to dependencies and test matrix.
  • Loading branch information
JasperTey authored Mar 11, 2024
2 parents a7e9f71 + 98da7da commit b73a39c
Show file tree
Hide file tree
Showing 17 changed files with 50 additions and 33 deletions.
22 changes: 14 additions & 8 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,22 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest]
php: [8.2, 8.1]
laravel: [9.*, 10.*]
php: [8.3, 8.2, 8.1]
laravel: [11.*, 10.*, 9.*]
stability: [prefer-lowest, prefer-stable]
include:
- laravel: 9.*
testbench: 7.*
carbon: ^2.63
- laravel: 10.*
testbench: 8.*
carbon: ^2.63
- laravel: 11.*
testbench: 9.*
carbon: ^3.0
- laravel: 10.*
testbench: 8.*
carbon: ^2.63
- laravel: 9.*
testbench: 7.*
carbon: ^2.63
exclude:
- laravel: 11.*
php: 8.1

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

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.idea
.phpunit.result.cache
.phpunit.cache
build
composer.lock
coverage
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to `laravel-ddd` will be documented in this file.

## [Unversioned]
### Chore
- Add Laravel 11 support.

## [0.8.1] - 2023-12-05
### Chore
- Update dependencies.
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
}
],
"require": {
"php": "^8.1|^8.2",
"php": "^8.1|^8.2|^8.3",
"spatie/laravel-package-tools": "^1.13.0",
"illuminate/contracts": "^9.0|^10.0"
"illuminate/contracts": "^9.0|^10.0|^11.0"
},
"require-dev": {
"laravel/pint": "^1.0",
"nunomaduro/collision": "^6.0|^7.0",
"nunomaduro/collision": "^6.0|^7.0|^8.1",
"larastan/larastan": "^2.0.1",
"orchestra/testbench": "^7|^8",
"orchestra/testbench": "^7|^8|^9.0",
"pestphp/pest": "^1.22|^2.0",
"pestphp/pest-plugin-laravel": "^1.1|^2.0",
"phpstan/extension-installer": "^1.1",
Expand Down
8 changes: 5 additions & 3 deletions src/Commands/DomainGeneratorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Console\GeneratorCommand;
use Illuminate\Support\Str;
use Lunarstorm\LaravelDDD\Support\Path;
use Symfony\Component\Console\Input\InputArgument;

abstract class DomainGeneratorCommand extends GeneratorCommand
Expand Down Expand Up @@ -57,19 +58,20 @@ protected function getDomain()

protected function getDomainBasePath()
{
return $this->laravel->basePath(config('ddd.paths.domains', 'src/Domains'));
return Path::normalize($this->laravel->basePath(config('ddd.paths.domains', 'src/Domains')));
}

protected function getPath($name)
{
$name = str($name)
$path = str($name)
->replaceFirst($this->rootNamespace(), '')
->replace('\\', '/')
->ltrim('/')
->append('.php')
->prepend($this->getDomainBasePath().DIRECTORY_SEPARATOR)
->toString();

return $this->getDomainBasePath().'/'.$name;
return Path::normalize($path);
}

protected function resolveStubPath($path)
Expand Down
3 changes: 2 additions & 1 deletion src/Commands/MakeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Lunarstorm\LaravelDDD\Commands;

use Lunarstorm\LaravelDDD\Support\Domain;
use Lunarstorm\LaravelDDD\Support\Path;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;

Expand Down Expand Up @@ -74,7 +75,7 @@ protected function getPath($name)
->append('.php')
->toString();

return base_path('database/factories/'.$name);
return Path::normalize(base_path('database/factories/'.$name));
}

protected function getFactoryName()
Expand Down
4 changes: 2 additions & 2 deletions src/Support/Domain.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Domain

public readonly DomainNamespaces $namespace;

public function __construct(string $domain, string $subdomain = null)
public function __construct(string $domain, ?string $subdomain = null)
{
if (is_null($subdomain)) {
// If a subdomain isn't explicitly specified, we
Expand Down Expand Up @@ -62,7 +62,7 @@ protected function getDomainBasePath()
return app()->basePath(config('ddd.paths.domains'));
}

public function path(string $path = null): string
public function path(?string $path = null): string
{
if (is_null($path)) {
return $this->path;
Expand Down
2 changes: 1 addition & 1 deletion src/ValueObjects/DomainNamespaces.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function __construct(
) {
}

public static function from(string $domain, string $subdomain = null): self
public static function from(string $domain, ?string $subdomain = null): self
{
$domainWithSubdomain = str($domain)
->when($subdomain, fn ($domain) => $domain->append("\\{$subdomain}"))
Expand Down
6 changes: 6 additions & 0 deletions tests/Expectations.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
<?php

use Lunarstorm\LaravelDDD\Support\Path;

use function PHPUnit\Framework\assertMatchesRegularExpression;

expect()->extend('toMatchRegularExpression', function ($pattern, string $message = '') {
assertMatchesRegularExpression($pattern, $this->value, $message);

return $this;
});

expect()->extend('toContainFilepath', function ($path) {
return $this->toContain(Path::normalize($path));
});
2 changes: 1 addition & 1 deletion tests/Generator/MakeActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

expect(Artisan::output())->when(
Feature::IncludeFilepathInGeneratorCommandOutput->exists(),
fn ($output) => $output->toContain($relativePath),
fn ($output) => $output->toContainFilepath($relativePath),
);

expect(file_exists($expectedPath))->toBeTrue();
Expand Down
2 changes: 1 addition & 1 deletion tests/Generator/MakeBaseModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

expect(Artisan::output())->when(
Feature::IncludeFilepathInGeneratorCommandOutput->exists(),
fn ($output) => $output->toContain($relativePath),
fn ($output) => $output->toContainFilepath($relativePath),
);

expect(file_exists($expectedPath))->toBeTrue();
Expand Down
2 changes: 1 addition & 1 deletion tests/Generator/MakeBaseViewModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

expect(Artisan::output())->when(
Feature::IncludeFilepathInGeneratorCommandOutput->exists(),
fn ($output) => $output->toContain($relativePath),
fn ($output) => $output->toContainFilepath($relativePath),
);

expect(file_exists($expectedPath))->toBeTrue();
Expand Down
2 changes: 1 addition & 1 deletion tests/Generator/MakeDataTransferObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

expect(Artisan::output())->when(
Feature::IncludeFilepathInGeneratorCommandOutput->exists(),
fn ($output) => $output->toContain($relativePath),
fn ($output) => $output->toContainFilepath($relativePath),
);

expect(file_exists($expectedPath))->toBeTrue();
Expand Down
7 changes: 3 additions & 4 deletions tests/Generator/MakeFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Str;
use Lunarstorm\LaravelDDD\Support\Domain;
use Lunarstorm\LaravelDDD\Support\Path;
use Lunarstorm\LaravelDDD\Tests\Fixtures\Enums\Feature;

it('can generate domain factories', function ($domainPath, $domainRoot, $domain, $subdomain) {
Expand All @@ -23,7 +24,7 @@

$domainFactory = $domain->factory($factoryName);

$expectedFactoryPath = base_path($domainFactory->path);
$expectedFactoryPath = Path::normalize(base_path($domainFactory->path));

if (file_exists($expectedFactoryPath)) {
unlink($expectedFactoryPath);
Expand All @@ -33,11 +34,9 @@

Artisan::call("ddd:factory {$domain->dotName} {$modelName}");

$outputPath = str_replace('\\', '/', $domainFactory->path);

expect(Artisan::output())->when(
Feature::IncludeFilepathInGeneratorCommandOutput->exists(),
fn ($output) => $output->toContain($outputPath),
fn ($output) => $output->toContainFilepath($domainFactory->path),
);

expect(file_exists($expectedFactoryPath))->toBeTrue(
Expand Down
6 changes: 2 additions & 4 deletions tests/Generator/MakeModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

expect(Artisan::output())->when(
Feature::IncludeFilepathInGeneratorCommandOutput->exists(),
fn ($output) => $output->toContain($relativePath),
fn ($output) => $output->toContainFilepath($relativePath),
);

expect(file_exists($expectedModelPath))->toBeTrue();
Expand Down Expand Up @@ -76,11 +76,9 @@
'--factory' => true,
]);

$outputPath = str_replace('\\', '/', $domainModel->path);

expect(Artisan::output())->when(
Feature::IncludeFilepathInGeneratorCommandOutput->exists(),
fn ($output) => $output->toContain($outputPath),
fn ($output) => $output->toContainFilepath($domainModel->path),
);

expect(file_exists($expectedModelPath))->toBeTrue();
Expand Down
2 changes: 1 addition & 1 deletion tests/Generator/MakeValueObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

expect(Artisan::output())->when(
Feature::IncludeFilepathInGeneratorCommandOutput->exists(),
fn ($output) => $output->toContain($relativePath),
fn ($output) => $output->toContainFilepath($relativePath),
);

expect(file_exists($expectedPath))->toBeTrue();
Expand Down
2 changes: 1 addition & 1 deletion tests/Generator/MakeViewModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

expect(Artisan::output())->when(
Feature::IncludeFilepathInGeneratorCommandOutput->exists(),
fn ($output) => $output->toContain($relativePath),
fn ($output) => $output->toContainFilepath($relativePath),
);

expect(file_exists($expectedPath))->toBeTrue();
Expand Down

0 comments on commit b73a39c

Please sign in to comment.