Revert Laravel Dusk changes (#4919)

The Browser tests will be made into a RainLab plugin. (https://github.com/rainlab/dusk-plugin)
This commit is contained in:
Ben Thomson 2020-02-07 16:59:39 +08:00
parent ef86ddc482
commit 5e4916148f
81 changed files with 681 additions and 1428 deletions

View File

@ -1,38 +0,0 @@
APP_ENV=dusk
APP_DEBUG=true
APP_URL=http://127.0.0.1:8000
APP_KEY=base64:R2w4QUhGcWxobnpjcHhlSkd0MHpMTjVxZTVuZ1BkaUM=
DB_CONNECTION=sqlite
DB_HOST=
DB_PORT=
DB_DATABASE=storage/dusk.sqlite
DB_USERNAME=
DB_PASSWORD=
REDIS_HOST=
REDIS_PASSWORD=
REDIS_PORT=
DB_USE_CONFIG_FOR_TESTING=false
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_CONNECTION=sync
MAIL_DRIVER=array
MAIL_HOST=
MAIL_PORT=
MAIL_ENCRYPTION=tls
MAIL_USERNAME=
MAIL_PASSWORD=
ROUTES_CACHE=false
ASSET_CACHE=false
DATABASE_TEMPLATES=false
LINK_POLICY=detect
ENABLE_CSRF=false
# Uncomment the following to use custom authentication credentials for tests
#DUSK_ADMIN_USER=
#DUSK_ADMIN_PASS=

View File

@ -261,15 +261,6 @@ class ServiceProvider extends ModuleServiceProvider
$this->registerConsoleCommand('theme.list', 'System\Console\ThemeList'); $this->registerConsoleCommand('theme.list', 'System\Console\ThemeList');
$this->registerConsoleCommand('theme.use', 'System\Console\ThemeUse'); $this->registerConsoleCommand('theme.use', 'System\Console\ThemeUse');
$this->registerConsoleCommand('theme.sync', 'System\Console\ThemeSync'); $this->registerConsoleCommand('theme.sync', 'System\Console\ThemeSync');
if (!App::isProduction() && class_exists('Laravel\Dusk\Dusk')) {
$this->registerConsoleCommand('dusk', 'System\Console\Dusk');
$this->registerConsoleCommand('dusk.fails', 'System\Console\DuskFails');
$this->commands([
\Laravel\Dusk\Console\ChromeDriverCommand::class,
]);
}
} }
/* /*

View File

@ -1,89 +0,0 @@
<?php namespace System\Console;
use Laravel\Dusk\Console\DuskCommand as BaseDuskCommand;
class Dusk extends BaseDuskCommand
{
/**
* Setup the Dusk environment.
*
* @return void
*/
protected function setupDuskEnvironment()
{
if (file_exists(base_path($this->duskFile()))) {
if (!file_exists(base_path('.env'))) {
$this->stubEnvironment();
} elseif (file_get_contents(base_path('.env')) !== file_get_contents(base_path($this->duskFile()))) {
$this->backupEnvironment();
}
$this->refreshEnvironment();
}
$this->writeConfiguration();
$this->setupSignalHandler();
}
/**
* Restore the original environment.
*
* @return void
*/
protected function teardownDuskEnviroment()
{
$this->removeConfiguration();
if (
file_exists(base_path($this->duskFile()))
&& (
file_exists(base_path('.env.backup'))
|| file_exists(base_path('.env.blank'))
)
) {
$this->restoreEnvironment();
}
}
/**
* Stub a current environment file.
*
* @return void
*/
protected function stubEnvironment()
{
touch(base_path('.env.blank'));
copy(base_path($this->duskFile()), base_path('.env'));
}
/**
* Backup the current environment file.
*
* @return void
*/
protected function backupEnvironment()
{
copy(base_path('.env'), base_path('.env.backup'));
copy(base_path($this->duskFile()), base_path('.env'));
}
/**
* Restore the backed-up environment file.
*
* @return void
*/
protected function restoreEnvironment()
{
if (file_exists(base_path('.env.blank'))) {
unlink(base_path('.env'));
unlink(base_path('.env.blank'));
} else {
copy(base_path('.env.backup'), base_path('.env'));
unlink(base_path('.env.backup'));
}
}
}

View File

@ -1,31 +0,0 @@
<?php namespace System\Console;
class DuskFails extends Dusk
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'dusk:fails {--without-tty : Disable output to TTY}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Run the failing Dusk tests from the last run and stop on failure';
/**
* Get the array of arguments for running PHPUnit.
*
* @param array $options
* @return array
*/
protected function phpunitArguments($options)
{
return array_unique(array_merge(parent::phpunitArguments($options), [
'--cache-result', '--order-by=defects', '--stop-on-failure',
]));
}
}

View File

@ -1,34 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="tests/bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
>
<testsuites>
<testsuite name="October CMS Browser Test Suite">
<directory suffix="Test.php">./tests/Browser/Backend</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">./modules/</directory>
<exclude>
<file>./modules/backend/routes.php</file>
<file>./modules/cms/routes.php</file>
<file>./modules/system/routes.php</file>
<directory suffix=".php">./modules/backend/database</directory>
<directory suffix=".php">./modules/cms/database</directory>
<directory suffix=".php">./modules/system/database</directory>
</exclude>
</whitelist>
</filter>
</phpunit>

View File

@ -1,41 +0,0 @@
<?php namespace October\Core\Tests\Browser\Backend;
use Laravel\Dusk\Browser;
use October\Core\Tests\Browser\Pages\Backend\ForgotPassword;
use October\Core\Tests\Browser\Pages\Backend\Login;
class AuthTest extends \October\Core\Tests\BrowserTestCase
{
public function testSignInAndOut()
{
$this->browse(function (Browser $browser) {
$browser
->signInToBackend()
->click('@accountMenu')
->clickLink('Sign out');
$browser
->on(new Login);
});
}
public function testPasswordReset()
{
$this->browse(function (Browser $browser) {
$browser
->visit(new Login)
->pause(500)
->click('@forgotPasswordLink');
$browser
->on(new ForgotPassword)
->type('@loginField', 'admin')
->click('@submitButton');
$browser
->on(new Login)
->waitFor('.flash-message')
->assertSeeIn('.flash-message', 'Message sent to your email address');
});
}
}

View File

