Skip to content

Commit 6afac9a

Browse files
Add Laravel 13 support (#72)
* Bump dependencies for Laravel 13 * Update GitHub Actions for Laravel 13 * Fix styling * Add PHP 8.5 support, fix coverage warnings, ensure Pest 4/PHPUnit 12 * Fix styling * Clean up CI workflow for L13 support * Fix CI workflow GitHub Actions syntax * Convert @test to #[Test] for PHPUnit 12 * Fix styling --------- Co-authored-by: Shift <shift@laravelshift.com> Co-authored-by: laravel-shift <laravel-shift@users.noreply.github.com> Co-authored-by: freekmurze <freekmurze@users.noreply.github.com>
1 parent 45a43f7 commit 6afac9a

File tree

7 files changed

+37
-65
lines changed

7 files changed

+37
-65
lines changed

.github/workflows/run-tests.yml

Lines changed: 18 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,38 @@
11
name: run-tests
22

3-
on:
4-
- push
5-
- pull_request
3+
on: [push, pull_request]
64

75
jobs:
86
test:
9-
runs-on: ${{ matrix.os }}
7+
runs-on: ubuntu-latest
108

119
strategy:
12-
fail-fast: false
10+
fail-fast: true
1311
matrix:
14-
os: [ubuntu-latest]
15-
php: [8.4, 8.3, 8.2, 8.1, 8.0]
16-
laravel: ['8.*', '9.*', '10.*', '11.*', '12.*']
17-
dependency-version: [prefer-stable]
12+
php: [8.5, 8.4, 8.3, 8.2]
13+
laravel: ['13.*', '12.*', '11.*', '10.*']
14+
stability: [prefer-stable]
1815
include:
19-
- laravel: 10.*
20-
testbench: 8.*
21-
- laravel: 9.*
22-
testbench: 7.*
23-
- laravel: 8.*
24-
testbench: 6.*
25-
- laravel: 11.*
26-
testbench: 9.*
16+
- laravel: 13.*
17+
testbench: 11.*
2718
- laravel: 12.*
2819
testbench: 10.*
20+
- laravel: 11.*
21+
testbench: 9.*
22+
- laravel: 10.*
23+
testbench: 8.*
2924
exclude:
30-
- laravel: 8.*
31-
php: 8.0
32-
dependency-version: prefer-lowest
33-
- laravel: 8.*
34-
php: 8.2
35-
dependency-version: prefer-lowest
36-
- laravel: 6.*
25+
- laravel: 13.*
3726
php: 8.2
3827
- laravel: 10.*
39-
php: 8.0
40-
- laravel: 11.*
41-
php: 8.1
42-
- laravel: 11.*
43-
php: 8.0
44-
- laravel: 12.*
45-
php: 8.1
46-
- laravel: 12.*
47-
php: 8.0
28+
php: 8.5
4829

49-
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} - ${{ matrix.os }}
30+
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }}
5031

5132
steps:
5233
- name: Checkout code
53-
uses: actions/checkout@v2
54-
34+
uses: actions/checkout@v4
35+
5536
- name: Setup PHP
5637
uses: shivammathur/setup-php@v2
5738
with:
@@ -62,7 +43,7 @@ jobs:
6243
- name: Install dependencies
6344
run: |
6445
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
65-
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest
46+
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
6647
6748
- name: Execute tests
6849
run: vendor/bin/phpunit

