Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 0 additions & 41 deletions tests/ConsoleKernel.php

This file was deleted.

69 changes: 10 additions & 59 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,73 +3,40 @@
namespace Tests;

use Illuminate\Foundation\Testing\RefreshDatabase;
use Statamic\Eloquent\ServiceProvider;
use Statamic\Extend\AddonTestCase;
use Statamic\Facades\Site;

abstract class TestCase extends \Orchestra\Testbench\TestCase
abstract class TestCase extends AddonTestCase
{
use RefreshDatabase;

protected string $addonServiceProvider = ServiceProvider::class;

protected $shouldFakeVersion = true;

protected $shouldPreventNavBeingBuilt = true;

protected $shouldUseStringEntryIds = false;

protected function setUp(): void
{
require_once __DIR__.'/ConsoleKernel.php';

parent::setUp();

$uses = array_flip(class_uses_recursive(static::class));

if ($this->shouldFakeVersion) {
\Facades\Statamic\Version::shouldReceive('get')->zeroOrMoreTimes()->andReturn('3.0.0-testing');
$this->addToAssertionCount(-1); // Dont want to assert this
}
}

public function tearDown(): void
{
parent::tearDown();
}

protected function getPackageProviders($app)
{
return [
\Statamic\Providers\StatamicServiceProvider::class,
\Statamic\Eloquent\ServiceProvider::class,
\Wilderborn\Partyline\ServiceProvider::class,
];
}

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

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

$configs = [
'eloquent-driver',
];

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

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

// We changed the default sites setup but the tests assume defaults like the following.
\Statamic\Facades\Site::setSites([
Site::setSites([
'en' => ['name' => 'English', 'locale' => 'en_US', 'url' => 'http://localhost/'],
]);

$app['config']->set('auth.providers.users.driver', 'statamic');
$app['config']->set('statamic.stache.watcher', false);
$app['config']->set('statamic.users.repository', 'file');
$app['config']->set('statamic.stache.stores.users', [
'class' => \Statamic\Stache\Stores\UsersStore::class,
'directory' => __DIR__.'/__fixtures__/users',
Expand Down Expand Up @@ -118,22 +85,6 @@ protected function assertEveryItemIsInstanceOf($class, $items)
$this->assertEquals(count($items), $matches, 'Failed asserting that every item is an instance of '.$class);
}

protected function assertContainsHtml($string)
{
preg_match('/<[^<]+>/', $string, $matches);

$this->assertNotEmpty($matches, 'Failed asserting that string contains HTML.');
}

// This method is unavailable on earlier versions of Laravel.
public function partialMock($abstract, ?\Closure $mock = null)
{
$mock = \Mockery::mock(...array_filter(func_get_args()))->makePartial();
$this->app->instance($abstract, $mock);

return $mock;
}

protected function isUsingSqlite()
{
$connection = config('database.default');
Expand Down