@ -1,300 +0,0 @@
<?php namespace October\Core\Tests\Browser\Backend\Cms;
use Laravel\Dusk\Browser;
use October\Core\Tests\Browser\Pages\Backend\Cms;
class TemplateTest extends \October\Core\Tests\BrowserTestCase
{
public function testPageTemplates()
{
$this->browse(function (Browser $browser) {
$browser
->signInToBackend()
->visit(new Cms)
->pause(200);
// Fix side panel, if necessary
if ($browser->hasClass('', 'side-panel-not-fixed')) {
$browser
->mouseover('@sideNav > li[data-menu-item="pages"]')
->waitFor('@sidePanel')
->mouseover('@sidePanel')
->waitFor('@sidePanelFixButton')
->click('@sidePanelFixButton');
}
// Add a new page
$browser
->click('form[data-template-type="page"] button[data-control="create-template"]')
->waitFor('#cms-master-tabs .tab-content .tab-pane');
$tabId = $browser->attribute('#cms-master-tabs .tab-content .tab-pane', 'id');
$browser->assertPresent('a[data-toggle="tab"][data-target="#' . $tabId . '"]');
$this->assertEquals('New page', $browser->text('a[data-toggle="tab"][data-target="#' . $tabId . '"]'));
$browser
->type('input[name="settings[title]"]', 'Functional Test Page')
->pause(100)
// Check that slug values are working
->assertInputValue('input[name="settings[url]"]', '/functional-test-page')
->assertInputValue('input[name="fileName"]', 'functional-test-page')
->clear('input[name="settings[url]"]')
->type('input[name="settings[url]"]', '/xxx/functional/test/page')
->clear('input[name="fileName"]')
->type('input[name="fileName"]', 'xxx_functional_test_page.htm')
// Check that slug values have not been re-added after manual entry
->assertInputValue('input[name="settings[url]"]', '/xxx/functional/test/page')
->assertInputValue('input[name="fileName"]', 'xxx_functional_test_page.htm');
// Save the new page
$browser
->click('a[data-request="onSave"]')
->waitFor('.flash-message')
->assertSeeIn('.flash-message', 'Template saved.');
$this->assertEquals(
'Functional Test Page',
$browser->attribute('a[data-toggle="tab"][data-target="#' . $tabId . '"] span.title', 'title')
);
// Close the tab
$browser
->click('li[data-tab-id^="page-"][data-tab-id$="-xxx_functional_test_page.htm"] span.tab-close')
->pause(100)
->assertMissing('#cms-master-tabs .tab-content .tab-pane');
// Re-open the page
$browser
->click('div#TemplateList-pageList-template-list li[data-item-path="xxx_functional_test_page.htm"] a')
->waitFor('#cms-master-tabs .tab-content .tab-pane')
// Check that saved details are still there
->assertInputValue('input[name="settings[title]"]', 'Functional Test Page')
->assertInputValue('input[name="settings[url]"]', '/xxx/functional/test/page')
->assertInputValue('input[name="fileName"]', 'xxx_functional_test_page.htm');
// Delete the page
$browser
->click('button[data-request="onDelete"]')
->waitFor('.sweet-alert.showSweetAlert.visible')
->pause(300)
->click('.sweet-alert.showSweetAlert.visible button.confirm')
->waitUntilMissing('div#TemplateList-pageList-template-list li[data-item-path="xxx_functional_test_page.htm"]');
});
}
public function testPartialTemplates()
{
$this->browse(function (Browser $browser) {
$browser
->signInToBackend()
->visit(new Cms)
->pause(200);
// Fix side panel, if necessary
if ($browser->hasClass('', 'side-panel-not-fixed')) {
$browser
->mouseover('@sideNav > li[data-menu-item="pages"]')
->waitFor('@sidePanel')
->mouseover('@sidePanel')
->waitFor('@sidePanelFixButton')
->click('@sidePanelFixButton');
}
$browser
->click('@sideNav > li[data-menu-item="partials"] a');
// Add a new partial
$browser
->click('form[data-template-type="partial"] button[data-control="create-template"]')
->waitFor('#cms-master-tabs .tab-content .tab-pane');
$tabId = $browser->attribute('#cms-master-tabs .tab-content .tab-pane', 'id');
$browser->assertPresent('a[data-toggle="tab"][data-target="#' . $tabId . '"]');
$this->assertEquals('New partial', $browser->text('a[data-toggle="tab"][data-target="#' . $tabId . '"]'));
$browser
->type('input[name="fileName"]', 'xxx_functional_test_partial')
->type('input[name="settings[description]"]', 'Test Partial');
// Save the new partial
$browser
->click('a[data-request="onSave"]')
->waitFor('.flash-message')
->assertSeeIn('.flash-message', 'Template saved.');
$this->assertEquals(
'xxx_functional_test_partial',
$browser->attribute('a[data-toggle="tab"][data-target="#' . $tabId . '"] span.title', 'title')
);
// Close the tab
$browser
->click('li[data-tab-id^="partial-"][data-tab-id$="-xxx_functional_test_partial.htm"] span.tab-close')
->pause(100)
->assertMissing('#cms-master-tabs .tab-content .tab-pane');
// Re-open the partial
$browser
->click('div#TemplateList-partialList-template-list li[data-item-path="xxx_functional_test_partial.htm"] a')
->waitFor('#cms-master-tabs .tab-content .tab-pane')
// Check that saved details are still there
->assertInputValue('input[name="fileName"]', 'xxx_functional_test_partial.htm')
->assertInputValue('input[name="settings[description]"]', 'Test Partial');
// Delete the partial
$browser
->click('button[data-request="onDelete"]')
->waitFor('.sweet-alert.showSweetAlert.visible')
->pause(300)
->click('.sweet-alert.showSweetAlert.visible button.confirm')
->waitUntilMissing('div#TemplateList-partialList-template-list li[data-item-path="xxx_functional_test_partial.htm"]');
});
}
public function testLayoutTemplates()
{
$this->browse(function (Browser $browser) {
$browser
->signInToBackend()
->visit(new Cms)
->pause(200);
// Fix side panel, if necessary
if ($browser->hasClass('', 'side-panel-not-fixed')) {
$browser
->mouseover('@sideNav > li[data-menu-item="pages"]')
->waitFor('@sidePanel')
->mouseover('@sidePanel')
->waitFor('@sidePanelFixButton')
->click('@sidePanelFixButton');
}
$browser
->click('@sideNav > li[data-menu-item="layouts"] a');
// Add a new layout
$browser
->click('form[data-template-type="layout"] button[data-control="create-template"]')
->waitFor('#cms-master-tabs .tab-content .tab-pane');
$tabId = $browser->attribute('#cms-master-tabs .tab-content .tab-pane', 'id');
$browser->assertPresent('a[data-toggle="tab"][data-target="#' . $tabId . '"]');
$this->assertEquals('New layout', $browser->text('a[data-toggle="tab"][data-target="#' . $tabId . '"]'));
$browser
->type('input[name="fileName"]', 'xxx_functional_test_layout')
->type('input[name="settings[description]"]', 'Test Layout');
// Save the new layout
$browser
->click('a[data-request="onSave"]')
->waitFor('.flash-message')
->assertSeeIn('.flash-message', 'Template saved.');
$this->assertEquals(
'xxx_functional_test_layout',
$browser->attribute('a[data-toggle="tab"][data-target="#' . $tabId . '"] span.title', 'title')
);
// Close the tab
$browser
->click('li[data-tab-id^="layout-"][data-tab-id$="-xxx_functional_test_layout.htm"] span.tab-close')
->pause(100)
->assertMissing('#cms-master-tabs .tab-content .tab-pane');
// Re-open the partial
$browser
->click('div#TemplateList-layoutList-template-list li[data-item-path="xxx_functional_test_layout.htm"] a')
->waitFor('#cms-master-tabs .tab-content .tab-pane')
// Check that saved details are still there
->assertInputValue('input[name="fileName"]', 'xxx_functional_test_layout.htm')
->assertInputValue('input[name="settings[description]"]', 'Test Layout');
// Delete the partial
$browser
->click('button[data-request="onDelete"]')
->waitFor('.sweet-alert.showSweetAlert.visible')
->pause(300)
->click('.sweet-alert.showSweetAlert.visible button.confirm')
->waitUntilMissing('div#TemplateList-layoutList-template-list li[data-item-path="xxx_functional_test_layout.htm"]');
});
}
public function testContentTemplates()
{
$this->browse(function (Browser $browser) {
$browser
->signInToBackend()
->visit(new Cms)
->pause(200);
// Fix side panel, if necessary
if ($browser->hasClass('', 'side-panel-not-fixed')) {
$browser
->mouseover('@sideNav > li[data-menu-item="pages"]')
->waitFor('@sidePanel')
->mouseover('@sidePanel')
->waitFor('@sidePanelFixButton')
->click('@sidePanelFixButton');
}
$browser
->click('@sideNav > li[data-menu-item="content"] a');
// Add a new content file
$browser
->click('form[data-template-type="content"] button[data-control="create-template"]')
->waitFor('#cms-master-tabs .tab-content .tab-pane');
$tabId = $browser->attribute('#cms-master-tabs .tab-content .tab-pane', 'id');
$browser->assertPresent('a[data-toggle="tab"][data-target="#' . $tabId . '"]');
$this->assertStringContainsString('content', $browser->text('a[data-toggle="tab"][data-target="#' . $tabId . '"]'));
$browser
->type('input[name="fileName"]', 'xxx_functional_test_content.txt');
// Save the new content file
$browser
->click('a[data-request="onSave"]')
->waitFor('.flash-message')
->assertSeeIn('.flash-message', 'Template saved.');
$this->assertEquals(
'xxx_functional_test_content.txt',
$browser->attribute('a[data-toggle="tab"][data-target="#' . $tabId . '"] span.title', 'title')
);
// Close the tab
$browser
->click('li[data-tab-id^="content-"][data-tab-id$="-xxx_functional_test_content.txt"] span.tab-close')
->pause(100)
->assertMissing('#cms-master-tabs .tab-content .tab-pane');
// Re-open the partial
$browser
->click('div#TemplateList-contentList-template-list li[data-item-path="xxx_functional_test_content.txt"] a')
->waitFor('#cms-master-tabs .tab-content .tab-pane')
// Check that saved details are still there
->assertInputValue('input[name="fileName"]', 'xxx_functional_test_content.txt');
// Delete the partial
$browser
->click('button[data-request="onDelete"]')
->waitFor('.sweet-alert.showSweetAlert.visible')
->pause(300)
->click('.sweet-alert.showSweetAlert.visible button.confirm')
->waitUntilMissing('div#TemplateList-contentList-template-list li[data-item-path="xxx_functional_test_content.txt"]');
});
}
}

View File

@ -1,32 +0,0 @@
<?php namespace October\Core\Tests\Browser\Pages\Backend;
use Laravel\Dusk\Browser;
use October\Core\Tests\Browser\Pages\BackendPage;
class Cms extends BackendPage
{
/**
* Get the URL for the page.
*
* @return string
*/
public function url()
{
return '/backend/cms';
}
/**
* Assert that the browser is on the page.
*
* @param \Laravel\Dusk\Browser $browser
* @return void
*/
public function assert(Browser $browser)
{
$browser
->assertTitleContains('CMS |')
->assertPresent('@mainMenu')
->assertPresent('@sideNav')
->assertPresent('@accountMenu');
}
}

View File

@ -1,33 +0,0 @@
<?php namespace October\Core\Tests\Browser\Pages\Backend;
use Laravel\Dusk\Browser;
use October\Core\Tests\Browser\Pages\BackendPage;
class Dashboard extends BackendPage
{
/**
* Get the URL for the page.
*
* @return string
*/
public function url()
{
return '/backend';
}
/**
* Assert that the browser is on the page.
*
* @param \Laravel\Dusk\Browser $browser
* @return void
*/
public function assert(Browser $browser)
{
$browser
->assertTitleContains('Dashboard |')
->assertPresent('@mainMenu')
->assertPresent('@accountMenu')
->waitFor('.report-widget')
->assertSee('Welcome');
}
}

View File

@ -1,48 +0,0 @@
<?php namespace October\Core\Tests\Browser\Pages\Backend;
use Laravel\Dusk\Browser;
use October\Core\Tests\Browser\Pages\Page;
class ForgotPassword extends Page
{
/**
* Get the URL for the page.
*
* @return string
*/
public function url()
{
return '/backend/backend/auth/restore';
}
/**
* Assert that the browser is on the page.
*
* @param \Laravel\Dusk\Browser $browser
* @return void
*/
public function assert(Browser $browser)
{
$browser
->assertTitle('Administration Area')
->assertPresent('@loginField')
->assertMissing('input[name="password"]')
->assertPresent('@submitButton')
->assertPresent('@cancelLink')
->assertSeeIn('@submitButton', 'Restore');
}
/**
* Get the global element shortcuts for the site.
*
* @return array
*/
public function elements()
{
return [
'@loginField' => 'input[name="login"]',
'@submitButton' => 'button[type="submit"]',
'@cancelLink' => 'p.forgot-password > a',
];
}
}

View File

@ -1,49 +0,0 @@
<?php namespace October\Core\Tests\Browser\Pages\Backend;
use Laravel\Dusk\Browser;
use October\Core\Tests\Browser\Pages\Page;
class Login extends Page
{
/**
* Get the URL for the page.
*
* @return string
*/
public function url()
{
return '/backend/backend/auth/signin';
}
/**
* Assert that the browser is on the page.
*
* @param \Laravel\Dusk\Browser $browser
* @return void
*/
public function assert(Browser $browser)
{
$browser
->assertTitle('Administration Area')
->assertPresent('@loginField')
->assertPresent('@passwordField')
->assertPresent('@submitButton')
->assertPresent('@forgotPasswordLink')
->assertSeeIn('@submitButton', 'Login');
}
/**
* Get the global element shortcuts for the site.
*
* @return array
*/
public function elements()
{
return [
'@loginField' => 'input[name="login"]',
'@passwordField' => 'input[name="password"]',
'@submitButton' => 'button[type="submit"]',
'@forgotPasswordLink' => 'p.forgot-password > a',
];
}
}

View File

@ -1,21 +0,0 @@
<?php namespace October\Core\Tests\Browser\Pages;
abstract class BackendPage extends Page
{
/**
* Get the global element shortcuts for the site.
*
* @return array
*/
public static function siteElements()
{
return [
'@mainMenu' => '#layout-mainmenu',
'@accountMenu' => '#layout-mainmenu .mainmenu-account > a',
'@sideNav' => '#layout-sidenav > ul',
'@sidePanel' => '#layout-side-panel',
'@sidePanelFixButton' => '#layout-side-panel a.fix-button',
];
}
}