.php-cs-fixer.cache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"php":"8.4.12","version":"3.87.1","indent":" ","lineEnding":"\n","rules":{"blank_line_after_namespace":true,"braces_position":true,"class_definition":true,"constant_case":true,"control_structure_braces":true,"control_structure_continuation_position":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline","keep_multiple_spaces_after_comma":true},"no_break_comment":true,"no_closing_tag":true,"no_multiple_statements_per_line":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":true,"single_line_after_imports":true,"single_space_around_construct":{"constructs_followed_by_a_single_space":["abstract","as","case","catch","class","do","else","elseif","final","for","foreach","function","if","interface","namespace","private","protected","public","static","switch","trait","try","use_lambda","while"],"constructs_preceded_by_a_single_space":["as","else","elseif","use_lambda"]},"spaces_inside_parentheses":true,"statement_indentation":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":{"elements":["method","property"]},"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"short"},"ordered_imports":{"sort_algorithm":"alpha"},"no_unused_imports":true,"not_operator_with_successor_space":true,"trailing_comma_in_multiline":true,"phpdoc_scalar":true,"unary_operator_spaces":true,"binary_operator_spaces":true,"blank_line_before_statement":{"statements":["break","continue","declare","return","throw","try"]},"phpdoc_single_line_var_spacing":true,"phpdoc_var_without_name":true,"single_trait_insert_per_statement":true},"hashes":{"src\/TemplateMailable.php":"98d21ed30247a6181e1eef3e35229476","src\/Exceptions\/MissingMailTemplate.php":"1079084a808a88c3f7950bd411fd01dc","src\/Exceptions\/CannotRenderTemplateMailable.php":"4a5ad26d39238538944b3dbff7fc8b0c","src\/Models\/MailTemplate.php":"b6ae1e6ab0f07620284b9979a36a75ea","src\/TemplateMailableRenderer.php":"454745cd3650d5ef2b6ae174b8ef189b","src\/MailTemplatesServiceProvider.php":"9994d50db2d640e83d06ac3de231619f","src\/Interfaces\/MailTemplateInterface.php":"f7f55f6c86a750bb6b084af536af4dbc","tests\/TestCase.php":"2741e36ef5bf6e39811c2454e3ab659c","tests\/MailTemplateModelTest.php":"1129ce6d661faddbda96e62a451aa0cd","tests\/TemplateMailableTest.php":"9264710859869feceb0c313e795557e9","tests\/CustomMailTemplateTest.php":"5ee328d3e91093bfba0db981e9b5543a","tests\/stubs\/Models\/CustomMailTemplate.php":"aed43d597448ef37e5c70c26ec7000c9","tests\/stubs\/Models\/LayoutMailTemplate.php":"8105ab377ae18d2e26124471017a5305","tests\/stubs\/Mails\/LayoutMail.php":"516adbabcfc298f25b483eeb8b24197f","tests\/stubs\/Mails\/BadLayoutMail.php":"f57d2d09055e857f7817fe5b614d145a","tests\/stubs\/Mails\/BasicMail.php":"7eb282fa204a1addf59e393262b82aa4","tests\/stubs\/Mails\/CustomTemplateModelMail.php":"2e65b916a96c3ece2edb3632ac1046f5"}}
1+
{"php":"8.5.3","version":"3.94.2","indent":" ","lineEnding":"\n","rules":{"blank_line_after_namespace":true,"braces_position":{"allow_single_line_anonymous_functions":false},"class_definition":true,"constant_case":true,"control_structure_braces":true,"control_structure_continuation_position":true,"elseif":true,"function_declaration":{"closure_fn_spacing":"one"},"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline","keep_multiple_spaces_after_comma":true},"modifier_keywords":{"elements":["method","property"]},"no_break_comment":true,"no_closing_tag":true,"no_multiple_statements_per_line":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":true,"single_line_after_imports":true,"single_space_around_construct":{"constructs_followed_by_a_single_space":["abstract","as","case","catch","class","do","else","elseif","final","for","foreach","function","if","interface","namespace","private","protected","public","static","switch","trait","try","use_lambda","while"],"constructs_preceded_by_a_single_space":["as","else","elseif","use_lambda"]},"spaces_inside_parentheses":true,"statement_indentation":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"short"},"ordered_imports":{"sort_algorithm":"alpha"},"no_unused_imports":true,"not_operator_with_successor_space":true,"trailing_comma_in_multiline":true,"phpdoc_scalar":true,"unary_operator_spaces":true,"binary_operator_spaces":true,"blank_line_before_statement":{"statements":["break","continue","declare","return","throw","try"]},"phpdoc_single_line_var_spacing":true,"phpdoc_var_without_name":true,"single_trait_insert_per_statement":true},"ruleCustomisationPolicyVersion":"null-policy","hashes":{"src\/MailTemplatesServiceProvider.php":"9994d50db2d640e83d06ac3de231619f","src\/Interfaces\/MailTemplateInterface.php":"f7f55f6c86a750bb6b084af536af4dbc","src\/Models\/MailTemplate.php":"b6ae1e6ab0f07620284b9979a36a75ea","src\/TemplateMailable.php":"98d21ed30247a6181e1eef3e35229476","src\/Exceptions\/CannotRenderTemplateMailable.php":"4a5ad26d39238538944b3dbff7fc8b0c","src\/Exceptions\/MissingMailTemplate.php":"1079084a808a88c3f7950bd411fd01dc","src\/TemplateMailableRenderer.php":"454745cd3650d5ef2b6ae174b8ef189b","tests\/TestCase.php":"2741e36ef5bf6e39811c2454e3ab659c","tests\/CustomMailTemplateTest.php":"c2e001aa8880051ed7788a58d90c5221","tests\/stubs\/Models\/CustomMailTemplate.php":"aed43d597448ef37e5c70c26ec7000c9","tests\/stubs\/Models\/LayoutMailTemplate.php":"8105ab377ae18d2e26124471017a5305","tests\/stubs\/Mails\/LayoutMail.php":"516adbabcfc298f25b483eeb8b24197f","tests\/stubs\/Mails\/BasicMail.php":"7eb282fa204a1addf59e393262b82aa4","tests\/stubs\/Mails\/CustomTemplateModelMail.php":"2e65b916a96c3ece2edb3632ac1046f5","tests\/stubs\/Mails\/BadLayoutMail.php":"f57d2d09055e857f7817fe5b614d145a","tests\/MailTemplateModelTest.php":"cf8f128c6bb1745bb68d9a13891cff17","tests\/TemplateMailableTest.php":"adf110ac1adcc151b92a5e94b91fea58"}}

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
],
1818
"require": {
1919
"php": "^7.2|^8.0",
20-
"laravel/framework": "~5.8|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0",
20+
"laravel/framework": "~5.8|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0|^13.0",
2121
"mustache/mustache": "^2.14.1|^2.14"
2222
},
2323
"require-dev": {
2424
"ext-pdo_sqlite": "*",
2525
"mockery/mockery": "^1.0|^1.3.1",
26-
"orchestra/testbench": "~3.8|^4.0|^5.0|^6.0|^7.0|^8.0|^9.0|^10.0",
27-
"phpunit/phpunit": "^7.5|^8.0|^9.3|^10.5|^11.5.3"
26+
"orchestra/testbench": "~3.8|^4.0|^5.0|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0",
27+
"phpunit/phpunit": "^7.5|^8.0|^9.3|^10.5|^11.5.3|^12.5.12"
2828
},
2929
"autoload": {
3030
"psr-4": {

phpunit.xml.dist

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit bootstrap="vendor/autoload.php"
33
backupGlobals="false"
4-
backupStaticAttributes="false"
54
colors="true"
6-
verbose="true"
7-
convertErrorsToExceptions="true"
8-
convertNoticesToExceptions="true"
9-
convertWarningsToExceptions="true"
105
processIsolation="false"
116
stopOnFailure="false">
127
<testsuites>
@@ -19,13 +14,6 @@
1914
<directory suffix=".php">src/</directory>
2015
</whitelist>
2116
</filter>
22-
<logging>
23-
<log type="tap" target="build/report.tap"/>
24-
<log type="junit" target="build/report.junit.xml"/>
25-
<log type="coverage-html" target="build/coverage"/>
26-
<log type="coverage-text" target="build/coverage.txt"/>
27-
<log type="coverage-clover" target="build/logs/clover.xml"/>
28-
</logging>
2917
<php>
3018
<env name="DB_CONNECTION" value="testing" />
3119
</php>

tests/CustomMailTemplateTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
namespace Spatie\MailTemplates\Tests;
44

5+
use PHPUnit\Framework\Attributes\Test;
56
use Spatie\MailTemplates\Tests\stubs\Mails\BasicMail;
67
use Spatie\MailTemplates\Tests\stubs\Mails\CustomTemplateModelMail;
78
use Spatie\MailTemplates\Tests\stubs\Models\CustomMailTemplate;
89

910
class CustomMailTemplateTest extends TestCase
1011
{
11-
/** @test */
12+
#[Test]
1213
public function it_can_render_a_mailable_using_a_custom_mail_template()
1314
{
1415
$this->createMailTemplateForMailable(BasicMail::class, CustomMailTemplate::class, ['use' => true]);
@@ -18,7 +19,7 @@ public function it_can_render_a_mailable_using_a_custom_mail_template()
1819
$this->assertEquals('<main>Hello, John</main>', $renderedMail);
1920
}
2021

21-
/** @test */
22+
#[Test]
2223
public function it_can_resolve_a_mail_template_for_a_mailable_based_on_a_custom_scope()
2324
{
2425
$this->createMailTemplateForMailable(CustomTemplateModelMail::class, CustomMailTemplate::class, ['use' => false]);

tests/MailTemplateModelTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
namespace Spatie\MailTemplates\Tests;
44

5+
use PHPUnit\Framework\Attributes\Test;
56
use Spatie\MailTemplates\Models\MailTemplate;
67
use Spatie\MailTemplates\Tests\stubs\Mails\BasicMail;
78
use Spatie\MailTemplates\Tests\stubs\Models\LayoutMailTemplate;
89

910
class MailTemplateModelTest extends TestCase
1011
{
11-
/** @test */
12+
#[Test]
1213
public function it_can_resolve_the_right_mail_template_for_a_mailable()
1314
{
1415
$mailTemplate = $this->createMailTemplateForMailable(BasicMail::class);
@@ -20,7 +21,7 @@ public function it_can_resolve_the_right_mail_template_for_a_mailable()
2021
$this->assertEquals($mailTemplate->id, $resolvedMailTemplate->id);
2122
}
2223

23-
/** @test */
24+
#[Test]
2425
public function it_can_get_the_available_template_variables_for_a_mail_template()
2526
{
2627
$basicMail = new BasicMail();
@@ -32,7 +33,7 @@ public function it_can_get_the_available_template_variables_for_a_mail_template(
3233
$this->assertEquals(['name', 'email'], $variables);
3334
}
3435

35-
/** @test */
36+
#[Test]
3637
public function it_gets_an_empty_template_variable_array_for_a_mail_template_with_a_missing_mailable()
3738
{
3839
$mailTemplate = $this->createMailTemplateForMailable('\Non\Existent\Mailable');
@@ -42,7 +43,7 @@ public function it_gets_an_empty_template_variable_array_for_a_mail_template_wit
4243
$this->assertEquals([], $variables);
4344
}
4445

45-
/** @test */
46+
#[Test]
4647
public function it_can_render_a_mail_template_with_a_layout()
4748
{
4849
LayoutMailTemplate::create([

tests/TemplateMailableTest.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Spatie\MailTemplates\Tests;
44

5+
use PHPUnit\Framework\Attributes\Test;
56
use Spatie\MailTemplates\Exceptions\CannotRenderTemplateMailable;
67
use Spatie\MailTemplates\Exceptions\MissingMailTemplate;
78
use Spatie\MailTemplates\Models\MailTemplate;
@@ -11,7 +12,7 @@
1112

1213
class TemplateMailableTest extends TestCase
1314
{
14-
/** @test */
15+
#[Test]
1516
public function it_can_render_a_mailable()
1617
{
1718
MailTemplate::create([
@@ -24,15 +25,15 @@ public function it_can_render_a_mailable()
2425
$this->assertEquals('Hello, John', $renderedMail);
2526
}
2627

27-
/** @test */
28+
#[Test]
2829
public function it_can_get_the_available_template_variables_for_a_mailable()
2930
{
3031
$variables = BasicMail::getVariables();
3132

3233
$this->assertEquals(['name', 'email'], $variables);
3334
}
3435

35-
/** @test */
36+
#[Test]
3637
public function it_can_render_a_mailable_with_a_layout()
3738
{
3839
$this->createMailTemplateForMailable(LayoutMail::class);
@@ -42,7 +43,7 @@ public function it_can_render_a_mailable_with_a_layout()
4243
$this->assertEquals('<main>Hello, John</main>', $renderedMail);
4344
}
4445

45-
/** @test */
46+
#[Test]
4647
public function it_throws_an_exception_if_the_layout_does_not_contain_a_body_tag()
4748
{
4849
$this->expectException(CannotRenderTemplateMailable::class);
@@ -52,15 +53,15 @@ public function it_throws_an_exception_if_the_layout_does_not_contain_a_body_tag
5253
(new BadLayoutMail('John'))->render();
5354
}
5455

55-
/** @test */
56+
#[Test]
5657
public function it_throws_an_exception_if_no_mail_template_exists_for_mailable()
5758
{
5859
$this->expectException(MissingMailTemplate::class);
5960

6061
(new BasicMail('John'))->render();
6162
}
6263

63-
/** @test */
64+
#[Test]
6465
public function it_can_set_additional_data()
6566
{
6667
MailTemplate::create([

0 commit comments

Comments
 (0)