-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
162 additions
and
7 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,38 @@ | ||
name: Test Suite | ||
|
||
on: | ||
push: | ||
pull_request: | ||
|
||
jobs: | ||
php_tests: | ||
if: "!contains(github.event.head_commit.message, 'changelog')" | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
matrix: | ||
php: [8.3, 8.2] | ||
laravel: [11.*] | ||
statamic: [^5.0] | ||
os: [ubuntu-latest] | ||
|
||
name: ${{ matrix.php }} - ${{ matrix.statamic }} - ${{ matrix.laravel }} | ||
|
||
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 }}" "statamic/cms:${{ matrix.statamic }}" --no-interaction --no-update | ||
composer install --no-interaction | ||
- name: Run Pest | ||
run: vendor/bin/pest |
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 |
---|---|---|
|
@@ -6,3 +6,4 @@ composer.lock | |
mix-manifest.json | ||
package-lock.json | ||
yarn.lock | ||
.idea/* |
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
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,17 @@ | ||
<?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/10.4/phpunit.xsd" processIsolation="false" stopOnFailure="false" beStrictAboutTestsThatDoNotTestAnything="false" cacheDirectory=".phpunit.cache"> | ||
<testsuites> | ||
<testsuite name="Test Suite"> | ||
<directory suffix="Test.php">./tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<php> | ||
<env name="APP_ENV" value="testing"/> | ||
<env name="CACHE_DRIVER" value="array"/> | ||
<env name="SESSION_DRIVER" value="array"/> | ||
<env name="QUEUE_DRIVER" value="sync"/> | ||
<env name="MAIL_DRIVER" value="array"/> | ||
<env name="DB_CONNECTION" value="sqlite"/> | ||
<env name="DB_DATABASE" value=":memory:"/> | ||
</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
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,30 @@ | ||
<?php | ||
|
||
namespace Thoughtco\StatamicCacheTracker\Tests; | ||
|
||
use Illuminate\Encryption\Encrypter; | ||
use Statamic\Testing\AddonTestCase; | ||
use Statamic\Testing\Concerns\PreventsSavingStacheItemsToDisk; | ||
use Thoughtco\StatamicCacheTracker\ServiceProvider; | ||
|
||
class TestCase extends AddonTestCase | ||
{ | ||
use PreventsSavingStacheItemsToDisk; | ||
|
||
protected string $addonServiceProvider = ServiceProvider::class; | ||
|
||
protected $shouldFakeVersion = true; | ||
|
||
protected function resolveApplicationConfiguration($app) | ||
{ | ||
parent::resolveApplicationConfiguration($app); | ||
|
||
$app['config']->set('app.key', 'base64:'.base64_encode(Encrypter::generateKey($app['config']['app.cipher']))); | ||
|
||
// Assume the pro edition within tests | ||
$app['config']->set('statamic.editions.pro', true); | ||
|
||
// enable caching | ||
$app['config']->set('statamic.static_caching.strategy', 'half'); | ||
} | ||
} |
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,40 @@ | ||
<?php | ||
|
||
namespace Thoughtco\StatamicCacheTracker\Tests\Unit; | ||
|
||
use PHPUnit\Framework\Attributes\Test; | ||
use Thoughtco\StatamicCacheTracker\Facades\Tracker; | ||
use Thoughtco\StatamicCacheTracker\Tests\TestCase; | ||
|
||
class AdditionalTrackerTest extends TestCase | ||
{ | ||
#[Test] | ||
public function tracks_additional_closures() | ||
{ | ||
Tracker::addAdditionalTracker(function ($tracker, $next) { | ||
$tracker->addContentTag('test::tag'); | ||
}); | ||
|
||
$this->get('/'); | ||
|
||
$this->assertSame(['test::tag'], collect(Tracker::all())->firstWhere('url', 'http://localhost/')['tags']); | ||
} | ||
|
||
#[Test] | ||
public function tracks_additional_classes() | ||
{ | ||
Tracker::addAdditionalTracker(AdditionalTrackerClass::class); | ||
|
||
$this->get('/'); | ||
|
||
$this->assertSame(['additional::tag'], collect(Tracker::all())->firstWhere('url', 'http://localhost/')['tags']); | ||
} | ||
} | ||
|
||
class AdditionalTrackerClass | ||
{ | ||
public function __invoke($tracker, $next) | ||
{ | ||
$tracker->addContentTag('additional::tag'); | ||
} | ||
} |
Empty file.