View File

@ -1,16 +0,0 @@
<?php namespace October\Core\Tests\Browser\Pages;
use Laravel\Dusk\Page as BasePage;
abstract class Page extends BasePage
{
/**
* Get the global element shortcuts for the site.
*
* @return array
*/
public static function siteElements()
{
return [];
}
}

View File

@ -1,2 +0,0 @@
*
!.gitignore

View File

@ -1,2 +0,0 @@
*
!.gitignore

View File

@ -1,147 +0,0 @@
<?php namespace October\Core\Tests;
use Facebook\WebDriver\Chrome\ChromeOptions;
use Facebook\WebDriver\Remote\RemoteWebDriver;
use Facebook\WebDriver\Remote\DesiredCapabilities;
use Laravel\Dusk\Browser;
use Laravel\Dusk\TestCase as DuskTestCase;
use October\Core\Tests\Browser\Pages\Backend\Dashboard;
use October\Core\Tests\Browser\Pages\Backend\Login;
use October\Core\Tests\Concerns\CreatesApplication;
use October\Core\Tests\Concerns\InteractsWithAuthentication;
use October\Core\Tests\Concerns\RunsMigrations;
use October\Core\Tests\Concerns\TestsPlugins;
abstract class BrowserTestCase extends DuskTestCase
{
use CreatesApplication;
use InteractsWithAuthentication;
use RunsMigrations;
use TestsPlugins;
/**
* Prepare for Dusk test execution.
*
* @beforeClass
* @return void
*/
public static function prepare()
{
static::startChromeDriver();
}
/**
* Create the RemoteWebDriver instance.
*
* @return \Facebook\WebDriver\Remote\RemoteWebDriver
*/
protected function driver()
{
$options = (new ChromeOptions)->addArguments([
'--disable-gpu',
'--headless',
'--window-size=1920,1080',
]);
return RemoteWebDriver::create(
'http://localhost:9515',
DesiredCapabilities::chrome()->setCapability(
ChromeOptions::CAPABILITY,
$options
)
);
}
public function setUp(): void
{
$this->resetManagers();
parent::setUp();
// Ensure system is up to date
if ($this->usingTestDatabase) {
$this->runOctoberUpCommand();
}
// Detect a plugin and autoload it, if necessary
$this->detectPlugin();
// Disable mailer
\Mail::pretend();
Browser::$baseUrl = $this->baseUrl();
Browser::$storeScreenshotsAt = base_path('tests/Browser/screenshots');
Browser::$storeConsoleLogAt = base_path('tests/Browser/console');
Browser::$userResolver = function () {
return $this->user();
};
$this->setupMacros();
}
public function tearDown(): void
{
if ($this->usingTestDatabase && isset($this->testDatabasePath)) {
unlink($this->testDatabasePath);
}
parent::tearDown();
}
/**
* Defines October macros for use in browser tests
*
* @return void
*/
protected function setupMacros()
{
/**
* Signs the user into the backend
*/
Browser::macro('signInToBackend', function (string $username = null, string $password = null) {
$username = $username ?? env('DUSK_ADMIN_USER', 'admin');
$password = $password ?? env('DUSK_ADMIN_PASS', 'admin1234');
$this
->visit(new Login)
->pause(500)
->type('@loginField', $username)
->type('@passwordField', $password)
->click('@submitButton');
$this->
on(new Dashboard);
return $this;
});
Browser::macro('hasClass', function (string $selector, string $class) {
$classes = preg_split('/\s+/', $this->attribute($selector, 'class'), -1, PREG_SPLIT_NO_EMPTY);
if (empty($classes)) {
return false;
}
return in_array($class, $classes);
});
}
/**
* Similar to the native getConfirmation() function
*/
protected function getSweetConfirmation($expectedText = null, $clickOk = true)
{
$this->waitForElementPresent("xpath=(//div[@class='sweet-alert showSweetAlert visible'])[1]");
if ($expectedText) {
$this->verifyText("//div[@class='sweet-alert showSweetAlert visible']//h4", $expectedText);
}
$this->verifyText("//div[@class='sweet-alert showSweetAlert visible']//button[@class='confirm btn btn-primary']", "OK");
if ($clickOk) {
$this->click("xpath=(//div[@class='sweet-alert showSweetAlert visible']//button[@class='confirm btn btn-primary'])[1]");
}
}
}

View File

@ -1,98 +0,0 @@
<?php namespace October\Core\Tests\Concerns;
use Config;
use Backend\Classes\AuthManager;
trait CreatesApplication
{
/**
* Determines if a test SQLite database is being used
*
* @var boolean
*/
protected $usingTestDatabase = false;
/**
* The test SQLite database in use
*
* @var string
*/
protected $testDatabasePath;
/**
* Creates the application.
*
* @return \Illuminate\Foundation\Application
*/
public function createApplication()
{
$app = require __DIR__ . '/../../bootstrap/app.php';
$app->make('Illuminate\Contracts\Console\Kernel')->bootstrap();
$app['cache']->setDefaultDriver('array');
$app->setLocale('en');
$app->singleton('auth', function ($app) {
$app['auth.loaded'] = true;
return AuthManager::instance();
});
// Use test database configuration, unless overriden
$dbConnection = Config::get('database.default', 'sqlite');
$dbConnections = [
$dbConnection => Config::get('database.connections.' . $dbConnection, [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
])
];
if (env('APP_ENV') === 'testing' && !Config::get('database.useConfigForTesting', false)) {
$this->usingTestDatabase = true;
$dbConnection = 'sqlite';
$dbConnections = [
'sqlite' => [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
],
];
} elseif (env('APP_ENV') === 'dusk' && !Config::get('database.useConfigForTesting', false)) {
$this->usingTestDatabase = true;
$dbConnection = 'sqlite';
$dbConnections = [
'sqlite' => [
'driver' => 'sqlite',
'database' => 'storage/dusk.sqlite',
'prefix' => '',
],
];
// Ensure a fresh copy of the SQLite database is made
$this->testDatabasePath = base_path('storage/dusk.sqlite');
if (file_exists($this->testDatabasePath)) {
unlink($this->testDatabasePath);
}
touch($this->testDatabasePath);
}
$app['config']->set('database.default', $dbConnection);
$app['config']->set('database.connections.' . $dbConnection, $dbConnections[$dbConnection]);
/**
* Prevent mail from being sent out
*/
$app['config']->set('mail.driver', 'array');
/**
* Modify the plugin path away from the test context
*/
$app->setPluginsPath(realpath(base_path() . Config::get('cms.pluginsPath')));
return $app;
}
}

View File

@ -1,14 +0,0 @@
<?php namespace October\Core\Tests\Concerns;
trait RunsMigrations
{
protected function runOctoberUpCommand()
{
\Artisan::call('october:up');
}
protected function runOctoberDownCommand()
{
\Artisan::call('october:down --force');
}
}

View File

@ -1,108 +0,0 @@
<?php namespace October\Core\Tests\Concerns;
use System\Classes\UpdateManager;
use System\Classes\PluginManager;
trait TestsPlugins
{
/**
* @var array Cache for storing which plugins have been loaded
* and refreshed.
*/
protected $pluginTestCaseLoadedPlugins = [];
public function resetManagers(): void
{
PluginManager::forgetInstance();
UpdateManager::forgetInstance();
}
/**
* Detects the current plugin based on the namespace, when running tests within a plugin.
*
* @return void
*/
public function detectPlugin(): void
{
$this->pluginTestCaseLoadedPlugins = [];
$pluginCode = $this->guessPluginCodeFromTest();
if ($pluginCode !== false) {
$this->runPluginRefreshCommand($pluginCode, false);
}
}
/**
* Locates the plugin code based on the test file location.
*
* @return string|bool
*/
protected function guessPluginCodeFromTest()
{
$reflect = new \ReflectionClass($this);
$path = $reflect->getFilename();
$basePath = $this->app->pluginsPath();
$result = false;
if (strpos($path, $basePath) === 0) {
$result = ltrim(str_replace('\\', '/', substr($path, strlen($basePath))), '/');
$result = implode('.', array_slice(explode('/', $result), 0, 2));
}
return $result;
}
/**
* Runs a refresh command on a plugin.
*
* Since the test environment has loaded all the test plugins
* natively, this method will ensure the desired plugin is
* loaded in the system before proceeding to migrate it.
*
* @return void
*/
protected function runPluginRefreshCommand($code, $throwException = true): void
{
if (!preg_match('/^[\w+]*\.[\w+]*$/', $code)) {
if (!$throwException) {
return;
}
throw new \Exception(sprintf('Invalid plugin code: "%s"', $code));
}
$manager = PluginManager::instance();
$plugin = $manager->findByIdentifier($code);
// First time seeing this plugin, load it up
if (!$plugin) {
$namespace = '\\'.str_replace('.', '\\', strtolower($code));
$path = array_get($manager->getPluginNamespaces(), $namespace);
if (!$path) {
if (!$throwException) {
return;
}
throw new \Exception(sprintf('Unable to find plugin with code: "%s"', $code));
}
$plugin = $manager->loadPlugin($namespace, $path);
}
// Spin over dependencies and refresh them too
$this->pluginTestCaseLoadedPlugins[$code] = $plugin;
if (!empty($plugin->require)) {
foreach ((array) $plugin->require as $dependency) {
if (isset($this->pluginTestCaseLoadedPlugins[$dependency])) {
continue;
}
$this->runPluginRefreshCommand($dependency);
}
}
// Execute the command
\Artisan::call('plugin:refresh', ['name' => $code]);
}
}

View File

