Skip to content

Commit

Permalink
[4.x] Statamic 5 (#66)
Browse files Browse the repository at this point in the history
* Update dependencies

* Update PHPUnit

* Simplify `TestCase`

* `AllowedFile` has moved

* Fix testing workflow

* tweak statamic constraint in `composer.json`

* tweak statamic constraint in testing matrix

* Update `AddonTestCase` import
  • Loading branch information
duncanmcclean committed Apr 27, 2024
1 parent 7c5b2c3 commit e895308
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 93 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ jobs:
strategy:
matrix:
php: [8.3, 8.2]
framework: [10.*]
statamic: [^4.0]
testbench: [8.*]
laravel: [11.*, 10.*]
statamic: [^5.0]
os: [ubuntu-latest]

name: ${{ matrix.php }} - ${{ matrix.statamic }} - ${{ matrix.laravel }}
Expand All @@ -32,8 +31,8 @@ jobs:

- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.framework }}" "statamic/cms:${{ matrix.statamic }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer require "laravel/framework:${{ matrix.laravel }}" "statamic/cms:${{ matrix.statamic }}" --no-interaction --no-update
composer install --no-interaction
- name: Run PHPUnit
run: composer test
run: vendor/bin/pest
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ package-lock.json
.php_cs.cache
.idea
composer.lock
.phpunit.cache
15 changes: 3 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,13 @@
},
"require": {
"php": "^8.2",
"statamic/cms": "^4.0"
"statamic/cms": "^5.0"
},
"require-dev": {
"nunomaduro/collision": "^6.1",
"orchestra/testbench": "^7.0",
"pestphp/pest": "^1.22",
"orchestra/testbench": "^8.0 || ^9.0",
"pestphp/pest": "^2.2",
"spatie/test-time": "^1.2"
},
"scripts": {
"lint": [
"php-cs-fixer fix ./src"
],
"test": [
"php -d memory_limit=-1 -d max_execution_time=0 ./vendor/bin/pest"
]
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
Expand Down
47 changes: 19 additions & 28 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,30 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
printerClass="NunoMaduro\Collision\Adapters\Phpunit\Printer">
<testsuites>
<testsuite name="Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./app</directory>
</whitelist>
</filter>
<php>
<env name="APP_ENV" value="testing"/>
<env name="APP_KEY" value="base64:xRIcDp1ReW8Y8rd9V9D7hOVV4TI7ThCF3FKxRg01Rm8="/>
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>
<env name="MAIL_DRIVER" value="array"/>
</php>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<php>
<env name="APP_ENV" value="testing"/>
<env name="APP_KEY" value="base64:xRIcDp1ReW8Y8rd9V9D7hOVV4TI7ThCF3FKxRg01Rm8="/>
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>
<env name="MAIL_DRIVER" value="array"/>
</php>
<source>
<include>
<directory suffix=".php">./app</directory>
</include>
</source>
</phpunit>
2 changes: 1 addition & 1 deletion src/Http/Controllers/GuestEntryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
use Statamic\Fieldtypes\Assets\Assets as AssetFieldtype;
use Statamic\Fieldtypes\Date as DateFieldtype;
use Statamic\Fieldtypes\Replicator;
use Statamic\Rules\AllowedFile;
use Statamic\Sites\Site;
use Statamic\Validation\AllowedFile;

class GuestEntryController extends Controller
{
Expand Down
50 changes: 3 additions & 47 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,9 @@
namespace DuncanMcClean\GuestEntries\Tests;

use DuncanMcClean\GuestEntries\ServiceProvider;
use Orchestra\Testbench\TestCase as OrchestraTestCase;
use Statamic\Extend\Manifest;
use Statamic\Providers\StatamicServiceProvider;
use Statamic\Statamic;
use Statamic\Testing\AddonTestCase;

abstract class TestCase extends OrchestraTestCase
abstract class TestCase extends AddonTestCase
{
protected function getPackageProviders($app)
{
return [
StatamicServiceProvider::class,
ServiceProvider::class,
];
}

protected function getPackageAliases($app)
{
return [
'Statamic' => Statamic::class,
];
}

protected function getEnvironmentSetUp($app)
{
parent::getEnvironmentSetUp($app);

$app->make(Manifest::class)->manifest = [
'duncanmcclean/guest-entries' => [
'id' => 'duncanmcclean/guest-entries',
'namespace' => 'DuncanMcClean\\GuestEntries',
],
];
}

protected function resolveApplicationConfiguration($app)
{
parent::resolveApplicationConfiguration($app);

$configs = [
'assets', 'cp', 'forms', 'static_caching',
'sites', 'stache', 'system', 'users',
];

foreach ($configs as $config) {
$app['config']->set("statamic.$config", require (__DIR__."/../vendor/statamic/cms/config/{$config}.php"));
}

$app['config']->set('statamic.users.repository', 'file');
}
protected string $addonServiceProvider = ServiceProvider::class;
}

0 comments on commit e895308

Please sign in to comment.