Skip to content

Commit

Permalink
Switch to using Statamic 5's add on test case
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanmitchell committed Apr 12, 2024
1 parent 00384ea commit c07d502
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 114 deletions.
27 changes: 0 additions & 27 deletions tests/ExceptionHandler.php

This file was deleted.

30 changes: 0 additions & 30 deletions tests/PreventSavingStacheItemsToDisk.php

This file was deleted.

60 changes: 3 additions & 57 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,74 +2,20 @@

namespace StatamicRadPack\CampaignMonitor\Tests;

use JMac\Testing\Traits\AdditionalAssertions;
use Orchestra\Testbench\TestCase as OrchestraTestCase;
use Statamic\Extend\Manifest;
use Statamic\Extend\AddonTestCase;
use Statamic\Facades\Blueprint as BlueprintFacade;
use Statamic\Facades\YAML;
use Statamic\Providers\StatamicServiceProvider;
use Statamic\Statamic;
use StatamicRadPack\CampaignMonitor\ServiceProvider;

class TestCase extends OrchestraTestCase
class TestCase extends AddonTestCase
{
use AdditionalAssertions, PreventSavingStacheItemsToDisk;

public function setup(): void
{
parent::setup();
$this->preventSavingStacheItemsToDisk();
}

public function tearDown(): void
{
$this->deleteFakeStacheDirectory();

parent::tearDown();
}

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 = [
'statamic-rad-pack/campaign-monitor' => [
'id' => 'statamic-rad-pack/campaign-monitor',
'namespace' => 'StatamicRadPack\\CampaignMonitor',
],
];

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

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

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

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

// Setting the user repository to the default flat file system
$app['config']->set('statamic.users.repository', 'file');

// Assume the pro edition within tests
$app['config']->set('statamic.editions.pro', true);

Statamic::booted(function () {
$blueprintContents = YAML::parse(file_get_contents(__DIR__.'/__fixtures__/blueprints/contact_us.yaml'));
$blueprintFields = collect($blueprintContents['sections']['main']['fields'])
Expand Down

0 comments on commit c07d502

Please sign in to comment.