@ -1,17 +1,67 @@
<?php namespace October\Core\Tests; <?php
use Backend\Classes\AuthManager;
use System\Classes\UpdateManager;
use System\Classes\PluginManager;
use October\Rain\Database\Model as ActiveRecord; use October\Rain\Database\Model as ActiveRecord;
use October\Core\Tests\Concerns\CreatesApplication; use October\Tests\Concerns\InteractsWithAuthentication;
use October\Core\Tests\Concerns\InteractsWithAuthentication;
use October\Core\Tests\Concerns\RunsMigrations;
use October\Core\Tests\Concerns\TestsPlugins;
abstract class PluginTestCase extends TestCase abstract class PluginTestCase extends TestCase
{ {
use CreatesApplication;
use InteractsWithAuthentication; use InteractsWithAuthentication;
use RunsMigrations;
use TestsPlugins; /**
* @var array Cache for storing which plugins have been loaded
* and refreshed.
*/
protected $pluginTestCaseLoadedPlugins = [];
/**
* Creates the application.
* @return Symfony\Component\HttpKernel\HttpKernelInterface
*/
public function createApplication()
{
$app = require __DIR__.'/../bootstrap/app.php';
$app->make('Illuminate\Contracts\Console\Kernel')->bootstrap();
$app['cache']->setDefaultDriver('array');
$app->setLocale('en');
$app->singleton('auth', function ($app) {
$app['auth.loaded'] = true;
return AuthManager::instance();
});
/*
* Store database in memory by default, if not specified otherwise
*/
$dbConnection = 'sqlite';
$dbConnections = [];
$dbConnections['sqlite'] = [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => ''
];
if (env('APP_ENV') === 'testing' && Config::get('database.useConfigForTesting', false)) {
$dbConnection = Config::get('database.default', 'sqlite');
$dbConnections[$dbConnection] = Config::get('database.connections' . $dbConnection, $dbConnections['sqlite']);
}
$app['config']->set('database.default', $dbConnection);
$app['config']->set('database.connections.' . $dbConnection, $dbConnections[$dbConnection]);
/*
* Modify the plugin path away from the test context
*/
$app->setPluginsPath(realpath(base_path().Config::get('cms.pluginsPath')));
return $app;
}
/** /**
* Perform test case set up. * Perform test case set up.
@ -19,21 +69,36 @@ abstract class PluginTestCase extends TestCase
*/ */
public function setUp() : void public function setUp() : void
{ {
$this->resetManagers(); /*
* Force reload of October singletons
*/
PluginManager::forgetInstance();
UpdateManager::forgetInstance();
// Create application /*
* Create application instance
*/
parent::setUp(); parent::setUp();
// Ensure system is up to date /*
if ($this->usingTestDatabase) { * Ensure system is up to date
*/
$this->runOctoberUpCommand(); $this->runOctoberUpCommand();
/*
* Detect plugin from test and autoload it
*/
$this->pluginTestCaseLoadedPlugins = [];
$pluginCode = $this->guessPluginCodeFromTest();
if ($pluginCode !== false) {
$this->runPluginRefreshCommand($pluginCode, false);
} }
// Detect a plugin and autoload it, if necessary /*
$this->detectPlugin(); * Disable mailer
*/
// Disable mailer Mail::pretend();
\Mail::pretend();
} }
/** /**
@ -43,8 +108,88 @@ abstract class PluginTestCase extends TestCase
public function tearDown() : void public function tearDown() : void
{ {
$this->flushModelEventListeners(); $this->flushModelEventListeners();
parent::tearDown(); parent::tearDown();
unset($this->app);
}
/**
* Migrate database using october:up command.
* @return void
*/
protected function runOctoberUpCommand()
{
Artisan::call('october:up');
}
/**
* Since the test environment has loaded all the test plugins
* natively, this method will ensure the desired plugin is
* loaded in the system before proceeding to migrate it.
* @return void
*/
protected function runPluginRefreshCommand($code, $throwException = true)
{
if (!preg_match('/^[\w+]*\.[\w+]*$/', $code)) {
if (!$throwException) {
return;
}
throw new Exception(sprintf('Invalid plugin code: "%s"', $code));
}
$manager = PluginManager::instance();
$plugin = $manager->findByIdentifier($code);
/*
* First time seeing this plugin, load it up
*/
if (!$plugin) {
$namespace = '\\'.str_replace('.', '\\', strtolower($code));
$path = array_get($manager->getPluginNamespaces(), $namespace);
if (!$path) {
if (!$throwException) {
return;
}
throw new Exception(sprintf('Unable to find plugin with code: "%s"', $code));
}
$plugin = $manager->loadPlugin($namespace, $path);
}
/*
* Spin over dependencies and refresh them too
*/
$this->pluginTestCaseLoadedPlugins[$code] = $plugin;
if (!empty($plugin->require)) {
foreach ((array) $plugin->require as $dependency) {
if (isset($this->pluginTestCaseLoadedPlugins[$dependency])) {
continue;
}
$this->runPluginRefreshCommand($dependency);
}
}
/*
* Execute the command
*/
Artisan::call('plugin:refresh', ['name' => $code]);
}
/**
* Returns a plugin object from its code, useful for registering events, etc.
* @return PluginBase
*/
protected function getPluginObject($code = null)
{
if ($code === null) {
$code = $this->guessPluginCodeFromTest();
}
if (isset($this->pluginTestCaseLoadedPlugins[$code])) {
return $this->pluginTestCaseLoadedPlugins[$code];
}
} }
/** /**
@ -60,7 +205,7 @@ abstract class PluginTestCase extends TestCase
continue; continue;
} }
$reflectClass = new \ReflectionClass($class); $reflectClass = new ReflectionClass($class);
if ( if (
!$reflectClass->isInstantiable() || !$reflectClass->isInstantiable() ||
!$reflectClass->isSubclassOf('October\Rain\Database\Model') || !$reflectClass->isSubclassOf('October\Rain\Database\Model') ||
@ -74,4 +219,24 @@ abstract class PluginTestCase extends TestCase
ActiveRecord::flushEventListeners(); ActiveRecord::flushEventListeners();
} }
/**
* Locates the plugin code based on the test file location.
* @return string|bool
*/
protected function guessPluginCodeFromTest()
{
$reflect = new ReflectionClass($this);
$path = $reflect->getFilename();
$basePath = $this->app->pluginsPath();
$result = false;
if (strpos($path, $basePath) === 0) {
$result = ltrim(str_replace('\\', '/', substr($path, strlen($basePath))), '/');
$result = implode('.', array_slice(explode('/', $result), 0, 2));
}
return $result;
}
} }

View File

