Skip to content

Commit

Permalink
Pest and arch tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonferens committed Oct 18, 2024
1 parent 6999d24 commit 425a181
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 26 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
composer install --prefer-dist --no-interaction --no-scripts
- name: Run Testsuite
run: vendor/bin/phpunit tests/
run: composer pest

phpunit-php81:
name: PHP 8.1
Expand All @@ -36,7 +36,7 @@ jobs:
composer install --prefer-dist --no-interaction --no-scripts
- name: Run Testsuite
run: vendor/bin/phpunit tests/
run: composer pest

phpunit-php82:
name: PHP 8.2
Expand All @@ -54,4 +54,4 @@ jobs:
composer install --prefer-dist --no-interaction --no-scripts
- name: Run Testsuite
run: vendor/bin/phpunit tests/
run: composer pest
10 changes: 3 additions & 7 deletions .github/workflows/code-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,16 @@ on: push
name: Code Style

jobs:
php-cs-fixer:
pint:
runs-on: ubuntu-latest
container:
image: kirschbaumdevelopment/laravel-test-runner:8.0
image: kirschbaumdevelopment/laravel-test-runner:8.2

steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1

- name: Install PHP CS Fixer
run: |
composer global require friendsofphp/php-cs-fixer
- name: Check Coding Standards
run: php-cs-fixer fix --dry-run
run: composer pint-check

11 changes: 9 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"require-dev": {
"laravel/pint": "^1.18",
"orchestra/testbench": "^7.1|^8.0|^9.0",
"phpunit/phpunit": "^9.5.10|^10.5",
"pestphp/pest": "^2.36|^3.4",
"phpunit/phpunit": "^9.5.10|^10.5|^11.0",
"spatie/ray": "^1.41.1"
},
"autoload": {
Expand All @@ -37,6 +38,9 @@
}
},
"scripts": {
"pest": [
"./vendor/bin/pest"
],
"pint": [
"./vendor/bin/pint"
],
Expand All @@ -48,7 +52,10 @@
]
},
"config": {
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"pestphp/pest-plugin": true
}
},
"minimum-stability": "dev",
"prefer-stable": true
Expand Down
20 changes: 6 additions & 14 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="Mail Intercept Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>

<source>
<include>
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
</include>
</source>
</phpunit>
15 changes: 15 additions & 0 deletions tests/Architecture/AssertableMessageTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

use Illuminate\Support\Traits\ForwardsCalls;
use KirschbaumDevelopment\MailIntercept\AssertableMessage;
use KirschbaumDevelopment\MailIntercept\WithMailInterceptor;
use PHPUnit\Framework\Assert;

arch()->expect(AssertableMessage::class)
->toExtend(Assert::class);

arch()->expect(AssertableMessage::class)
->toUseTraits([
ForwardsCalls::class,
WithMailInterceptor::class,
]);
14 changes: 14 additions & 0 deletions tests/Architecture/AssertionsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

arch()->expect('KirschbaumDevelopment\MailIntercept\Assertions')
->toBeTraits();

arch()->expect('KirschbaumDevelopment\MailIntercept\Assertions')
->traits()
->toHaveSuffix('Assertions');

arch()->expect('KirschbaumDevelopment\MailIntercept\Assertions')
->not->toHavePrivateMethods();

arch()->expect('KirschbaumDevelopment\MailIntercept\Assertions')
->not->toHaveProtectedMethods();
7 changes: 7 additions & 0 deletions tests/Architecture/PresetTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

arch()->preset()->laravel();

arch()->preset()->php();

arch()->preset()->security();
33 changes: 33 additions & 0 deletions tests/Architecture/TraitTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

use KirschbaumDevelopment\MailIntercept\Assertions\BccAssertions;
use KirschbaumDevelopment\MailIntercept\Assertions\CcAssertions;
use KirschbaumDevelopment\MailIntercept\Assertions\ContentAssertions;
use KirschbaumDevelopment\MailIntercept\Assertions\ContentTypeAssertions;
use KirschbaumDevelopment\MailIntercept\Assertions\FromAssertions;
use KirschbaumDevelopment\MailIntercept\Assertions\PriorityAssertions;
use KirschbaumDevelopment\MailIntercept\Assertions\ReplyToAssertions;
use KirschbaumDevelopment\MailIntercept\Assertions\ReturnPathAssertions;
use KirschbaumDevelopment\MailIntercept\Assertions\SenderAssertions;
use KirschbaumDevelopment\MailIntercept\Assertions\SubjectAssertions;
use KirschbaumDevelopment\MailIntercept\Assertions\ToAssertions;
use KirschbaumDevelopment\MailIntercept\Assertions\UnstructuredHeaderAssertions;

arch()->expect('KirschbaumDevelopment\MailIntercept\WithMailInterceptor')
->toBeTrait();

arch()->expect('KirschbaumDevelopment\MailIntercept\WithMailInterceptor')
->toUseTraits([
BccAssertions::class,
CcAssertions::class,
ContentAssertions::class,
ContentTypeAssertions::class,
FromAssertions::class,
PriorityAssertions::class,
ReplyToAssertions::class,
ReturnPathAssertions::class,
SenderAssertions::class,
SubjectAssertions::class,
ToAssertions::class,
UnstructuredHeaderAssertions::class,
]);

0 comments on commit 425a181

Please sign in to comment.