Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
05b5b3f
Split tests by module and updated winter:test
jaxwilko Jun 21, 2022
7b441ad
Added js tests
jaxwilko Jun 21, 2022
07c7ef5
Fixed js test pathing issues
jaxwilko Jun 21, 2022
4d347f9
Updated js test github action working dir
jaxwilko Jun 21, 2022
8e32b13
Added nl to improve readability
jaxwilko Jun 21, 2022
b684ff6
Code cleanup
jaxwilko Jun 21, 2022
f0c561e
Removed dev autoload as no longer required
jaxwilko Jun 21, 2022
9d4c4e8
Switched linting command for composer alias
jaxwilko Jun 21, 2022
5d6aa76
Added snowboard tests to eslint ignore
jaxwilko Jun 21, 2022
1fd838b
Added backend module eslint ignore & comments
jaxwilko Jun 21, 2022
4ae3937
Update modules/backend/tests/widgets/FormTest.php
LukeTowers Jun 21, 2022
a0f8876
Update modules/cms/tests/classes/AssetTest.php
LukeTowers Jun 21, 2022
d0008d2
Update modules/backend/tests/widgets/FormTest.php
LukeTowers Jun 21, 2022
0fe4d6d
Remove unnecessary docblock comments
LukeTowers Jun 21, 2022
7ded887
Cleanup docblocks
LukeTowers Jun 21, 2022
64e4d4a
Re-add README
LukeTowers Jun 21, 2022
6d9fcbf
Update modules/cms/tests/classes/PageTest.php
LukeTowers Jun 21, 2022
392610a
Update modules/system/tests/classes/ImageResizerTest.php
LukeTowers Jun 21, 2022
fba6446
[WIP] Split Test - 1.2 - PluginManager lower case internal IDs (#583)
jaxwilko Jun 21, 2022
46a8921
Simplified getPlugins method key translation
jaxwilko Jun 22, 2022
d1ff094
Removed imports of global functions
jaxwilko Jun 22, 2022
556c3dc
Improved readability
jaxwilko Jun 22, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 4 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ jobs:
node-version: 12

- name: Install Node dependencies
working-directory: ./tests/js
working-directory: ./modules/system/tests/js
run: npm install

- name: Run tests
working-directory: ./tests/js
working-directory: ./modules/system/tests/js
run: npm run test

phpUnitTests:
strategy:
max-parallel: 8
Expand Down Expand Up @@ -117,5 +118,5 @@ jobs:

- name: Run Linting and Tests
run: |
./vendor/bin/parallel-lint --exclude vendor --exclude storage --exclude tests/fixtures/plugins/testvendor/goto/Plugin.php .
composer lint
./vendor/bin/phpunit
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ package-lock.json
/node_modules

# Ignore generated public directory from `winter:mirror public`
public
public
10 changes: 1 addition & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,6 @@
"php-parallel-lint/php-parallel-lint": "^1.0",
"dms/phpunit-arraysubset-asserts": "^0.1.0|^0.2.1"
},
"autoload-dev": {
"classmap": [
"tests/concerns/InteractsWithAuthentication.php",
"tests/fixtures/backend/models/UserFixture.php",
"tests/TestCase.php",
"tests/PluginTestCase.php"
]
},
"scripts": {
"post-create-project-cmd": [
"@php artisan key:generate",
Expand All @@ -66,7 +58,7 @@
"phpunit --stop-on-failure"
],
"lint": [
"parallel-lint --exclude vendor --exclude storage --exclude tests/fixtures/plugins/testvendor/goto/Plugin.php ."
"parallel-lint --exclude vendor --exclude storage --exclude modules/system/tests/fixtures/plugins/testvendor/goto/Plugin.php ."
],
"sniff": [
"phpcs --colors -nq --report=\"full\" --extensions=\"php\""
Expand Down
10 changes: 5 additions & 5 deletions config/testing/cms.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
|
*/

'pluginsPathLocal' => base_path('tests/fixtures/plugins'),
'pluginsPathLocal' => base_path('modules/system/tests/fixtures/plugins'),

/*
|--------------------------------------------------------------------------
Expand All @@ -107,7 +107,7 @@
|
*/

'themesPathLocal' => base_path('tests/fixtures/themes'),
'themesPathLocal' => base_path('modules/cms/tests/fixtures/themes'),

/*
|--------------------------------------------------------------------------
Expand Down Expand Up @@ -149,20 +149,20 @@
'uploads' => [
'disk' => 'local',
'folder' => 'uploads',
'path' => '/tests/storage/app/uploads',
'path' => '/storage/tests/app/uploads',
'temporaryUrlTTL' => 3600,
],

'media' => [
'disk' => 'local',
'folder' => 'media',
'path' => '/tests/storage/app/media',
'path' => '/storage/tests/app/media',
],

'resized' => [
'disk' => 'local',
'folder' => 'resized',
'path' => '/tests/storage/app/resized',
'path' => '/storage/tests/app/resized',
],

],
Expand Down
4 changes: 2 additions & 2 deletions config/testing/filesystems.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@

'local' => [
'driver' => 'local',
'root' => base_path('tests/storage/app'),
'url' => '/tests/storage/app',
'root' => base_path('storage/tests/app'),
'url' => '/storage/tests/app',
],

's3' => [
Expand Down
3 changes: 3 additions & 0 deletions modules/backend/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ controllers/**/*.js
formwidgets/**/*.js
reportwidgets/**/*.js
widgets/**/*.js

# Ignore test fixtures
tests
9 changes: 4 additions & 5 deletions tests/unit/phpunit.xml → modules/backend/phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="../bootstrap.php"
bootstrap="../system/tests/bootstrap/app.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
>
<testsuites>
<testsuite name="Winter Test Suite">
<directory>./</directory>
<testsuite name="Winter Backend Module">
<directory>./tests</directory>
</testsuite>
</testsuites>
<php>
<env name="APP_ENV" value="testing" />
<env name="CACHE_DRIVER" value="array" />
<env name="SESSION_DRIVER" value="array" />
</php>
</phpunit>
</phpunit>
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
use Backend\Classes\AuthManager;

namespace Backend\Tests\Classes;

use System\Tests\Bootstrap\TestCase;
use Winter\Storm\Exception\SystemException;
use Backend\Classes\AuthManager;

class AuthManagerTest extends TestCase
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

use Backend\Classes\Controller;
namespace Backend\Tests\Classes;

use System\Tests\Bootstrap\TestCase;
use Backend\Classes\NavigationManager;

class NavigationManagerTest extends TestCase
Expand All @@ -13,10 +15,10 @@ public function testRegisterMenuItems()

$manager->registerMenuItems('Winter.Test', [
'dashboard' => [
'label' => 'Dashboard',
'icon' => 'icon-dashboard',
'url' => 'http://example.com',
'order' => 100
'label' => 'Dashboard',
'icon' => 'icon-dashboard',
'url' => 'http://example.com',
'order' => 100
]
]);

Expand Down Expand Up @@ -175,9 +177,9 @@ public function testAddSideMenuItems()

$manager->addSideMenuItems('Winter.Tester', 'blog', [
'foo' => [
'label' => 'Bar',
'icon' => 'icon-derp',
'url' => 'http://google.com',
'label' => 'Bar',
'icon' => 'icon-derp',
'url' => 'http://google.com',
'permissions' => [
'winter.tester.access_foo',
'winter.tester.access_bar'
Expand Down Expand Up @@ -213,9 +215,9 @@ public function testAddSideMenuItemsWithAlias()

$manager->addSideMenuItems('Winter.Tester', 'blog', [
'foo' => [
'label' => 'Bar',
'icon' => 'icon-derp',
'url' => 'http://google.com',
'label' => 'Bar',
'icon' => 'icon-derp',
'url' => 'http://google.com',
'permissions' => [
'winter.tester.access_foo',
'winter.tester.access_bar'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

use Backend\Classes\Controller;
namespace Backend\Tests\Classes;

use System\Tests\Bootstrap\TestCase;
use Backend\Classes\WidgetManager;

class WidgetManagerTest extends TestCase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Winter\Tests\Concerns;
namespace Backend\Tests\Concerns;

use Illuminate\Contracts\Auth\Authenticatable as UserContract;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Winter\Tests\Fixtures\Backend\Models;
namespace Backend\Tests\Fixtures\Models;

use Backend\Models\User;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php

namespace Backend\Tests\Helpers;

use System\Tests\Bootstrap\TestCase;
use Backend\Helpers\Backend;
use Backend\Helpers\Exception\DecompileException;

Expand All @@ -8,7 +11,7 @@ class BackendHelperTest extends TestCase
public function testDecompileAssets()
{
$backendHelper = new Backend;
$assets = $backendHelper->decompileAsset('tests/fixtures/backend/assets/compilation.js');
$assets = $backendHelper->decompileAsset('modules/backend/tests/fixtures/assets/compilation.js');

$this->assertCount(2, $assets);
$this->assertStringContainsString('file1.js', $assets[0]);
Expand All @@ -20,6 +23,6 @@ public function testDecompileMissingFile()
$this->expectException(DecompileException::class);

$backendHelper = new Backend;
$assets = $backendHelper->decompileAsset('tests/fixtures/backend/assets/missing.js');
$assets = $backendHelper->decompileAsset('modules/backend/tests/fixtures/assets/missing.js');
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php

namespace Backend\Tests\Models;

use System\Tests\Bootstrap\TestCase;
use Backend\Models\ExportModel;
use Illuminate\Http\Request;

if (!class_exists('Model')) {
class_alias('Winter\Storm\Database\Model', 'Model');
Expand Down Expand Up @@ -56,7 +60,7 @@ public function testDownload()

$response = $model->download($csvName);

$request = new Illuminate\Http\Request();
$request = new Request();

$response->prepare($request);

Expand All @@ -72,9 +76,9 @@ public function testDownload()
$response->send();
$output = ob_get_clean();

$utf8BOM = chr(239).chr(187).chr(191);
$utf8BOM = chr(239) . chr(187) . chr(191);

$this->assertEquals($utf8BOM."title,title2\nbar,foo\nbar2,foo2\n", $output, "CSV is not right!");
$this->assertEquals($utf8BOM . "title,title2\nbar,foo\nbar2,foo2\n", $output, "CSV is not right!");

$filePath = temp_path($csvName);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php

namespace Backend\Tests\Models;

use System\Tests\Bootstrap\PluginTestCase;
use Backend\Models\ImportModel;
use System\Models\File as FileModel;

if (!class_exists('Model')) {
class_alias('Winter\Storm\Database\Model', 'Model');
Expand All @@ -16,7 +20,7 @@ public function importData($results, $sessionKey = null)
}
}

class ImportModelTest extends TestCase
class ImportModelTest extends PluginTestCase
{

//
Expand All @@ -38,4 +42,29 @@ public function testDecodeArrayValue()
$result = self::callProtectedMethod($model, 'decodeArrayValue', [$data, '-']);
$this->assertEquals(['art direction', 'roman empire', 'sci-fi'], $result);
}

public function testGetImportFilePath()
{
$model = new ExampleImportModel;
$sessionKey = uniqid('session_key', true);

$file1 = FileModel::create([
'data' => base_path().'/modules/backend/tests/fixtures/reference/file1.txt',
'is_public' => false,
]);

$file2 = FileModel::create([
'data' => base_path().'/modules/backend/tests/fixtures/reference/file2.txt',
'is_public' => false,
]);

$model->import_file()->add($file1, $sessionKey);
$model->import_file()->add($file2, $sessionKey);

$this->assertEquals(
$file2->getLocalPath(),
$model->getImportFilePath($sessionKey),
'ImportModel::getImportFilePath() should return the last uploaded file.'
);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php

namespace Backend\Tests\Traits;

use System\Tests\Bootstrap\TestCase;
use Backend\Classes\Controller;

class ExampleTraitClass
Expand Down Expand Up @@ -28,7 +31,7 @@ class WidgetMakerTest extends TestCase
*
* @return void
*/
public function setUp() : void
public function setUp(): void
{
parent::setUp();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<?php

namespace Backend\Tests\Widgets;

use System\Tests\Bootstrap\PluginTestCase;
use Backend\Tests\Fixtures\Models\UserFixture;
use Backend\Widgets\Filter;
use ApplicationException;
use Backend\Models\User;
use Winter\Tests\Fixtures\Backend\Models\UserFixture;

class FilterWidgetTest extends PluginTestCase
{
Expand Down
Loading