@ -1,131 +1,13 @@
# Testing # Plugin testing
October CMS has a suite of tools available for running automated tests on your October instance and plugins. To run tests, you must ensure that you have PHPUnit installed and can run the `phpunit` command from a command-line interface. Plugin unit tests can be performed by running `phpunit` in the base plugin directory.
--- ### Creating plugin tests
- [System Tests](#system-tests) Plugins can be tested by creating a file called `phpunit.xml` in the base directory with the following content, for example, in a file **/plugins/acme/blog/phpunit.xml**:
- [Unit Tests](#unit-tests)
- [Using a Custom Database Engine](#custom-database-engine)
- [Browser Tests](#browser-tests)
- [Testing Environment for Browser Tests](#testing-environment)
- [JavaScript Tests](#javascript-tests)
- [Creating Tests for Plugins](#creating-plugin-tests)
- [Unit Tests](#plugin-unit-tests)
- [Browser Tests](#plugin-browser-tests)
---
<a name="system-tests"></a>
## System Tests
The system tests cover the tests that analyse the core functionality of October CMS. To run these tests, we recommend that you use Git to checkout a copy of the development version of October CMS and use Composer to install all necessary dependencies.
You can do this on command-line by simply running the following:
```bash
git checkout git@github.com:octobercms/october.git
cd october
composer install
```
<a name="unit-tests"></a>
### Unit Tests
The unit tests in October CMS can be found in the **tests/unit** folder and are executed through PHPUnit. You can run the tests by running the following command in the root folder of the October CMS installation:
```bash
./vendor/bin/phpunit
```
This will run tests for both October CMS and the Rain library. The Rain library tests can be found in the **vendor/october/rain/tests** folder.
Note that unit tests run in a special environment called `testing`. You may configure this environment by adding or modifying the configuration files in the **config/testing/** directory.
<a name="custom-database-engine"></a>
#### Using a Custom Database Engine
By default, OctoberCMS uses SQLite stored in memory for the `testing` environment. If you wish to override this with your own database configuration, set the `useConfigForTesting` config to `true` in your `/config/database.php` file.
When the `APP_ENV` is `testing` and the `useConfigForTesting` is `true` database parameters will be taken from `/config/database.php`.
You can override the `/config/database.php` file by creating `/config/testing/database.php`. In this case variables from the latter file will be taken.
<a name="browser-tests"></a>
### Browser Tests
Browsers tests are a more flexible type of automated test that run directly in a web browser. October CMS leverages the [Laravel Dusk](https://laravel.com/docs/6.x/dusk) framework to run these tests, which in turn uses Google Chrome and a ChromeDriver install to run the tests.
Running the browser tests will require Google Chrome to be installed on your machine. Once this is done, you may prepare your installation for running Browser tests by running the following in your project root folder:
```bash
php artisan dusk:chrome-driver
```
> **Note:** It is possible to use other browsers, or a standalone Selenium server, if you wish. Please see the [Laravel Dusk documentation](https://laravel.com/docs/6.x/dusk#using-other-browsers) for more information.
Once installed, you may run the browsers test by simply running the following command in the root folder of the October CMS installation:
```bash
php artisan dusk
```
If you have previously run the browser tests and want to re-run only the tests that failed, you may use this shortcut to run just the failed tests:
```bash
php artisan dusk:fails
```
Note that your October CMS installation must be web-accessible in order to run the browser tests. Please review the next section on setting up the testing environment.
<a name="testing-environment"></a>
#### Testing Environment for Browser Tests
The Browser tests in October CMS are, by default, set up to run within a special testing environment called `dusk`. This is configured to run October CMS via the inbuilt PHP web server, using an SQLite database to store the database temporarily.
You may start this web server before running the browser tests simply by running the following:
```bash
php artisan serve
```
This environment is configured in two places: the **.env.dusk** file available in the project root, and within the **config/dusk/** folder. You may modify either of these configuration files in order to configure the testing environment to your requirements.
When the browser tests are started, the **.env** file in your project (if any) is subtituted with **.env.dusk** for the duration of the tests. Once the tests end, the **.env** file is restored to its original content.
> **Note:** The system browser tests will need to be authenticated with a superuser-level user to run correctly. If you are using the default environment, this will happen automatically.<br><br>If you are custom settings however, you may need to provide authentication information to Dusk in order for it to run. You can specify the environment variables `DUSK_ADMIN_USER` and `DUSK_ADMIN_PASS` to use specific authentication credentials during testing. These are available in the `.env.dusk` file.
<a name="javascript-tests"></a>
### JavaScript Tests
In addition to the PHP-based tests above, we also have a suite of unit tests for our JavaScript libraries and functions. These run on an NodeJS-based environment, so you will need to [download and install](https://nodejs.org/en/download/) NodeJS and NPM in order to install the tools required for these tests.
Once installed, you may install the tools by running the following in the browser root:
```bash
npm install
```
Then, you may run the following command to run the JavaScript tests:
```bash
npm run test
```
<a name="creating-plugin-tests"></a>
## Creating Tests for Plugins
October CMS has made it easy for plugin developers to create unit and browser tests for their plugins.
Please read the sections below in order to configure your plugin for your required types of testing.
<a name="plugin-unit-tests"></a>
### Unit Tests
To allow unit testing in your plugin, you must first create a file called `phpunit.xml` in the plugin base directory with the following content - for example, in a file **/plugins/acme/blog/phpunit.xml**:
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit <phpunit backupGlobals="false"
backupGlobals="false"
backupStaticAttributes="false" backupStaticAttributes="false"
bootstrap="../../../tests/bootstrap.php" bootstrap="../../../tests/bootstrap.php"
colors="true" colors="true"
@ -134,10 +16,11 @@ To allow unit testing in your plugin, you must first create a file called `phpun
convertWarningsToExceptions="true" convertWarningsToExceptions="true"
processIsolation="false" processIsolation="false"
stopOnFailure="false" stopOnFailure="false"
syntaxCheck="false"
> >
<testsuites> <testsuites>
<testsuite name="Plugin Unit Test Suite"> <testsuite name="Plugin Unit Test Suite">
<directory>./tests/unit</directory> <directory>./tests</directory>
</testsuite> </testsuite>
</testsuites> </testsuites>
<php> <php>
@ -147,56 +30,31 @@ To allow unit testing in your plugin, you must first create a file called `phpun
</php> </php>
</phpunit> </phpunit>
Then you may create a **tests/unit/** directory to contain the unit test classes. Then a **tests/** directory can be created to contain the test classes. The file structure should mimic the base directory with classes having a `Test` suffix. Using a namespace for the class is also recommended.
Each unit test class file must match the following guidelines: <?php namespace Acme\Blog\Tests\Models;
- Each file can be any number of folder levels deep, but must end with `Test.php`. use Acme\Blog\Models\Post;
- Each test class must have a namespace that follows both your plugin name as well as the folder location of your test. use PluginTestCase;
- Each test class must extend the `October\Core\Tests\PluginTestCase` class.
For example, if you have a plugin `Acme.Blog` that contained a `Post` model that you wanted to test, you would create the test class file in **tests/unit/models/PostTest.php**, with the test class code containing the following: class PostTest extends PluginTestCase
{
```php
<?php namespace Acme\Blog\Tests\Unit\Models;
use Acme\Blog\Models\Post;
use October\Core\Tests\PluginTestCase;
class PostTest extends PluginTestCase
{
public function testCreateFirstPost() public function testCreateFirstPost()
{ {
$post = Post::create(['title' => 'Hi!']); $post = Post::create(['title' => 'Hi!']);
$this->assertEquals(1, $post->id); $this->assertEquals(1, $post->id);
} }
} }
```
The `October\Core\Tests\PluginTestCase` class takes care of ensuring that you have a clean database for each test, in order to run each test in isolation. If you need to run some code before, or after each test, you may overwrite the `setUp` and `tearDown` methods in your class. It is important, however, that you allow the parent methods to run too. The test class should extend the base class `PluginTestCase` and this is a special class that will set up the October database stored in memory, as part of the `setUp` method. It will also refresh the plugin being tested, along with any of the defined dependencies in the plugin registration file. This is the equivalent of running the following before each test:
```php php artisan october:up
public function setUp(): void php artisan plugin:refresh Acme.Blog
{ [php artisan plugin:refresh <dependency>, ...]
parent::setUp();
// Load necessary model fixture > **Note:** If your plugin uses [configuration files](../plugin/settings#file-configuration), then you will need to run `System\Classes\PluginManager::instance()->registerAll(true);` in the `setUp` method of your tests. Below is an example of a base test case class that should be used if you need to test your plugin working with other plugins instead of in isolation.
$this->postFixture = PostFixture::create(['title' => 'Test Post']);
}
public function tearDown(): void
{
// Remove model fixtur
unset($this->postFixture);
parent::tearDown();
}
```
> **Note:** If your plugin uses [configuration files](../plugin/settings#file-configuration), then you will need to run `System\Classes\PluginManager::instance()->registerAll(true);` in the `setUp` method of your tests.<br><br>Below is an example of a base test case class that should be used if you need to test your plugin working with other plugins instead of in isolation.
use System\Classes\PluginManager; use System\Classes\PluginManager;
use October\Core\Tests\PluginTestCase;
class BaseTestCase extends PluginTestCase class BaseTestCase extends PluginTestCase
{ {
@ -226,51 +84,51 @@ public function tearDown(): void
} }
} }
To run the unit tests for your plugin, simply go to the base folder for your plugin, and run the following command: #### Changing database engine for plugins tests
```bash By default OctoberCMS uses SQLite stored in memory for the plugin testing environment. If you want to override the default behavior set the `useConfigForTesting` config to `true` in your `/config/database.php` file. When the `APP_ENV` is `testing` and the `useConfigForTesting` is `true` database parameters will be taken from `/config/database.php`.
../../../vendor/bin/phpunit
```
This will execute PHPUnit in the context of your plugin. You can override the `/config/database.php` file by creating `/config/testing/database.php`. In this case variables from the latter file will be taken.
<a name="plugin-browser-tests"></a> ## System testing
### Browsers Tests
Browser tests for plugins can be set up in much the same way as unit tests, with a small number of differences. To perform unit testing on the core October files, you should download a development copy using composer or cloning the git repo. This will ensure you have the `tests/` directory.
Browsers tests require their own PHPUnit XML configuration file. You should create a `phpunit.dusk.xml` file in your project base directory with the following content: ### Unit tests
<?xml version="1.0" encoding="UTF-8"?> Unit tests can be performed by running `phpunit` in the root directory or inside `/tests/unit`.
<phpunit
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="../../../tests/bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
>
<testsuites>
<testsuite name="Plugin Browser Test Suite">
<directory>./tests/browser</directory>
</testsuite>
</testsuites>
<php>
<env name="APP_ENV" value="dusk"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
</php>
</phpunit>
Browser tests should be separate from unit tests - you can instead store browser tests within the **tests/browser/** directory. ### Functional tests
Browser test files follow the same rules as unit test files, however, instead of extending the `October\Core\Tests\PluginTestCase` class, they should instead extend the `October\Core\Tests\BrowserTestCase` class. Functional tests can be performed by running `phpunit` in the `/tests/functional` directory. Ensure the following configuration is met:
To run the plugin browser tests, you must run the following command within the root folder of your *October CMS install*, not the plugin: - Active theme is `demo`
- Language preference is `en`
```bash #### Selenium set up
php artisan dusk -c plugins/acme/test/phpunit.dusk.xml
``` 1. Download latest Java SE from http://java.sun.com/ and install
1. Download a distribution archive of [Selenium Server](http://seleniumhq.org/download/).
1. Unzip the distribution archive and copy selenium-server-standalone-2.42.2.jar (check the version suffix) to /usr/local/bin, for instance.
1. Start the Selenium Server server by running `java -jar /usr/local/bin/selenium-server-standalone-2.42.2.jar`.
#### Selenium configuration
Create a new file `selenium.php` in the root directory, add the following content:
<?php
// Selenium server details
define('TEST_SELENIUM_HOST', '127.0.0.1');
define('TEST_SELENIUM_PORT', 4444);
define('TEST_SELENIUM_BROWSER', '*firefox');
// Back-end URL
define('TEST_SELENIUM_URL', 'http://localhost/backend/');
// Active Theme
define('TEST_SELENIUM_THEME', 'demo');
// Back-end credentials
define('TEST_SELENIUM_USER', 'admin');
define('TEST_SELENIUM_PASS', 'admin');

View File

@ -1,6 +1,5 @@
<?php namespace October\Core\Tests; <?php
class TestCase extends Illuminate\Foundation\Testing\TestCase
abstract class TestCase extends \Illuminate\Foundation\Testing\TestCase
{ {
/** /**
* Creates the application. * Creates the application.
@ -22,10 +21,11 @@ abstract class TestCase extends \Illuminate\Foundation\Testing\TestCase
// //
// Helpers // Helpers
// //
protected static function callProtectedMethod($object, $name, $params = []) protected static function callProtectedMethod($object, $name, $params = [])
{ {
$className = get_class($object); $className = get_class($object);
$class = new \ReflectionClass($className); $class = new ReflectionClass($className);
$method = $class->getMethod($name); $method = $class->getMethod($name);
$method->setAccessible(true); $method->setAccessible(true);
return $method->invokeArgs($object, $params); return $method->invokeArgs($object, $params);
@ -34,7 +34,7 @@ abstract class TestCase extends \Illuminate\Foundation\Testing\TestCase
public static function getProtectedProperty($object, $name) public static function getProtectedProperty($object, $name)
{ {
$className = get_class($object); $className = get_class($object);
$class = new \ReflectionClass($className); $class = new ReflectionClass($className);
$property = $class->getProperty($name); $property = $class->getProperty($name);
$property->setAccessible(true); $property->setAccessible(true);
return $property->getValue($object); return $property->getValue($object);
@ -43,7 +43,7 @@ abstract class TestCase extends \Illuminate\Foundation\Testing\TestCase
public static function setProtectedProperty($object, $name, $value) public static function setProtectedProperty($object, $name, $value)
{ {
$className = get_class($object); $className = get_class($object);
$class = new \ReflectionClass($className); $class = new ReflectionClass($className);
$property = $class->getProperty($name); $property = $class->getProperty($name);
$property->setAccessible(true); $property->setAccessible(true);
return $property->setValue($object, $value); return $property->setValue($object, $value);

111
tests/UiTestCase.php Normal file
View File

@ -0,0 +1,111 @@
<?php
class UiTestCase extends PHPUnit\Extensions\Selenium2TestCase
{
protected function setUp()
{
/*
* Look for selenium configuration
*/
if (file_exists($seleniumEnv = __DIR__.'/../selenium.php')) {
require_once $seleniumEnv;
}
/*
* Configure selenium
*/
if (!defined('TEST_SELENIUM_URL')) {
return $this->markTestSkipped('Selenium skipped');
}
if (defined('TEST_SELENIUM_HOST')) {
$this->setHost(TEST_SELENIUM_HOST);
}
if (defined('TEST_SELENIUM_PORT')) {
$this->setPort(TEST_SELENIUM_PORT);
}
if (defined('TEST_SELENIUM_BROWSER')) {
$this->setBrowser(TEST_SELENIUM_BROWSER);
}
$this->setBrowserUrl(TEST_SELENIUM_URL);
}
//
// OctoberCMS Helpers
//
protected function signInToBackend()
{
$this->open('backend');
$this->type("name=login", TEST_SELENIUM_USER);
$this->type("name=password", TEST_SELENIUM_PASS);
$this->click("//button[@type='submit']");
$this->waitForPageToLoad("30000");
}
/**
* Similar to the native getConfirmation() function
*/
protected function getSweetConfirmation($expectedText = null, $clickOk = true)
{
$this->waitForElementPresent("xpath=(//div[@class='sweet-alert showSweetAlert visible'])[1]");
if ($expectedText) {
$this->verifyText("//div[@class='sweet-alert showSweetAlert visible']//h4", $expectedText);
}
$this->verifyText("//div[@class='sweet-alert showSweetAlert visible']//button[@class='confirm btn btn-primary']", "OK");
if ($clickOk) {
$this->click("xpath=(//div[@class='sweet-alert showSweetAlert visible']//button[@class='confirm btn btn-primary'])[1]");
}
}
//
// Selenium helpers
//
protected function waitForElementPresent($target, $timeout = 60)
{
$second = 0;
while (true) {
if ($second >= $timeout) {
$this->fail('timeout');
}
try {
if ($this->isElementPresent($target)) {
break;
}
}
catch (Exception $e) {
}
sleep(1);
++$second;
}
}
protected function waitForElementNotPresent($target, $timeout = 60)
{
$second = 0;
while (true) {
if ($second >= $timeout) {
$this->fail('timeout');
}
try {
if (!$this->isElementPresent($target)) {
break;
}
}
catch (Exception $e) {
}
sleep(1);
++$second;
}
}
}

View File

@ -11,5 +11,5 @@ $loader = new October\Rain\Support\ClassLoader(
$loader->register(); $loader->register();
$loader->addDirectories([ $loader->addDirectories([
'modules', 'modules',
'plugins', 'plugins'
]); ]);

View File

@ -1,4 +1,6 @@
<?php namespace October\Core\Tests\Concerns; <?php
namespace October\Tests\Concerns;
use Illuminate\Contracts\Auth\Authenticatable as UserContract; use Illuminate\Contracts\Auth\Authenticatable as UserContract;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace October\Core\Tests\Fixtures\Backend\Models; namespace October\Tests\Fixtures\Backend\Models;
use Backend\Models\User; use Backend\Models\User;

View File

@ -0,0 +1,90 @@
<?php
class AuthTest extends UiTestCase
{
public function testSignInAndOut()
{
$this->open('backend');
$cssLogoutLink = '#layout-mainmenu .mainmenu-accountmenu > ul > li:first-child > a';
try {
$this->assertTitle('Administration Area');
$this->assertTrue($this->isElementPresent("name=login"));
$this->assertTrue($this->isElementPresent("name=password"));
$this->assertTrue($this->isElementPresent("//button[@type='submit']"));
$this->verifyText("//button[@type='submit']", "Login");
}
catch (PHPUnit_Framework_AssertionFailedError $e) {
array_push($this->verificationErrors, $e->toString());
}
/*
* Sign in
*/
$this->type("name=login", TEST_SELENIUM_USER);
$this->type("name=password", TEST_SELENIUM_PASS);
$this->click("//button[@type='submit']");
$this->waitForPageToLoad("30000");
try {
$this->assertTitle('Dashboard | October CMS');
$this->assertTrue($this->isElementPresent('css='.$cssLogoutLink));
}
catch (PHPUnit_Framework_AssertionFailedError $e) {
array_push($this->verificationErrors, $e->toString());
}
$this->verifyText('css='.$cssLogoutLink, "Sign out");
/*
* Log out
*/
$this->click('css='.$cssLogoutLink);
$this->waitForPageToLoad("30000");
try {
$this->assertTitle('Administration Area');
}
catch (PHPUnit_Framework_AssertionFailedError $e) {
array_push($this->verificationErrors, $e->toString());
}
}
public function testPasswordReset()
{
$this->open('backend');
try {
$this->assertTrue($this->isElementPresent("link=exact:Forgot your password?"));
}
catch (PHPUnit_Framework_AssertionFailedError $e) {
array_push($this->verificationErrors, $e->toString());
}
$this->click('link=exact:Forgot your password?');
$this->waitForPageToLoad("30000");
try {
$this->assertTrue($this->isElementPresent("//button[@type='submit']"));
$this->verifyText("//button[@type='submit']", "Restore");
$this->assertTrue($this->isElementPresent("link=Cancel"));
}
catch (PHPUnit_Framework_AssertionFailedError $e) {
array_push($this->verificationErrors, $e->toString());
}
$this->type("name=login", TEST_SELENIUM_USER);
sleep(1);
$this->click("//button[@type='submit']");
$this->waitForPageToLoad("30000");
try {
$this->assertTitle('Administration Area');
$this->assertTrue($this->isElementPresent("css=p.flash-message.success"));
$this->verifyText("css=p.flash-message.success", "An email has been sent to your email address with password restore instructions.×");
}
catch (PHPUnit_Framework_AssertionFailedError $e) {
array_push($this->verificationErrors, $e->toString());
}
}
}

View File

@ -0,0 +1,143 @@
<?php
class TemplateTest extends UiTestCase
{
public function testOpenTemplates()
{
$this->signInToBackend();
$this->open('cms');
$this->waitForPageToLoad("30000");
// Fix the sidebar
$this->click("xpath=(//a[@class='fix-button'])[1]");
/*
* Page
*/
// Create a new page
$this->click("xpath=(//form[@data-template-type='page']//button[@data-control='create-template'])[1]");
$this->waitForElementPresent("name=settings[title]");
// Populate page details
$this->type('name=settings[title]', 'Functional Test Page');
$this->type('name=settings[url]', '/xxx/functional/test/page');
$this->type('name=fileName', 'xxx_functional_test_page');
// Save the new page
$this->click("xpath=(//a[@data-request='onSave'])[1]");
$this->waitForElementPresent("xpath=(//li[@data-tab-id='page-".TEST_SELENIUM_THEME."-xxx_functional_test_page.htm'])[1]");
// Close the tab
$this->click("xpath=(//li[@data-tab-id='page-".TEST_SELENIUM_THEME."-xxx_functional_test_page.htm']/span[@class='tab-close'])[1]");
// Reopen the tab
$this->waitForElementPresent("xpath=(//div[@id='TemplateList-pageList-template-list']//li[@data-item-path='xxx_functional_test_page.htm']/a)[1]");
$this->click("xpath=(//div[@id='TemplateList-pageList-template-list']//li[@data-item-path='xxx_functional_test_page.htm']/a)[1]");
$this->waitForElementPresent("name=settings[title]");
sleep(1);
// Delete the page
$this->click("xpath=(//button[@data-request='onDelete'])[1]");
$this->getSweetConfirmation('Do you really want delete this page?');
// $this->assertTrue((bool)preg_match('/^Do you really want delete this page[\s\S]$/',$this->getConfirmation()));
$this->waitForElementNotPresent("name=settings[title]");
/*
* Partial
*/
// Click partials menu item
$this->click("xpath=(//li[@data-menu-item='partials']/a)[1]");
// Create a new partial
$this->click("xpath=(//form[@data-template-type='partial']//button[@data-control='create-template'])[1]");
$this->waitForElementPresent("name=fileName");
// Populate partial details
$this->type('name=fileName', 'xxx_functional_test_partial');
$this->type('name=settings[description]', 'Test partial');
// Save the new partial
$this->click("xpath=(//a[@data-request='onSave'])[1]");
$this->waitForElementPresent("xpath=(//li[@data-tab-id='partial-".TEST_SELENIUM_THEME."-xxx_functional_test_partial.htm'])[1]");
// Close the tab
$this->click("xpath=(//li[@data-tab-id='partial-".TEST_SELENIUM_THEME."-xxx_functional_test_partial.htm']/span[@class='tab-close'])[1]");
// Reopen the tab
$this->waitForElementPresent("xpath=(//div[@id='TemplateList-partialList-template-list']//li[@data-item-path='xxx_functional_test_partial.htm']/a)[1]");
$this->click("xpath=(//div[@id='TemplateList-partialList-template-list']//li[@data-item-path='xxx_functional_test_partial.htm']/a)[1]");
$this->waitForElementPresent("name=fileName");
sleep(1);
// Delete the partial
$this->click("xpath=(//button[@data-request='onDelete'])[1]");
$this->getSweetConfirmation('Do you really want delete this partial?');
$this->waitForElementNotPresent("name=fileName");
/*
* Layout
*/
// Click layouts menu item
$this->click("xpath=(//li[@data-menu-item='layouts']/a)[1]");
// Create a new layout
$this->click("xpath=(//form[@data-template-type='layout']//button[@data-control='create-template'])[1]");
$this->waitForElementPresent("name=fileName");
// Populate layout details
$this->type('name=fileName', 'xxx_functional_test_layout');
$this->type('name=settings[description]', 'Test layout');
// Save the new layout
$this->click("xpath=(//a[@data-request='onSave'])[1]");
$this->waitForElementPresent("xpath=(//li[@data-tab-id='layout-".TEST_SELENIUM_THEME."-xxx_functional_test_layout.htm'])[1]");
// Close the tab
$this->click("xpath=(//li[@data-tab-id='layout-".TEST_SELENIUM_THEME."-xxx_functional_test_layout.htm']/span[@class='tab-close'])[1]");
// Reopen the tab
$this->waitForElementPresent("xpath=(//div[@id='TemplateList-layoutList-template-list']//li[@data-item-path='xxx_functional_test_layout.htm']/a)[1]");
$this->click("xpath=(//div[@id='TemplateList-layoutList-template-list']//li[@data-item-path='xxx_functional_test_layout.htm']/a)[1]");
$this->waitForElementPresent("name=fileName");
sleep(1);
// Delete the layout
$this->click("xpath=(//button[@data-request='onDelete'])[1]");
$this->getSweetConfirmation('Do you really want delete this layout?');
$this->waitForElementNotPresent("name=fileName");
/*
* Content
*/
// Click contents menu item
$this->click("xpath=(//li[@data-menu-item='content']/a)[1]");
// Create a new content
$this->click("xpath=(//form[@data-template-type='content']//button[@data-control='create-template'])[1]");
$this->waitForElementPresent("name=fileName");
// Populate content details
$this->type('name=fileName', 'xxx_functional_test_content.txt');
// Save the new content
$this->click("xpath=(//a[@data-request='onSave'])[1]");
$this->waitForElementPresent("xpath=(//li[@data-tab-id='content-".TEST_SELENIUM_THEME."-xxx_functional_test_content.txt'])[1]");
// Close the tab
$this->click("xpath=(//li[@data-tab-id='content-".TEST_SELENIUM_THEME."-xxx_functional_test_content.txt']/span[@class='tab-close'])[1]");
// Reopen the tab
$this->waitForElementPresent("xpath=(//div[@id='TemplateList-contentList-template-list']//li[@data-item-path='xxx_functional_test_content.txt']/a)[1]");
$this->click("xpath=(//div[@id='TemplateList-contentList-template-list']//li[@data-item-path='xxx_functional_test_content.txt']/a)[1]");
$this->waitForElementPresent("name=fileName");
sleep(1);
// Delete the content
$this->click("xpath=(//button[@data-request='onDelete'])[1]");
$this->getSweetConfirmation('Do you really want delete this content file?');
$this->waitForElementNotPresent("name=fileName");
}
}

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="../../bootstrap/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="true"
syntaxCheck="false"
>
<testsuites>
<testsuite name="October Test Suite">
<directory>./</directory>
</testsuite>
</testsuites>
</phpunit>

View File

@ -2,7 +2,7 @@
use Backend\Classes\AuthManager; use Backend\Classes\AuthManager;
use October\Rain\Exception\SystemException; use October\Rain\Exception\SystemException;
class AuthManagerTest extends \October\Core\Tests\TestCase class AuthManagerTest extends TestCase
{ {
public function setUp(): void public function setUp(): void
{ {

View File

@ -3,7 +3,7 @@
use Backend\Classes\Controller; use Backend\Classes\Controller;
use Backend\Classes\NavigationManager; use Backend\Classes\NavigationManager;
class NavigationManagerTest extends \October\Core\Tests\TestCase class NavigationManagerTest extends TestCase
{ {
public function testRegisterMenuItems() public function testRegisterMenuItems()
{ {

View File

@ -3,7 +3,7 @@
use Backend\Classes\Controller; use Backend\Classes\Controller;
use Backend\Classes\WidgetManager; use Backend\Classes\WidgetManager;
class WidgetManagerTest extends \October\Core\Tests\TestCase class WidgetManagerTest extends TestCase
{ {
public function testListFormWidgets() public function testListFormWidgets()
{ {

View File

@ -3,7 +3,7 @@
use Backend\Helpers\Backend; use Backend\Helpers\Backend;
use Backend\Helpers\Exception\DecompileException; use Backend\Helpers\Exception\DecompileException;
class BackendHelperTest extends \October\Core\Tests\TestCase class BackendHelperTest extends TestCase
{ {
public function testDecompileAssets() public function testDecompileAssets()
{ {

View File

@ -25,7 +25,7 @@ class ExampleExportModel extends ExportModel
} }
} }
class ExportModelTest extends \October\Core\Tests\TestCase class ExportModelTest extends TestCase
{ {
// //

View File

@ -16,7 +16,7 @@ class ExampleImportModel extends ImportModel
} }
} }
class ImportModelTest extends \October\Core\Tests\TestCase class ImportModelTest extends TestCase
{ {
// //

View File

@ -12,7 +12,7 @@ class ExampleTraitClass
} }
} }
class WidgetMakerTest extends \October\Core\Tests\TestCase class WidgetMakerTest extends TestCase
{ {
/** /**
* The object under test. * The object under test.

View File

@ -2,17 +2,10 @@
use Backend\Widgets\Filter; use Backend\Widgets\Filter;
use Backend\Models\User; use Backend\Models\User;
use October\Core\Tests\Fixtures\Backend\Models\UserFixture; use October\Tests\Fixtures\Backend\Models\UserFixture;
class FilterTest extends \October\Core\Tests\PluginTestCase class FilterTest extends PluginTestCase
{ {
public function setUp() : void
{
parent::setUp();
include_once base_path() . '/tests/fixtures/backend/models/UserFixture.php';
}
public function testRestrictedScopeWithUserWithNoPermissions() public function testRestrictedScopeWithUserWithNoPermissions()
{ {
$user = new UserFixture; $user = new UserFixture;

View File

@ -2,23 +2,15 @@
use Backend\Widgets\Form; use Backend\Widgets\Form;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use October\Core\Tests\Fixtures\Backend\Models\UserFixture; use October\Tests\Fixtures\Backend\Models\UserFixture;
class FormTestModel extends Model class FormTestModel extends Model
{ {
} }
class FormTest extends \October\Core\Tests\PluginTestCase class FormTest extends PluginTestCase
{ {
public function setUp() : void
{
parent::setUp();
include_once base_path() . '/tests/fixtures/backend/models/UserFixture.php';
}
public function testRestrictedFieldWithUserWithNoPermissions() public function testRestrictedFieldWithUserWithNoPermissions()
{ {
$user = new UserFixture; $user = new UserFixture;

View File

@ -3,17 +3,10 @@
use Backend\Models\User; use Backend\Models\User;
use Backend\Widgets\Lists; use Backend\Widgets\Lists;
use October\Rain\Exception\ApplicationException; use October\Rain\Exception\ApplicationException;
use October\Core\Tests\Fixtures\Backend\Models\UserFixture; use October\Tests\Fixtures\Backend\Models\UserFixture;
class ListsTest extends \October\Core\Tests\PluginTestCase class ListsTest extends PluginTestCase
{ {
public function setUp() : void
{
parent::setUp();
include_once base_path() . '/tests/fixtures/backend/models/UserFixture.php';
}
public function testRestrictedColumnWithUserWithNoPermissions() public function testRestrictedColumnWithUserWithNoPermissions()
{ {
$user = new UserFixture; $user = new UserFixture;

View File

@ -28,7 +28,7 @@ class TestTemporaryCmsCompoundObject extends CmsCompoundObject
} }
} }
class CmsCompoundObjectTest extends \October\Core\Tests\TestCase class CmsCompoundObjectTest extends TestCase
{ {
public function setUp() : void public function setUp() : void
{ {

View File

@ -9,7 +9,7 @@ use Cms\Classes\CmsException;
use Cms\Classes\CodeParser; use Cms\Classes\CodeParser;
use October\Rain\Exception\SystemException; use October\Rain\Exception\SystemException;
class CmsExceptionTest extends \October\Core\Tests\TestCase class CmsExceptionTest extends TestCase
{ {
// //
// Tests // Tests

View File

@ -5,7 +5,7 @@ use Cms\Classes\Theme;
use Cms\Classes\Layout; use Cms\Classes\Layout;
use October\Rain\Halcyon\Model; use October\Rain\Halcyon\Model;
class CmsObjectQueryTest extends \October\Core\Tests\TestCase class CmsObjectQueryTest extends TestCase
{ {
public function setUp() : void public function setUp() : void
{ {

View File

@ -13,7 +13,7 @@ class TestTemporaryCmsObject extends CmsObject
protected $dirName = 'temporary'; protected $dirName = 'temporary';
} }
class CmsObjectTest extends \October\Core\Tests\TestCase class CmsObjectTest extends TestCase
{ {
public function testLoad() public function testLoad()
{ {

View File

@ -8,7 +8,7 @@ use Cms\Classes\Layout;
use Cms\Classes\CodeParser; use Cms\Classes\CodeParser;
use Cms\Classes\Controller; use Cms\Classes\Controller;
class CodeParserTest extends \October\Core\Tests\TestCase class CodeParserTest extends TestCase
{ {
public function setUp() : void public function setUp() : void
{ {

View File

@ -7,7 +7,7 @@ use Cms\Classes\Controller;
use Cms\Classes\CodeParser; use Cms\Classes\CodeParser;
use Cms\Classes\ComponentManager; use Cms\Classes\ComponentManager;
class ComponentManagerTest extends \October\Core\Tests\TestCase class ComponentManagerTest extends TestCase
{ {
public function setUp() : void public function setUp() : void
{ {

View File

@ -3,7 +3,7 @@
use Cms\Classes\Theme; use Cms\Classes\Theme;
use Cms\Classes\Content; use Cms\Classes\Content;
class ContentTest extends \October\Core\Tests\TestCase class ContentTest extends TestCase
{ {
public function testMarkdownContent() public function testMarkdownContent()

View File

@ -4,7 +4,7 @@ use Cms\Classes\Theme;
use Cms\Classes\Controller; use Cms\Classes\Controller;
use October\Rain\Halcyon\Model; use October\Rain\Halcyon\Model;
class ControllerTest extends \October\Core\Tests\TestCase class ControllerTest extends TestCase
{ {
public function setUp() : void public function setUp() : void
{ {

View File

@ -2,7 +2,7 @@
use Cms\Classes\PartialStack; use Cms\Classes\PartialStack;
class PartialStackTest extends \October\Core\Tests\TestCase class PartialStackTest extends TestCase
{ {
public function testStackPartials() public function testStackPartials()

View File

@ -3,7 +3,7 @@
use Cms\Classes\Router; use Cms\Classes\Router;
use Cms\Classes\Theme; use Cms\Classes\Theme;
class RouterTest extends \October\Core\Tests\TestCase class RouterTest extends TestCase
{ {
protected static $theme = null; protected static $theme = null;

View File

@ -2,7 +2,7 @@
use Cms\Classes\Theme; use Cms\Classes\Theme;
class ThemeTest extends \October\Core\Tests\TestCase class ThemeTest extends TestCase
{ {
public function setUp() : void public function setUp() : void
{ {

View File

@ -2,7 +2,7 @@
use Cms\Helpers\File as FileHelper; use Cms\Helpers\File as FileHelper;
class FileTest extends \October\Core\Tests\TestCase class FileTest extends TestCase
{ {
public function testValidateName() public function testValidateName()
{ {

View File

@ -13,7 +13,7 @@ class ExampleDbImportModel extends ImportModel
} }
} }
class ImportModelDbTest extends \October\Core\Tests\PluginTestCase class ImportModelDbTest extends PluginTestCase
{ {
public function testGetImportFilePath() public function testGetImportFilePath()
{ {

View File

@ -3,7 +3,7 @@
use System\Models\File as FileModel; use System\Models\File as FileModel;
use Database\Tester\Models\User; use Database\Tester\Models\User;
class AttachManyModelTest extends \October\Core\Tests\PluginTestCase class AttachManyModelTest extends PluginTestCase
{ {
public function setUp() : void public function setUp() : void
{ {

View File

@ -5,7 +5,7 @@ use Database\Tester\Models\User;
use Database\Tester\Models\SoftDeleteUser; use Database\Tester\Models\SoftDeleteUser;
use Symfony\Component\HttpFoundation\File\UploadedFile; use Symfony\Component\HttpFoundation\File\UploadedFile;
class AttachOneModelTest extends \October\Core\Tests\PluginTestCase class AttachOneModelTest extends PluginTestCase
{ {
public function setUp() : void public function setUp() : void
{ {

View File

@ -3,7 +3,7 @@
use Database\Tester\Models\Role; use Database\Tester\Models\Role;
use Database\Tester\Models\Author; use Database\Tester\Models\Author;
class BelongsToManyModelTest extends \October\Core\Tests\PluginTestCase class BelongsToManyModelTest extends PluginTestCase
{ {
public function setUp() : void public function setUp() : void
{ {

View File

@ -3,7 +3,7 @@
use Database\Tester\Models\Post; use Database\Tester\Models\Post;
use Database\Tester\Models\Author; use Database\Tester\Models\Author;
class BelongsToModelTest extends \October\Core\Tests\PluginTestCase class BelongsToModelTest extends PluginTestCase
{ {
public function setUp() : void public function setUp() : void
{ {

View File

@ -4,7 +4,7 @@ use Database\Tester\Models\Post;
use Database\Tester\Models\Author; use Database\Tester\Models\Author;
use October\Rain\Database\Models\DeferredBinding; use October\Rain\Database\Models\DeferredBinding;
class DeferredBindingTest extends \October\Core\Tests\PluginTestCase class DeferredBindingTest extends PluginTestCase
{ {
public function setUp() : void public function setUp() : void
{ {

View File

@ -4,7 +4,7 @@ use Database\Tester\Models\Author;
use Database\Tester\Models\Post; use Database\Tester\Models\Post;
use October\Rain\Database\Collection; use October\Rain\Database\Collection;
class HasManyModelTest extends \October\Core\Tests\PluginTestCase class HasManyModelTest extends PluginTestCase
{ {
public function setUp() : void public function setUp() : void
{ {

View File

@ -5,7 +5,7 @@ use Database\Tester\Models\Country;
use Database\Tester\Models\Post; use Database\Tester\Models\Post;
use October\Rain\Database\Collection; use October\Rain\Database\Collection;
class HasManyThroughModelTest extends \October\Core\Tests\PluginTestCase class HasManyThroughModelTest extends PluginTestCase
{ {
public function setUp() : void public function setUp() : void
{ {

View File

@ -3,7 +3,7 @@
use Database\Tester\Models\Author; use Database\Tester\Models\Author;
use Database\Tester\Models\Phone; use Database\Tester\Models\Phone;
class HasOneModelTest extends \October\Core\Tests\PluginTestCase class HasOneModelTest extends PluginTestCase
{ {
public function setUp() : void public function setUp() : void
{ {

View File

@ -4,7 +4,7 @@ use Database\Tester\Models\Author;
use Database\Tester\Models\Phone; use Database\Tester\Models\Phone;
use Database\Tester\Models\User; use Database\Tester\Models\User;
class HasOneThroughModelTest extends \October\Core\Tests\PluginTestCase class HasOneThroughModelTest extends PluginTestCase
{ {
public function setUp() : void public function setUp() : void
{ {

View File

@ -2,7 +2,7 @@
use Database\Tester\Models\Post; use Database\Tester\Models\Post;
class ModelTest extends \October\Core\Tests\PluginTestCase class ModelTest extends PluginTestCase
{ {
public function setUp() : void public function setUp() : void
{ {

View File

@ -4,7 +4,7 @@ use Database\Tester\Models\Author;
use Database\Tester\Models\EventLog; use Database\Tester\Models\EventLog;
use October\Rain\Database\Collection; use October\Rain\Database\Collection;
class MorphManyModelTest extends \October\Core\Tests\PluginTestCase class MorphManyModelTest extends PluginTestCase
{ {
public function setUp() : void public function setUp() : void
{ {

View File

@ -4,7 +4,7 @@ use Database\Tester\Models\Author;
use Database\Tester\Models\Post; use Database\Tester\Models\Post;
use Database\Tester\Models\Meta; use Database\Tester\Models\Meta;
class MorphOneModelTest extends \October\Core\Tests\PluginTestCase class MorphOneModelTest extends PluginTestCase
{ {
public function setUp() : void public function setUp() : void
{ {

View File

@ -4,7 +4,7 @@ use Database\Tester\Models\Post;
use Database\Tester\Models\Author; use Database\Tester\Models\Author;
use Database\Tester\Models\EventLog; use Database\Tester\Models\EventLog;
class MorphToModelTest extends \October\Core\Tests\PluginTestCase class MorphToModelTest extends PluginTestCase
{ {
public function setUp() : void public function setUp() : void
{ {

View File

@ -3,7 +3,7 @@
use Carbon\Carbon; use Carbon\Carbon;
use Database\Tester\Models\CategoryNested; use Database\Tester\Models\CategoryNested;
class NestedTreeModelTest extends \October\Core\Tests\PluginTestCase class NestedTreeModelTest extends PluginTestCase
{ {
public function setUp() : void public function setUp() : void
{ {

View File

@ -2,7 +2,7 @@
use Database\Tester\Models\NullablePost; use Database\Tester\Models\NullablePost;
class NullableModelTest extends \October\Core\Tests\PluginTestCase class NullableModelTest extends PluginTestCase
{ {
public function setUp() : void public function setUp() : void
{ {

View File

@ -3,7 +3,7 @@
use Carbon\Carbon; use Carbon\Carbon;
use Database\Tester\Models\RevisionablePost; use Database\Tester\Models\RevisionablePost;
class RevisionableModelTest extends \October\Core\Tests\PluginTestCase class RevisionableModelTest extends PluginTestCase
{ {
public function setUp() : void public function setUp() : void
{ {

View File

@ -3,7 +3,7 @@
use Carbon\Carbon; use Carbon\Carbon;
use Database\Tester\Models\CategorySimple; use Database\Tester\Models\CategorySimple;
class SimpleTreeModelTest extends \October\Core\Tests\PluginTestCase class SimpleTreeModelTest extends PluginTestCase
{ {
public function setUp() : void public function setUp() : void
{ {

View File

@ -2,7 +2,7 @@
use Database\Tester\Models\SluggablePost; use Database\Tester\Models\SluggablePost;
class SluggableModelTest extends \October\Core\Tests\PluginTestCase class SluggableModelTest extends PluginTestCase
{ {
public function setUp() : void public function setUp() : void
{ {

View File

@ -8,7 +8,7 @@ use Database\Tester\Models\UserWithSoftAuthor;
use Database\Tester\Models\UserWithAuthorAndSoftDelete; use Database\Tester\Models\UserWithAuthorAndSoftDelete;
use Database\Tester\Models\UserWithSoftAuthorAndSoftDelete; use Database\Tester\Models\UserWithSoftAuthorAndSoftDelete;
class SoftDeleteModelTest extends \October\Core\Tests\PluginTestCase class SoftDeleteModelTest extends PluginTestCase
{ {
public function setUp() : void public function setUp() : void
{ {

View File

@ -2,7 +2,7 @@
use Database\Tester\Models\ValidationPost; use Database\Tester\Models\ValidationPost;
class ValidationModelTest extends \October\Core\Tests\PluginTestCase class ValidationModelTest extends PluginTestCase
{ {
public function setUp() : void public function setUp() : void
{ {

View File

@ -14,7 +14,7 @@ class CmsThemeTemplateFixture extends Model
public $table = 'cms_theme_templates'; public $table = 'cms_theme_templates';
} }
class AutoDatasourceTest extends \October\Core\Tests\PluginTestCase class AutoDatasourceTest extends PluginTestCase
{ {
/** /**
* Array of model fixtures. * Array of model fixtures.

View File

@ -3,7 +3,7 @@
use Cms\Classes\Theme; use Cms\Classes\Theme;
use System\Classes\CombineAssets; use System\Classes\CombineAssets;
class CombineAssetsTest extends \October\Core\Tests\TestCase class CombineAssetsTest extends TestCase
{ {
public function setUp() : void public function setUp() : void
{ {

View File

@ -2,7 +2,7 @@
use System\Classes\PluginManager; use System\Classes\PluginManager;
class CoreLangTest extends \October\Core\Tests\TestCase class CoreLangTest extends TestCase
{ {
public function testValidationTranslator() public function testValidationTranslator()
{ {

View File

@ -2,7 +2,7 @@
use System\Classes\MarkupManager; use System\Classes\MarkupManager;
class MarkupManagerTest extends \October\Core\Tests\TestCase class MarkupManagerTest extends TestCase
{ {
public function setUp() : void public function setUp() : void

View File

@ -2,7 +2,7 @@
use System\Classes\MediaLibrary; use System\Classes\MediaLibrary;
class MediaLibraryTest extends \October\Core\Tests\TestCase // @codingStandardsIgnoreLine class MediaLibraryTest extends TestCase // @codingStandardsIgnoreLine
{ {
public function invalidPathsProvider() public function invalidPathsProvider()
{ {

View File

@ -1,7 +1,7 @@
<?php <?php
use System\Classes\PluginManager; use System\Classes\PluginManager;
class PluginManagerTest extends \October\Core\Tests\TestCase class PluginManagerTest extends TestCase
{ {
public $manager; public $manager;

View File

@ -2,7 +2,7 @@
use System\Controllers\Updates; use System\Controllers\Updates;
class UpdatesControllerTest extends \October\Core\Tests\TestCase class UpdatesControllerTest extends TestCase
{ {
// //

View File

@ -2,7 +2,7 @@
use System\Classes\VersionManager; use System\Classes\VersionManager;
class VersionManagerTest extends \October\Core\Tests\TestCase class VersionManagerTest extends TestCase
{ {
public function setUp() : void public function setUp() : void

View File

@ -6,7 +6,7 @@ class AssetMakerStub
use System\Traits\ViewMaker; // Needed for guessViewPath(), which is used to set default assetPath use System\Traits\ViewMaker; // Needed for guessViewPath(), which is used to set default assetPath
} }
class AssetMakerTest extends \October\Core\Tests\TestCase class AssetMakerTest extends TestCase
{ {
private $stub; private $stub;