-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add support for Statamic v5 * Add basic test coverage
- Loading branch information
1 parent
95ca2f0
commit aca1091
Showing
6 changed files
with
133 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Test Suite | ||
|
||
on: | ||
push: | ||
pull_request: | ||
|
||
jobs: | ||
php_tests: | ||
strategy: | ||
matrix: | ||
php: [8.2, 8.3] | ||
laravel: [11.*] | ||
os: [ubuntu-latest] | ||
|
||
name: ${{ matrix.php }} - ${{ matrix.laravel }} | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v1 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick | ||
|
||
- name: Install dependencies | ||
run: | | ||
composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update | ||
composer install --no-interaction | ||
- name: Run PHPUnit | ||
run: vendor/bin/phpunit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ node_modules | |
vendor | ||
mix-manifest.json | ||
composer.lock | ||
.phpunit.result.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" beStrictAboutTestsThatDoNotTestAnything="false"> | ||
<coverage/> | ||
<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:ybcI9MKuhLnESRSuWDfnJQuohOXMBaynfbTC5Y5i1FE="/> | ||
<env name="BCRYPT_ROUNDS" value="4"/> | ||
<env name="CACHE_DRIVER" value="array"/> | ||
<!-- <env name="DB_CONNECTION" value="sqlite"/> --> | ||
<!-- <env name="DB_DATABASE" value=":memory:"/> --> | ||
<env name="MAIL_MAILER" value="array"/> | ||
<env name="QUEUE_CONNECTION" value="sync"/> | ||
<env name="SESSION_DRIVER" value="array"/> | ||
<env name="TELESCOPE_ENABLED" value="false"/> | ||
</php> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace MarcoRieser\TailwindMergeStatamic\Tests; | ||
|
||
use Statamic\Statamic; | ||
|
||
class ModifierTest extends TestCase | ||
{ | ||
public function test_that_modifier_works_without_params(): void | ||
{ | ||
$this->assertSame( | ||
'h-10 rounded-full bg-blue-500 w-8', | ||
(string)Statamic::modify("w-10 h-10 rounded-full bg-red-500 bg-blue-500 w-8")->twMerge() | ||
); | ||
|
||
$this->assertSame( | ||
'h-10 rounded-full bg-blue-500 w-8', | ||
(string)Statamic::modify(['w-10 h-10 rounded-full bg-red-500', 'bg-blue-500 w-8'])->twMerge() | ||
); | ||
|
||
$this->assertSame( | ||
'h-10 rounded-full bg-blue-500 w-8', | ||
(string)Statamic::modify(['w-10 h-10 rounded-full bg-red-500', ['bg-blue-500 w-8']])->twMerge() | ||
); | ||
} | ||
|
||
public function test_that_modifier_works_with_params(): void | ||
{ | ||
$this->assertSame( | ||
'h-10 rounded-full bg-blue-500 w-8', | ||
(string)Statamic::modify("w-10 h-10 rounded-full bg-red-500")->context(['classes_to_merge' => 'bg-blue-500 w-8'])->twMerge('classes_to_merge') | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace MarcoRieser\TailwindMergeStatamic\Tests; | ||
|
||
use MarcoRieser\TailwindMergeStatamic\ServiceProvider; | ||
use Statamic\Providers\StatamicServiceProvider; | ||
use Statamic\Testing\AddonTestCase; | ||
use TailwindMerge\Laravel\TailwindMergeServiceProvider; | ||
|
||
abstract class TestCase extends AddonTestCase | ||
{ | ||
protected string $addonServiceProvider = ServiceProvider::class; | ||
|
||
protected function getPackageProviders($app) | ||
{ | ||
$serviceProviders = parent::getPackageProviders($app); | ||
|
||
$serviceProviders[] = TailwindMergeServiceProvider::class; | ||
|
||
return $serviceProviders; | ||
} | ||
} |