diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c405164021..3b081f3c4a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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 @@ -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 diff --git a/.gitignore b/.gitignore index 0a2a3393b4..3582897e81 100644 --- a/.gitignore +++ b/.gitignore @@ -32,4 +32,4 @@ package-lock.json /node_modules # Ignore generated public directory from `winter:mirror public` -public \ No newline at end of file +public diff --git a/composer.json b/composer.json index 1b144268b7..a2d8dffb18 100644 --- a/composer.json +++ b/composer.json @@ -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", @@ -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\"" diff --git a/config/testing/cms.php b/config/testing/cms.php index ba61b54e0d..f8660bbbde 100644 --- a/config/testing/cms.php +++ b/config/testing/cms.php @@ -96,7 +96,7 @@ | */ - 'pluginsPathLocal' => base_path('tests/fixtures/plugins'), + 'pluginsPathLocal' => base_path('modules/system/tests/fixtures/plugins'), /* |-------------------------------------------------------------------------- @@ -107,7 +107,7 @@ | */ - 'themesPathLocal' => base_path('tests/fixtures/themes'), + 'themesPathLocal' => base_path('modules/cms/tests/fixtures/themes'), /* |-------------------------------------------------------------------------- @@ -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', ], ], diff --git a/config/testing/filesystems.php b/config/testing/filesystems.php index dc085801ee..d7bf8bf430 100644 --- a/config/testing/filesystems.php +++ b/config/testing/filesystems.php @@ -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' => [ diff --git a/modules/backend/.eslintignore b/modules/backend/.eslintignore index e0d3f30269..b84f8627b8 100644 --- a/modules/backend/.eslintignore +++ b/modules/backend/.eslintignore @@ -12,3 +12,6 @@ controllers/**/*.js formwidgets/**/*.js reportwidgets/**/*.js widgets/**/*.js + +# Ignore test fixtures +tests diff --git a/tests/unit/phpunit.xml b/modules/backend/phpunit.xml similarity index 77% rename from tests/unit/phpunit.xml rename to modules/backend/phpunit.xml index a35949f19b..20888c41d4 100644 --- a/tests/unit/phpunit.xml +++ b/modules/backend/phpunit.xml @@ -1,18 +1,17 @@ - - ./ + + ./tests @@ -20,4 +19,4 @@ - \ No newline at end of file + diff --git a/tests/unit/backend/classes/AuthManagerTest.php b/modules/backend/tests/classes/AuthManagerTest.php similarity index 98% rename from tests/unit/backend/classes/AuthManagerTest.php rename to modules/backend/tests/classes/AuthManagerTest.php index bdb84dd6dd..9556794904 100644 --- a/tests/unit/backend/classes/AuthManagerTest.php +++ b/modules/backend/tests/classes/AuthManagerTest.php @@ -1,6 +1,10 @@ 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 ] ]); @@ -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' @@ -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' diff --git a/tests/unit/backend/classes/WidgetManagerTest.php b/modules/backend/tests/classes/WidgetManagerTest.php similarity index 95% rename from tests/unit/backend/classes/WidgetManagerTest.php rename to modules/backend/tests/classes/WidgetManagerTest.php index 7cab3f208a..c3aea566ae 100644 --- a/tests/unit/backend/classes/WidgetManagerTest.php +++ b/modules/backend/tests/classes/WidgetManagerTest.php @@ -1,6 +1,8 @@ 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]); @@ -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'); } } diff --git a/tests/unit/backend/models/ExportModelTest.php b/modules/backend/tests/models/ExportModelTest.php similarity index 89% rename from tests/unit/backend/models/ExportModelTest.php rename to modules/backend/tests/models/ExportModelTest.php index 26bacff54a..4c1d5e8e7a 100644 --- a/tests/unit/backend/models/ExportModelTest.php +++ b/modules/backend/tests/models/ExportModelTest.php @@ -1,6 +1,10 @@ download($csvName); - $request = new Illuminate\Http\Request(); + $request = new Request(); $response->prepare($request); @@ -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); diff --git a/tests/unit/backend/models/ImportModelTest.php b/modules/backend/tests/models/ImportModelTest.php similarity index 51% rename from tests/unit/backend/models/ImportModelTest.php rename to modules/backend/tests/models/ImportModelTest.php index 75cda6dd70..23a089393c 100644 --- a/tests/unit/backend/models/ImportModelTest.php +++ b/modules/backend/tests/models/ImportModelTest.php @@ -1,6 +1,10 @@ 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.' + ); + } } diff --git a/tests/unit/backend/traits/WidgetMakerTest.php b/modules/backend/tests/traits/WidgetMakerTest.php similarity index 93% rename from tests/unit/backend/traits/WidgetMakerTest.php rename to modules/backend/tests/traits/WidgetMakerTest.php index 9a290b509e..4d1caf2df9 100644 --- a/tests/unit/backend/traits/WidgetMakerTest.php +++ b/modules/backend/tests/traits/WidgetMakerTest.php @@ -1,5 +1,8 @@ actingAs($user); + + $form = $this->restrictedFormFixture(); + + $form->render(); + $this->assertNull($form->getField('testRestricted')); + } + + public function testRestrictedFieldWithUserWithWrongPermissions() + { + $user = new UserFixture; + $this->actingAs($user->withPermission('test.wrong_permission', true)); + + $form = $this->restrictedFormFixture(); + + $form->render(); + $this->assertNull($form->getField('testRestricted')); + } + + public function testRestrictedFieldWithUserWithRightPermissions() + { + $user = new UserFixture; + $this->actingAs($user->withPermission('test.access_field', true)); + + $form = $this->restrictedFormFixture(); + + $form->render(); + $this->assertNotNull($form->getField('testRestricted')); + } + + public function testRestrictedFieldWithUserWithRightWildcardPermissions() + { + $user = new UserFixture; + $this->actingAs($user->withPermission('test.access_field', true)); + + $form = new Form(null, [ + 'model' => new FormTestModel, + 'arrayName' => 'array', + 'fields' => [ + 'testField' => [ + 'type' => 'text', + 'label' => 'Test 1' + ], + 'testRestricted' => [ + 'type' => 'text', + 'label' => 'Test 2', + 'permission' => 'test.*' + ] + ] + ]); + + $form->render(); + $this->assertNotNull($form->getField('testRestricted')); + } + + public function testRestrictedFieldWithSuperuser() + { + $user = new UserFixture; + $this->actingAs($user->asSuperUser()); + + $form = $this->restrictedFormFixture(); + + $form->render(); + $this->assertNotNull($form->getField('testRestricted')); + } + + public function testRestrictedFieldSinglePermissionWithUserWithWrongPermissions() + { + $user = new UserFixture; + $this->actingAs($user->withPermission('test.wrong_permission', true)); + + $form = $this->restrictedFormFixture(true); + + $form->render(); + $this->assertNull($form->getField('testRestricted')); + } + + public function testRestrictedFieldSinglePermissionWithUserWithRightPermissions() + { + $user = new UserFixture; + $this->actingAs($user->withPermission('test.access_field', true)); + + $form = $this->restrictedFormFixture(true); + + $form->render(); + $this->assertNotNull($form->getField('testRestricted')); + } + + public function testCheckboxlistTrigger() + { + $form = new Form(null, [ + 'model' => new FormTestModel, + 'arrayName' => 'array', + 'fields' => [ + 'trigger' => [ + 'type' => 'checkboxlist', + 'options' => [ + '1' => 'Value One' + ] + ], + 'triggered' => [ + 'type' => 'text', + 'trigger' => [ + 'field' => 'trigger[]', + 'action' => 'show', + 'condition' => 'value[1]' + ] + ] + ] + ]); + + $form->render(); + + $attributes = $form->getField('triggered')->getAttributes('container', false); + $this->assertEquals('[name="array[trigger][]"]', array_get($attributes, 'data-trigger')); + } + + public function testOptionsGeneration() + { + $form = new Form(null, [ + 'model' => new FormTestModel, + 'arrayName' => 'array', + 'fields' => [ + 'static_method_options' => [ + 'type' => 'dropdown', + 'options' => 'FormHelper::staticMethodOptions', + 'expect' => ['static', 'method'], + ], + 'callable_options' => [ + 'type' => 'dropdown', + 'options' => [\FormHelper::class, 'staticMethodOptions'], + 'expect' => ['static', 'method'], + ], + 'model_method_options' => [ + 'type' => 'dropdown', + 'options' => 'modelCustomOptionsMethod', + 'expect' => ['model', 'custom', 'options'], + ], + 'defined_options' => [ + 'type' => 'dropdown', + 'options' => ['value1', 'value2'], + 'expect' => ['value1', 'value2'], + ], + 'defined_options_key_value' => [ + 'type' => 'dropdown', + 'options' => [ + 'key1' => 'value1', + 'key2' => 'value2', + ], + 'expect' => [ + 'key1' => 'value1', + 'key2' => 'value2', + ], + ], + 'field_name_on_model_options_method' => [ + 'type' => 'dropdown', + 'expect' => ['model', 'field name', 'options method'], + ], + 'get_dropdown_options_method' => [ + 'type' => 'dropdown', + 'expect' => ['dropdown', 'options'], + ], + ] + ]); + + $form->render(); + + foreach ($form->getFields() as $name => $field) { + $this->assertEquals($field->options(), $field->config['expect']); + } + } + + protected function restrictedFormFixture(bool $singlePermission = false) + { + return new Form(null, [ + 'model' => new FormTestModel, + 'arrayName' => 'array', + 'fields' => [ + 'testField' => [ + 'type' => 'text', + 'label' => 'Test 1' + ], + 'testRestricted' => [ + 'type' => 'text', + 'label' => 'Test 2', + 'permissions' => ($singlePermission) ? 'test.access_field' : [ + 'test.access_field' + ] + ] + ] + ]); + } + } +} + +namespace +{ + class FormHelper + { + public static function staticMethodOptions() + { + return ['static', 'method']; + } + } +} diff --git a/tests/unit/backend/widgets/ListsTest.php b/modules/backend/tests/widgets/ListsTest.php similarity index 97% rename from tests/unit/backend/widgets/ListsTest.php rename to modules/backend/tests/widgets/ListsTest.php index 1df36b14d6..43e194d332 100644 --- a/tests/unit/backend/widgets/ListsTest.php +++ b/modules/backend/tests/widgets/ListsTest.php @@ -1,9 +1,12 @@ + + + + ./tests + + + + + + + + diff --git a/tests/unit/cms/classes/AssetTest.php b/modules/cms/tests/classes/AssetTest.php similarity index 98% rename from tests/unit/cms/classes/AssetTest.php rename to modules/cms/tests/classes/AssetTest.php index 7325d473e5..c7be820af1 100644 --- a/tests/unit/cms/classes/AssetTest.php +++ b/modules/cms/tests/classes/AssetTest.php @@ -1,14 +1,16 @@ assertStringContainsString( 'console.log(\'script1.js\');', diff --git a/tests/unit/cms/classes/CmsCompoundObjectTest.php b/modules/cms/tests/classes/CmsCompoundObjectTest.php similarity index 90% rename from tests/unit/cms/classes/CmsCompoundObjectTest.php rename to modules/cms/tests/classes/CmsCompoundObjectTest.php index e861ef0b90..19b03df8cf 100644 --- a/tests/unit/cms/classes/CmsCompoundObjectTest.php +++ b/modules/cms/tests/classes/CmsCompoundObjectTest.php @@ -1,8 +1,11 @@ assertFileExists($srcPath); $testContent = file_get_contents($srcPath); $this->assertNotEmpty($testContent); @@ -199,7 +202,7 @@ public function testSaveMarkup() { $theme = Theme::load('apitest'); - $destFilePath = $theme->getPath().'/testobjects/compound-markup.htm'; + $destFilePath = $theme->getPath() . '/testobjects/compound-markup.htm'; if (file_exists($destFilePath)) { unlink($destFilePath); } @@ -209,11 +212,11 @@ public function testSaveMarkup() $obj = TestCmsCompoundObject::inTheme($theme); $obj->fill([ 'markup' => '

Hello, world!

', - 'fileName'=>'compound-markup' + 'fileName' => 'compound-markup' ]); $obj->save(); - $referenceFilePath = base_path().'/tests/fixtures/cms/reference/compound-markup.htm'; + $referenceFilePath = base_path() . '/modules/cms/tests/fixtures/reference/compound-markup.htm'; $this->assertFileExists($referenceFilePath); $this->assertFileExists($destFilePath); @@ -224,7 +227,7 @@ public function testSaveMarkupAndSettings() { $theme = Theme::load('apitest'); - $destFilePath = $theme->getPath().'/testobjects/compound-markup-settings.htm'; + $destFilePath = $theme->getPath() . '/testobjects/compound-markup-settings.htm'; if (file_exists($destFilePath)) { unlink($destFilePath); } @@ -233,13 +236,13 @@ public function testSaveMarkupAndSettings() $obj = TestCmsCompoundObject::inTheme($theme); $obj->fill([ - 'settings'=>['var'=>'value'], + 'settings' => ['var' => 'value'], 'markup' => '

Hello, world!

', - 'fileName'=>'compound-markup-settings' + 'fileName' => 'compound-markup-settings' ]); $obj->save(); - $referenceFilePath = base_path().'/tests/fixtures/cms/reference/compound-markup-settings.htm'; + $referenceFilePath = base_path() . '/modules/cms/tests/fixtures/reference/compound-markup-settings.htm'; $this->assertFileExists($referenceFilePath); $this->assertFileExists($destFilePath); @@ -250,7 +253,7 @@ public function testSaveFull() { $theme = Theme::load('apitest'); - $destFilePath = $theme->getPath().'/testobjects/compound.htm'; + $destFilePath = $theme->getPath() . '/testobjects/compound.htm'; if (file_exists($destFilePath)) { unlink($destFilePath); } @@ -259,14 +262,14 @@ public function testSaveFull() $obj = TestCmsCompoundObject::inTheme($theme); $obj->fill([ - 'fileName'=>'compound', - 'settings'=>['var'=>'value'], + 'fileName' => 'compound', + 'settings' => ['var' => 'value'], 'code' => 'function a() {return true;}', 'markup' => '

Hello, world!

' ]); $obj->save(); - $referenceFilePath = base_path().'/tests/fixtures/cms/reference/compound-full.htm'; + $referenceFilePath = base_path() . '/modules/cms/tests/fixtures/reference/compound-full.htm'; $this->assertFileExists($referenceFilePath); $this->assertFileExists($destFilePath); diff --git a/tests/unit/cms/classes/CmsExceptionTest.php b/modules/cms/tests/classes/CmsExceptionTest.php similarity index 93% rename from tests/unit/cms/classes/CmsExceptionTest.php rename to modules/cms/tests/classes/CmsExceptionTest.php index cdc3e4bb2e..2dc127f845 100644 --- a/tests/unit/cms/classes/CmsExceptionTest.php +++ b/modules/cms/tests/classes/CmsExceptionTest.php @@ -1,12 +1,11 @@ property('posts-per-page') == '69'; diff --git a/tests/unit/cms/classes/CmsObjectTest.php b/modules/cms/tests/classes/CmsObjectTest.php similarity index 93% rename from tests/unit/cms/classes/CmsObjectTest.php rename to modules/cms/tests/classes/CmsObjectTest.php index ca5418462d..9d3f3b4b99 100644 --- a/tests/unit/cms/classes/CmsObjectTest.php +++ b/modules/cms/tests/classes/CmsObjectTest.php @@ -1,5 +1,8 @@ assertEquals('

This is a test HTML content file.

', $obj->getContent()); $this->assertEquals('plain.html', $obj->getFileName()); - $path = str_replace('/', DIRECTORY_SEPARATOR, $theme->getPath().'/testobjects/plain.html'); + $path = str_replace('/', DIRECTORY_SEPARATOR, $theme->getPath() . '/testobjects/plain.html'); $this->assertEquals($path, $obj->getFilePath()); $this->assertEquals(filemtime($path), $obj->mtime); } @@ -38,7 +41,7 @@ public function testLoadFromSubdirectory() $this->assertEquals('

This is an object in a subdirectory.

', $obj->getContent()); $this->assertEquals('subdir/obj.html', $obj->getFileName()); - $path = str_replace('/', DIRECTORY_SEPARATOR, $theme->getPath().'/testobjects/subdir/obj.html'); + $path = str_replace('/', DIRECTORY_SEPARATOR, $theme->getPath() . '/testobjects/subdir/obj.html'); $this->assertEquals($path, $obj->getFilePath()); $this->assertEquals(filemtime($path), $obj->mtime); } @@ -214,7 +217,7 @@ public function testSave() { $theme = Theme::load('apitest'); - $destFilePath = $theme->getPath().'/testobjects/mytestobj.htm'; + $destFilePath = $theme->getPath() . '/testobjects/mytestobj.htm'; if (file_exists($destFilePath)) { unlink($destFilePath); } @@ -240,10 +243,10 @@ public function testRename() { $theme = Theme::load('apitest'); - $srcFilePath = $theme->getPath().'/testobjects/mytestobj.htm'; + $srcFilePath = $theme->getPath() . '/testobjects/mytestobj.htm'; $this->assertFileExists($srcFilePath); - $destFilePath = $theme->getPath().'/testobjects/anotherobj.htm'; + $destFilePath = $theme->getPath() . '/testobjects/anotherobj.htm'; if (file_exists($destFilePath)) { unlink($destFilePath); } @@ -272,10 +275,10 @@ public function testRenameToExistingFile() $theme = Theme::load('apitest'); - $srcFilePath = $theme->getPath().'/testobjects/anotherobj.htm'; + $srcFilePath = $theme->getPath() . '/testobjects/anotherobj.htm'; $this->assertFileExists($srcFilePath); - $destFilePath = $theme->getPath().'/testobjects/existingobj.htm'; + $destFilePath = $theme->getPath() . '/testobjects/existingobj.htm'; if (!file_exists($destFilePath)) { file_put_contents($destFilePath, 'str'); } @@ -293,7 +296,7 @@ public function testSaveSameName() { $theme = Theme::load('apitest'); - $filePath = $theme->getPath().'/testobjects/anotherobj.htm'; + $filePath = $theme->getPath() . '/testobjects/anotherobj.htm'; $this->assertFileExists($filePath); $testContents = 'new content'; @@ -313,7 +316,7 @@ public function testSaveNewDir() { $theme = Theme::load('apitest'); - $destFilePath = $theme->getPath().'/testobjects/testsubdir/mytestobj.htm'; + $destFilePath = $theme->getPath() . '/testobjects/testsubdir/mytestobj.htm'; if (file_exists($destFilePath)) { unlink($destFilePath); } diff --git a/tests/unit/cms/classes/CodeParserTest.php b/modules/cms/tests/classes/CodeParserTest.php similarity index 96% rename from tests/unit/cms/classes/CodeParserTest.php rename to modules/cms/tests/classes/CodeParserTest.php index 67d8f30e93..519d0dcc59 100644 --- a/tests/unit/cms/classes/CodeParserTest.php +++ b/modules/cms/tests/classes/CodeParserTest.php @@ -1,16 +1,21 @@ source($page, null, $controller); $this->assertInstanceOf(PageCode::class, $obj); - $referenceFilePath = base_path() . '/tests/fixtures/cms/reference/namespaces.php.stub'; + $referenceFilePath = base_path() . '/modules/cms/tests/fixtures/reference/namespaces.php.stub'; $this->assertFileExists($referenceFilePath); $referenceContents = $this->getContents($referenceFilePath); @@ -295,7 +300,7 @@ public function testNamespacesAliases() $obj = $parser->source($page, null, $controller); $this->assertInstanceOf(PageCode::class, $obj); - $referenceFilePath = base_path() . '/tests/fixtures/cms/reference/namespaces-aliases.php.stub'; + $referenceFilePath = base_path() . '/modules/cms/tests/fixtures/reference/namespaces-aliases.php.stub'; $this->assertFileExists($referenceFilePath); $referenceContents = $this->getContents($referenceFilePath); diff --git a/tests/unit/cms/classes/ComponentManagerTest.php b/modules/cms/tests/classes/ComponentManagerTest.php similarity index 82% rename from tests/unit/cms/classes/ComponentManagerTest.php rename to modules/cms/tests/classes/ComponentManagerTest.php index 45f3d01dbc..a28abbf646 100644 --- a/tests/unit/cms/classes/ComponentManagerTest.php +++ b/modules/cms/tests/classes/ComponentManagerTest.php @@ -1,24 +1,27 @@ spoofPageCode(); @@ -114,7 +117,7 @@ public function testMakeComponent() public function testDefineProperties() { - include_once base_path() . '/tests/fixtures/plugins/winter/tester/components/Archive.php'; + include_once base_path() . '/modules/system/tests/fixtures/plugins/winter/tester/components/Archive.php'; $manager = ComponentManager::instance(); $object = $manager->makeComponent('testArchive'); $details = $object->componentDetails(); diff --git a/tests/unit/cms/classes/ContentTest.php b/modules/cms/tests/classes/ContentTest.php similarity index 95% rename from tests/unit/cms/classes/ContentTest.php rename to modules/cms/tests/classes/ContentTest.php index 790501c6f8..7b1298ee88 100644 --- a/tests/unit/cms/classes/ContentTest.php +++ b/modules/cms/tests/classes/ContentTest.php @@ -1,7 +1,10 @@ assertNotEmpty($response); $this->assertInstanceOf('\Illuminate\Http\Response', $response); ob_start(); - include base_path().'/modules/cms/views/404.php'; + include base_path() . '/modules/cms/views/404.php'; $page404Content = ob_get_contents(); ob_end_clean(); $this->assertEquals($page404Content, $response->getContent()); @@ -358,7 +362,7 @@ public function testBasicComponents() public function testComponentAliases() { - include_once base_path() . '/tests/fixtures/plugins/winter/tester/components/Archive.php'; + include_once base_path() . '/modules/system/tests/fixtures/plugins/winter/tester/components/Archive.php'; $theme = Theme::load('test'); $controller = new Controller($theme); diff --git a/tests/unit/cms/classes/PageTest.php b/modules/cms/tests/classes/PageTest.php similarity index 92% rename from tests/unit/cms/classes/PageTest.php rename to modules/cms/tests/classes/PageTest.php index 7a3933406a..e2cbeebd4b 100644 --- a/tests/unit/cms/classes/PageTest.php +++ b/modules/cms/tests/classes/PageTest.php @@ -1,5 +1,8 @@ stackPartial(); - $stack->addComponent('override1', 'Winter\Tester\Components\MainMenu'); - $stack->addComponent('override2', 'Winter\Tester\Components\ContentBlock'); + $stack->addComponent('override1', 'Winter\Tester\Components\MainMenu'); + $stack->addComponent('override2', 'Winter\Tester\Components\ContentBlock'); - $stack->stackPartial(); - $stack->addComponent('override3', 'Winter\Tester\Components\Post'); - $stack->addComponent('post', 'Winter\Tester\Components\Post'); + $stack->stackPartial(); + $stack->addComponent('override3', 'Winter\Tester\Components\Post'); + $stack->addComponent('post', 'Winter\Tester\Components\Post'); - $stack->stackPartial(); - $stack->addComponent('mainMenu', 'Winter\Tester\Components\MainMenu'); + $stack->stackPartial(); + $stack->addComponent('mainMenu', 'Winter\Tester\Components\MainMenu'); /* * Knock em down diff --git a/tests/unit/cms/classes/RouterTest.php b/modules/cms/tests/classes/RouterTest.php similarity index 98% rename from tests/unit/cms/classes/RouterTest.php rename to modules/cms/tests/classes/RouterTest.php index f4eeda27ac..0cb61343cb 100644 --- a/tests/unit/cms/classes/RouterTest.php +++ b/modules/cms/tests/classes/RouterTest.php @@ -1,13 +1,17 @@ setMaxDepth(1); $it->rewind(); @@ -39,7 +44,7 @@ public function testGetPath() $theme = Theme::load('test'); - $this->assertEquals(base_path('tests/fixtures/themes/test'), $theme->getPath()); + $this->assertEquals(base_path('modules/cms/tests/fixtures/themes/test'), $theme->getPath()); } public function testListPages() @@ -50,7 +55,7 @@ public function testListPages() $pages = array_values($pageCollection->all()); $this->assertIsArray($pages); - $expectedPageNum = $this->countThemePages(base_path().'/tests/fixtures/themes/test/pages'); + $expectedPageNum = $this->countThemePages(base_path() . '/modules/cms/tests/fixtures/themes/test/pages'); $this->assertCount($expectedPageNum, $pages); $this->assertInstanceOf('\Cms\Classes\Page', $pages[0]); diff --git a/tests/fixtures/cms/reference/compound-full.htm b/modules/cms/tests/fixtures/reference/compound-full.htm similarity index 100% rename from tests/fixtures/cms/reference/compound-full.htm rename to modules/cms/tests/fixtures/reference/compound-full.htm diff --git a/tests/fixtures/cms/reference/compound-markup-settings.htm b/modules/cms/tests/fixtures/reference/compound-markup-settings.htm similarity index 100% rename from tests/fixtures/cms/reference/compound-markup-settings.htm rename to modules/cms/tests/fixtures/reference/compound-markup-settings.htm diff --git a/tests/fixtures/cms/reference/compound-markup.htm b/modules/cms/tests/fixtures/reference/compound-markup.htm similarity index 100% rename from tests/fixtures/cms/reference/compound-markup.htm rename to modules/cms/tests/fixtures/reference/compound-markup.htm diff --git a/tests/fixtures/cms/reference/namespaces-aliases.php.stub b/modules/cms/tests/fixtures/reference/namespaces-aliases.php.stub similarity index 100% rename from tests/fixtures/cms/reference/namespaces-aliases.php.stub rename to modules/cms/tests/fixtures/reference/namespaces-aliases.php.stub diff --git a/tests/fixtures/cms/reference/namespaces.php.stub b/modules/cms/tests/fixtures/reference/namespaces.php.stub similarity index 100% rename from tests/fixtures/cms/reference/namespaces.php.stub rename to modules/cms/tests/fixtures/reference/namespaces.php.stub diff --git a/tests/fixtures/themes/apitest/.gitignore b/modules/cms/tests/fixtures/themes/apitest/.gitignore similarity index 100% rename from tests/fixtures/themes/apitest/.gitignore rename to modules/cms/tests/fixtures/themes/apitest/.gitignore diff --git a/tests/fixtures/themes/test/assets/css/style1.css b/modules/cms/tests/fixtures/themes/test/assets/css/style1.css similarity index 100% rename from tests/fixtures/themes/test/assets/css/style1.css rename to modules/cms/tests/fixtures/themes/test/assets/css/style1.css diff --git a/tests/fixtures/themes/test/assets/css/style2.css b/modules/cms/tests/fixtures/themes/test/assets/css/style2.css similarity index 100% rename from tests/fixtures/themes/test/assets/css/style2.css rename to modules/cms/tests/fixtures/themes/test/assets/css/style2.css diff --git a/tests/fixtures/media/winter.png b/modules/cms/tests/fixtures/themes/test/assets/images/winter.png similarity index 100% rename from tests/fixtures/media/winter.png rename to modules/cms/tests/fixtures/themes/test/assets/images/winter.png diff --git a/tests/fixtures/themes/test/assets/js/script1.js b/modules/cms/tests/fixtures/themes/test/assets/js/script1.js similarity index 100% rename from tests/fixtures/themes/test/assets/js/script1.js rename to modules/cms/tests/fixtures/themes/test/assets/js/script1.js diff --git a/tests/fixtures/themes/test/assets/js/script2.js b/modules/cms/tests/fixtures/themes/test/assets/js/script2.js similarity index 100% rename from tests/fixtures/themes/test/assets/js/script2.js rename to modules/cms/tests/fixtures/themes/test/assets/js/script2.js diff --git a/tests/fixtures/themes/test/assets/js/subdir/script1.js b/modules/cms/tests/fixtures/themes/test/assets/js/subdir/script1.js similarity index 100% rename from tests/fixtures/themes/test/assets/js/subdir/script1.js rename to modules/cms/tests/fixtures/themes/test/assets/js/subdir/script1.js diff --git a/tests/fixtures/themes/test/content/a/a-content.htm b/modules/cms/tests/fixtures/themes/test/content/a/a-content.htm similarity index 100% rename from tests/fixtures/themes/test/content/a/a-content.htm rename to modules/cms/tests/fixtures/themes/test/content/a/a-content.htm diff --git a/tests/fixtures/themes/test/content/html-content.htm b/modules/cms/tests/fixtures/themes/test/content/html-content.htm similarity index 100% rename from tests/fixtures/themes/test/content/html-content.htm rename to modules/cms/tests/fixtures/themes/test/content/html-content.htm diff --git a/tests/fixtures/themes/test/content/layout-content.txt b/modules/cms/tests/fixtures/themes/test/content/layout-content.txt similarity index 100% rename from tests/fixtures/themes/test/content/layout-content.txt rename to modules/cms/tests/fixtures/themes/test/content/layout-content.txt diff --git a/tests/fixtures/themes/test/content/markdown-content.md b/modules/cms/tests/fixtures/themes/test/content/markdown-content.md similarity index 100% rename from tests/fixtures/themes/test/content/markdown-content.md rename to modules/cms/tests/fixtures/themes/test/content/markdown-content.md diff --git a/tests/fixtures/themes/test/content/page-content.htm b/modules/cms/tests/fixtures/themes/test/content/page-content.htm similarity index 100% rename from tests/fixtures/themes/test/content/page-content.htm rename to modules/cms/tests/fixtures/themes/test/content/page-content.htm diff --git a/tests/fixtures/themes/test/content/text-content.txt b/modules/cms/tests/fixtures/themes/test/content/text-content.txt similarity index 100% rename from tests/fixtures/themes/test/content/text-content.txt rename to modules/cms/tests/fixtures/themes/test/content/text-content.txt diff --git a/tests/fixtures/themes/test/layouts/a/a-layout.htm b/modules/cms/tests/fixtures/themes/test/layouts/a/a-layout.htm similarity index 100% rename from tests/fixtures/themes/test/layouts/a/a-layout.htm rename to modules/cms/tests/fixtures/themes/test/layouts/a/a-layout.htm diff --git a/tests/fixtures/themes/test/layouts/ajax-test.htm b/modules/cms/tests/fixtures/themes/test/layouts/ajax-test.htm similarity index 100% rename from tests/fixtures/themes/test/layouts/ajax-test.htm rename to modules/cms/tests/fixtures/themes/test/layouts/ajax-test.htm diff --git a/tests/fixtures/themes/test/layouts/content.htm b/modules/cms/tests/fixtures/themes/test/layouts/content.htm similarity index 100% rename from tests/fixtures/themes/test/layouts/content.htm rename to modules/cms/tests/fixtures/themes/test/layouts/content.htm diff --git a/tests/fixtures/themes/test/layouts/cycle-test.htm b/modules/cms/tests/fixtures/themes/test/layouts/cycle-test.htm similarity index 100% rename from tests/fixtures/themes/test/layouts/cycle-test.htm rename to modules/cms/tests/fixtures/themes/test/layouts/cycle-test.htm diff --git a/tests/fixtures/themes/test/layouts/no-php.htm b/modules/cms/tests/fixtures/themes/test/layouts/no-php.htm similarity index 100% rename from tests/fixtures/themes/test/layouts/no-php.htm rename to modules/cms/tests/fixtures/themes/test/layouts/no-php.htm diff --git a/tests/fixtures/themes/test/layouts/partials.htm b/modules/cms/tests/fixtures/themes/test/layouts/partials.htm similarity index 100% rename from tests/fixtures/themes/test/layouts/partials.htm rename to modules/cms/tests/fixtures/themes/test/layouts/partials.htm diff --git a/tests/fixtures/themes/test/layouts/php-parser-test.htm b/modules/cms/tests/fixtures/themes/test/layouts/php-parser-test.htm similarity index 100% rename from tests/fixtures/themes/test/layouts/php-parser-test.htm rename to modules/cms/tests/fixtures/themes/test/layouts/php-parser-test.htm diff --git a/tests/fixtures/themes/test/layouts/placeholder.htm b/modules/cms/tests/fixtures/themes/test/layouts/placeholder.htm similarity index 100% rename from tests/fixtures/themes/test/layouts/placeholder.htm rename to modules/cms/tests/fixtures/themes/test/layouts/placeholder.htm diff --git a/tests/fixtures/themes/test/layouts/sidebar.htm b/modules/cms/tests/fixtures/themes/test/layouts/sidebar.htm similarity index 100% rename from tests/fixtures/themes/test/layouts/sidebar.htm rename to modules/cms/tests/fixtures/themes/test/layouts/sidebar.htm diff --git a/tests/fixtures/themes/test/pages/404.htm b/modules/cms/tests/fixtures/themes/test/pages/404.htm similarity index 100% rename from tests/fixtures/themes/test/pages/404.htm rename to modules/cms/tests/fixtures/themes/test/pages/404.htm diff --git a/tests/fixtures/themes/test/pages/a/a-page.htm b/modules/cms/tests/fixtures/themes/test/pages/a/a-page.htm similarity index 100% rename from tests/fixtures/themes/test/pages/a/a-page.htm rename to modules/cms/tests/fixtures/themes/test/pages/a/a-page.htm diff --git a/tests/fixtures/themes/test/pages/ajax-test.htm b/modules/cms/tests/fixtures/themes/test/pages/ajax-test.htm similarity index 100% rename from tests/fixtures/themes/test/pages/ajax-test.htm rename to modules/cms/tests/fixtures/themes/test/pages/ajax-test.htm diff --git a/tests/fixtures/themes/test/pages/authors.htm b/modules/cms/tests/fixtures/themes/test/pages/authors.htm similarity index 100% rename from tests/fixtures/themes/test/pages/authors.htm rename to modules/cms/tests/fixtures/themes/test/pages/authors.htm diff --git a/tests/fixtures/themes/test/pages/b/b-page.htm b/modules/cms/tests/fixtures/themes/test/pages/b/b-page.htm similarity index 100% rename from tests/fixtures/themes/test/pages/b/b-page.htm rename to modules/cms/tests/fixtures/themes/test/pages/b/b-page.htm diff --git a/tests/fixtures/themes/test/pages/b/c/c-page.htm b/modules/cms/tests/fixtures/themes/test/pages/b/c/c-page.htm similarity index 100% rename from tests/fixtures/themes/test/pages/b/c/c-page.htm rename to modules/cms/tests/fixtures/themes/test/pages/b/c/c-page.htm diff --git a/tests/fixtures/themes/test/pages/blog-archive.htm b/modules/cms/tests/fixtures/themes/test/pages/blog-archive.htm similarity index 100% rename from tests/fixtures/themes/test/pages/blog-archive.htm rename to modules/cms/tests/fixtures/themes/test/pages/blog-archive.htm diff --git a/tests/fixtures/themes/test/pages/blog-category.htm b/modules/cms/tests/fixtures/themes/test/pages/blog-category.htm similarity index 100% rename from tests/fixtures/themes/test/pages/blog-category.htm rename to modules/cms/tests/fixtures/themes/test/pages/blog-category.htm diff --git a/tests/fixtures/themes/test/pages/blog-post.htm b/modules/cms/tests/fixtures/themes/test/pages/blog-post.htm similarity index 100% rename from tests/fixtures/themes/test/pages/blog-post.htm rename to modules/cms/tests/fixtures/themes/test/pages/blog-post.htm diff --git a/tests/fixtures/themes/test/pages/code-namespaces-aliases.htm b/modules/cms/tests/fixtures/themes/test/pages/code-namespaces-aliases.htm similarity index 100% rename from tests/fixtures/themes/test/pages/code-namespaces-aliases.htm rename to modules/cms/tests/fixtures/themes/test/pages/code-namespaces-aliases.htm diff --git a/tests/fixtures/themes/test/pages/code-namespaces.htm b/modules/cms/tests/fixtures/themes/test/pages/code-namespaces.htm similarity index 100% rename from tests/fixtures/themes/test/pages/code-namespaces.htm rename to modules/cms/tests/fixtures/themes/test/pages/code-namespaces.htm diff --git a/tests/fixtures/themes/test/pages/component-custom-render.htm b/modules/cms/tests/fixtures/themes/test/pages/component-custom-render.htm similarity index 100% rename from tests/fixtures/themes/test/pages/component-custom-render.htm rename to modules/cms/tests/fixtures/themes/test/pages/component-custom-render.htm diff --git a/tests/fixtures/themes/test/pages/component-partial-alias-override.htm b/modules/cms/tests/fixtures/themes/test/pages/component-partial-alias-override.htm similarity index 100% rename from tests/fixtures/themes/test/pages/component-partial-alias-override.htm rename to modules/cms/tests/fixtures/themes/test/pages/component-partial-alias-override.htm diff --git a/tests/fixtures/themes/test/pages/component-partial-nesting.htm b/modules/cms/tests/fixtures/themes/test/pages/component-partial-nesting.htm similarity index 100% rename from tests/fixtures/themes/test/pages/component-partial-nesting.htm rename to modules/cms/tests/fixtures/themes/test/pages/component-partial-nesting.htm diff --git a/tests/fixtures/themes/test/pages/component-partial-override.htm b/modules/cms/tests/fixtures/themes/test/pages/component-partial-override.htm similarity index 100% rename from tests/fixtures/themes/test/pages/component-partial-override.htm rename to modules/cms/tests/fixtures/themes/test/pages/component-partial-override.htm diff --git a/tests/fixtures/themes/test/pages/component-partial.htm b/modules/cms/tests/fixtures/themes/test/pages/component-partial.htm similarity index 100% rename from tests/fixtures/themes/test/pages/component-partial.htm rename to modules/cms/tests/fixtures/themes/test/pages/component-partial.htm diff --git a/tests/fixtures/themes/test/pages/cycle-test.htm b/modules/cms/tests/fixtures/themes/test/pages/cycle-test.htm similarity index 100% rename from tests/fixtures/themes/test/pages/cycle-test.htm rename to modules/cms/tests/fixtures/themes/test/pages/cycle-test.htm diff --git a/tests/fixtures/themes/test/pages/filters-test.htm b/modules/cms/tests/fixtures/themes/test/pages/filters-test.htm similarity index 100% rename from tests/fixtures/themes/test/pages/filters-test.htm rename to modules/cms/tests/fixtures/themes/test/pages/filters-test.htm diff --git a/tests/fixtures/themes/test/pages/index.htm b/modules/cms/tests/fixtures/themes/test/pages/index.htm similarity index 100% rename from tests/fixtures/themes/test/pages/index.htm rename to modules/cms/tests/fixtures/themes/test/pages/index.htm diff --git a/tests/fixtures/themes/test/pages/no-component-class.htm b/modules/cms/tests/fixtures/themes/test/pages/no-component-class.htm similarity index 100% rename from tests/fixtures/themes/test/pages/no-component-class.htm rename to modules/cms/tests/fixtures/themes/test/pages/no-component-class.htm diff --git a/tests/fixtures/themes/test/pages/no-component.htm b/modules/cms/tests/fixtures/themes/test/pages/no-component.htm similarity index 100% rename from tests/fixtures/themes/test/pages/no-component.htm rename to modules/cms/tests/fixtures/themes/test/pages/no-component.htm diff --git a/tests/fixtures/themes/test/pages/no-layout.htm b/modules/cms/tests/fixtures/themes/test/pages/no-layout.htm similarity index 100% rename from tests/fixtures/themes/test/pages/no-layout.htm rename to modules/cms/tests/fixtures/themes/test/pages/no-layout.htm diff --git a/tests/fixtures/themes/test/pages/no-partial.htm b/modules/cms/tests/fixtures/themes/test/pages/no-partial.htm similarity index 100% rename from tests/fixtures/themes/test/pages/no-partial.htm rename to modules/cms/tests/fixtures/themes/test/pages/no-partial.htm diff --git a/tests/fixtures/themes/test/pages/no-soft-component-class.htm b/modules/cms/tests/fixtures/themes/test/pages/no-soft-component-class.htm similarity index 100% rename from tests/fixtures/themes/test/pages/no-soft-component-class.htm rename to modules/cms/tests/fixtures/themes/test/pages/no-soft-component-class.htm diff --git a/tests/fixtures/themes/test/pages/optional-full-php-tags.htm b/modules/cms/tests/fixtures/themes/test/pages/optional-full-php-tags.htm similarity index 100% rename from tests/fixtures/themes/test/pages/optional-full-php-tags.htm rename to modules/cms/tests/fixtures/themes/test/pages/optional-full-php-tags.htm diff --git a/tests/fixtures/themes/test/pages/optional-short-php-tags.htm b/modules/cms/tests/fixtures/themes/test/pages/optional-short-php-tags.htm similarity index 100% rename from tests/fixtures/themes/test/pages/optional-short-php-tags.htm rename to modules/cms/tests/fixtures/themes/test/pages/optional-short-php-tags.htm diff --git a/tests/fixtures/themes/test/pages/throw-php.htm b/modules/cms/tests/fixtures/themes/test/pages/throw-php.htm similarity index 100% rename from tests/fixtures/themes/test/pages/throw-php.htm rename to modules/cms/tests/fixtures/themes/test/pages/throw-php.htm diff --git a/tests/fixtures/themes/test/pages/with-component.htm b/modules/cms/tests/fixtures/themes/test/pages/with-component.htm similarity index 100% rename from tests/fixtures/themes/test/pages/with-component.htm rename to modules/cms/tests/fixtures/themes/test/pages/with-component.htm diff --git a/tests/fixtures/themes/test/pages/with-components.htm b/modules/cms/tests/fixtures/themes/test/pages/with-components.htm similarity index 100% rename from tests/fixtures/themes/test/pages/with-components.htm rename to modules/cms/tests/fixtures/themes/test/pages/with-components.htm diff --git a/tests/fixtures/themes/test/pages/with-content.htm b/modules/cms/tests/fixtures/themes/test/pages/with-content.htm similarity index 100% rename from tests/fixtures/themes/test/pages/with-content.htm rename to modules/cms/tests/fixtures/themes/test/pages/with-content.htm diff --git a/tests/fixtures/themes/test/pages/with-layout.htm b/modules/cms/tests/fixtures/themes/test/pages/with-layout.htm similarity index 100% rename from tests/fixtures/themes/test/pages/with-layout.htm rename to modules/cms/tests/fixtures/themes/test/pages/with-layout.htm diff --git a/tests/fixtures/themes/test/pages/with-partials.htm b/modules/cms/tests/fixtures/themes/test/pages/with-partials.htm similarity index 100% rename from tests/fixtures/themes/test/pages/with-partials.htm rename to modules/cms/tests/fixtures/themes/test/pages/with-partials.htm diff --git a/tests/fixtures/themes/test/pages/with-placeholder.htm b/modules/cms/tests/fixtures/themes/test/pages/with-placeholder.htm similarity index 100% rename from tests/fixtures/themes/test/pages/with-placeholder.htm rename to modules/cms/tests/fixtures/themes/test/pages/with-placeholder.htm diff --git a/tests/fixtures/themes/test/pages/with-soft-component-class-alias.htm b/modules/cms/tests/fixtures/themes/test/pages/with-soft-component-class-alias.htm similarity index 100% rename from tests/fixtures/themes/test/pages/with-soft-component-class-alias.htm rename to modules/cms/tests/fixtures/themes/test/pages/with-soft-component-class-alias.htm diff --git a/tests/fixtures/themes/test/pages/with-soft-component-class.htm b/modules/cms/tests/fixtures/themes/test/pages/with-soft-component-class.htm similarity index 100% rename from tests/fixtures/themes/test/pages/with-soft-component-class.htm rename to modules/cms/tests/fixtures/themes/test/pages/with-soft-component-class.htm diff --git a/tests/fixtures/themes/test/partials/a/a-partial.htm b/modules/cms/tests/fixtures/themes/test/partials/a/a-partial.htm similarity index 100% rename from tests/fixtures/themes/test/partials/a/a-partial.htm rename to modules/cms/tests/fixtures/themes/test/partials/a/a-partial.htm diff --git a/tests/fixtures/themes/test/partials/ajax-result.htm b/modules/cms/tests/fixtures/themes/test/partials/ajax-result.htm similarity index 100% rename from tests/fixtures/themes/test/partials/ajax-result.htm rename to modules/cms/tests/fixtures/themes/test/partials/ajax-result.htm diff --git a/tests/fixtures/themes/test/partials/ajax-second-result.htm b/modules/cms/tests/fixtures/themes/test/partials/ajax-second-result.htm similarity index 100% rename from tests/fixtures/themes/test/partials/ajax-second-result.htm rename to modules/cms/tests/fixtures/themes/test/partials/ajax-second-result.htm diff --git a/tests/fixtures/themes/test/partials/layout-partial.htm b/modules/cms/tests/fixtures/themes/test/partials/layout-partial.htm similarity index 100% rename from tests/fixtures/themes/test/partials/layout-partial.htm rename to modules/cms/tests/fixtures/themes/test/partials/layout-partial.htm diff --git a/tests/fixtures/themes/test/partials/nesting/level1.htm b/modules/cms/tests/fixtures/themes/test/partials/nesting/level1.htm similarity index 100% rename from tests/fixtures/themes/test/partials/nesting/level1.htm rename to modules/cms/tests/fixtures/themes/test/partials/nesting/level1.htm diff --git a/tests/fixtures/themes/test/partials/nesting/level2.htm b/modules/cms/tests/fixtures/themes/test/partials/nesting/level2.htm similarity index 100% rename from tests/fixtures/themes/test/partials/nesting/level2.htm rename to modules/cms/tests/fixtures/themes/test/partials/nesting/level2.htm diff --git a/tests/fixtures/themes/test/partials/nesting/level3.htm b/modules/cms/tests/fixtures/themes/test/partials/nesting/level3.htm similarity index 100% rename from tests/fixtures/themes/test/partials/nesting/level3.htm rename to modules/cms/tests/fixtures/themes/test/partials/nesting/level3.htm diff --git a/tests/fixtures/themes/test/partials/override1/default.htm b/modules/cms/tests/fixtures/themes/test/partials/override1/default.htm similarity index 100% rename from tests/fixtures/themes/test/partials/override1/default.htm rename to modules/cms/tests/fixtures/themes/test/partials/override1/default.htm diff --git a/tests/fixtures/themes/test/partials/override2/default.htm b/modules/cms/tests/fixtures/themes/test/partials/override2/default.htm similarity index 100% rename from tests/fixtures/themes/test/partials/override2/default.htm rename to modules/cms/tests/fixtures/themes/test/partials/override2/default.htm diff --git a/tests/fixtures/themes/test/partials/override2/items.htm b/modules/cms/tests/fixtures/themes/test/partials/override2/items.htm similarity index 100% rename from tests/fixtures/themes/test/partials/override2/items.htm rename to modules/cms/tests/fixtures/themes/test/partials/override2/items.htm diff --git a/tests/fixtures/themes/test/partials/override3/default.htm b/modules/cms/tests/fixtures/themes/test/partials/override3/default.htm similarity index 100% rename from tests/fixtures/themes/test/partials/override3/default.htm rename to modules/cms/tests/fixtures/themes/test/partials/override3/default.htm diff --git a/tests/fixtures/themes/test/partials/override4/default.htm b/modules/cms/tests/fixtures/themes/test/partials/override4/default.htm similarity index 100% rename from tests/fixtures/themes/test/partials/override4/default.htm rename to modules/cms/tests/fixtures/themes/test/partials/override4/default.htm diff --git a/tests/fixtures/themes/test/partials/page-partial.htm b/modules/cms/tests/fixtures/themes/test/partials/page-partial.htm similarity index 100% rename from tests/fixtures/themes/test/partials/page-partial.htm rename to modules/cms/tests/fixtures/themes/test/partials/page-partial.htm diff --git a/tests/fixtures/themes/test/partials/testpost/default.htm b/modules/cms/tests/fixtures/themes/test/partials/testpost/default.htm similarity index 100% rename from tests/fixtures/themes/test/partials/testpost/default.htm rename to modules/cms/tests/fixtures/themes/test/partials/testpost/default.htm diff --git a/tests/fixtures/themes/test/temporary/.gitignore b/modules/cms/tests/fixtures/themes/test/temporary/.gitignore similarity index 100% rename from tests/fixtures/themes/test/temporary/.gitignore rename to modules/cms/tests/fixtures/themes/test/temporary/.gitignore diff --git a/tests/fixtures/themes/test/testobjects/component.htm b/modules/cms/tests/fixtures/themes/test/testobjects/component.htm similarity index 100% rename from tests/fixtures/themes/test/testobjects/component.htm rename to modules/cms/tests/fixtures/themes/test/testobjects/component.htm diff --git a/tests/fixtures/themes/test/testobjects/components.htm b/modules/cms/tests/fixtures/themes/test/testobjects/components.htm similarity index 100% rename from tests/fixtures/themes/test/testobjects/components.htm rename to modules/cms/tests/fixtures/themes/test/testobjects/components.htm diff --git a/tests/fixtures/themes/test/testobjects/compound.htm b/modules/cms/tests/fixtures/themes/test/testobjects/compound.htm similarity index 100% rename from tests/fixtures/themes/test/testobjects/compound.htm rename to modules/cms/tests/fixtures/themes/test/testobjects/compound.htm diff --git a/tests/fixtures/themes/test/testobjects/plain.html b/modules/cms/tests/fixtures/themes/test/testobjects/plain.html similarity index 100% rename from tests/fixtures/themes/test/testobjects/plain.html rename to modules/cms/tests/fixtures/themes/test/testobjects/plain.html diff --git a/tests/fixtures/themes/test/testobjects/subdir/obj.html b/modules/cms/tests/fixtures/themes/test/testobjects/subdir/obj.html similarity index 100% rename from tests/fixtures/themes/test/testobjects/subdir/obj.html rename to modules/cms/tests/fixtures/themes/test/testobjects/subdir/obj.html diff --git a/tests/fixtures/themes/test/testobjects/viewbag.htm b/modules/cms/tests/fixtures/themes/test/testobjects/viewbag.htm similarity index 100% rename from tests/fixtures/themes/test/testobjects/viewbag.htm rename to modules/cms/tests/fixtures/themes/test/testobjects/viewbag.htm diff --git a/tests/unit/cms/helpers/FileTest.php b/modules/cms/tests/helpers/FileTest.php similarity index 90% rename from tests/unit/cms/helpers/FileTest.php rename to modules/cms/tests/helpers/FileTest.php index dde19f0c38..2e9496c352 100644 --- a/tests/unit/cms/helpers/FileTest.php +++ b/modules/cms/tests/helpers/FileTest.php @@ -1,6 +1,9 @@ setRoot($root); - } else { - $this->setRoot(base_path()); - } - - if (isset($modules)) { - $this->setModules($modules); - } else { - $this->setModules(Config::get('cms.loadModules', ['System', 'Backend', 'Cms'])); - } + $this->setRoot($root ?? base_path()); + $this->setModules($modules ?? Config::get('cms.loadModules', ['System', 'Backend', 'Cms'])); } /** * Sets the root folder. * - * @param string $root * @throws ApplicationException If the specified root does not exist. */ - public function setRoot($root) + public function setRoot(string $root): static { if (is_string($root)) { $this->root = realpath($root); @@ -95,10 +82,8 @@ public function setRoot($root) /** * Sets the modules. - * - * @param array $modules */ - public function setModules(array $modules) + public function setModules(array $modules): static { $this->modules = array_map(function ($module) { return strtolower($module); @@ -109,10 +94,8 @@ public function setModules(array $modules) /** * Gets a list of files and their corresponding hashsums. - * - * @return array */ - public function getFiles() + public function getFiles(): array { if (count($this->files)) { return $this->files; @@ -137,10 +120,8 @@ public function getFiles() /** * Gets the checksum of a specific install. - * - * @return array */ - public function getModuleChecksums() + public function getModuleChecksums(): array { if (!count($this->files)) { $this->getFiles(); @@ -165,11 +146,8 @@ public function getModuleChecksums() /** * Finds all files within the path. - * - * @param string $basePath The base path to look for files within. - * @return array */ - protected function findFiles(string $basePath) + protected function findFiles(string $basePath): array { $datasource = new FileDatasource($basePath, new Filesystem); @@ -185,9 +163,6 @@ protected function findFiles(string $basePath) /** * Returns the filename without the root. - * - * @param string $file - * @return string */ protected function getFilename(string $file): string { @@ -196,9 +171,6 @@ protected function getFilename(string $file): string /** * Normalises the file contents, irrespective of OS. - * - * @param string $file - * @return string */ protected function normalizeFileContents(string $file): string { diff --git a/modules/system/classes/PluginManager.php b/modules/system/classes/PluginManager.php index 04fed249d8..a613302385 100644 --- a/modules/system/classes/PluginManager.php +++ b/modules/system/classes/PluginManager.php @@ -136,7 +136,7 @@ public function loadPlugins(): array // Sort all the plugins by number of dependencies $this->sortByDependencies(); - return $this->plugins; + return $this->getAllPlugins(); } /** @@ -173,14 +173,15 @@ public function loadPlugin(string $namespace, string $path): ?PluginBase } $classId = $this->getIdentifier($pluginObj); + $lowerClassId = strtolower($classId); - $this->plugins[$classId] = $pluginObj; - $this->normalizedMap[strtolower($classId)] = $classId; + $this->plugins[$lowerClassId] = $pluginObj; + $this->normalizedMap[$lowerClassId] = $classId; $replaces = $pluginObj->getReplaces(); if ($replaces) { foreach ($replaces as $replace) { - $this->replacementMap[$replace] = $classId; + $this->replacementMap[strtolower($replace)] = $lowerClassId; } } @@ -226,7 +227,7 @@ public function loadPluginFlags(): void ]; }); - list($this->pluginFlag, $this->replacementMap, $this->activeReplacementMap) = $data; + list($this->pluginFlags, $this->replacementMap, $this->activeReplacementMap) = $data; } /** @@ -409,7 +410,14 @@ public function exists(PluginBase|string $plugin): bool */ public function getPlugins(): array { - return array_diff_key($this->plugins, $this->pluginFlags); + $activePlugins = array_diff_key($this->plugins, $this->pluginFlags); + return array_combine( + array_map( + fn($code) => $this->normalizedMap[$code], + array_keys($activePlugins) + ), + $activePlugins + ); } /** @@ -419,7 +427,13 @@ public function getPlugins(): array */ public function getAllPlugins(): array { - return $this->plugins; + $plugins = []; + + foreach ($this->plugins as $code => $plugin) { + $plugins[$this->normalizedMap[$code]] = $plugin; + } + + return $plugins; } /** @@ -427,7 +441,7 @@ public function getAllPlugins(): array */ public function findByNamespace(string $namespace): ?PluginBase { - $identifier = $this->getIdentifier($namespace); + $identifier = $this->getIdentifier($namespace, true); return $this->plugins[$identifier] ?? null; } @@ -441,12 +455,10 @@ public function findByIdentifier(PluginBase|string $identifier, bool $ignoreRepl return $identifier; } - if (!$ignoreReplacements && is_string($identifier) && isset($this->replacementMap[$identifier])) { - $identifier = $this->replacementMap[$identifier]; - } + $identifier = $this->getNormalizedIdentifier($identifier, true); - if (!isset($this->plugins[$identifier])) { - $identifier = $this->getNormalizedIdentifier($identifier); + if (!$ignoreReplacements && isset($this->replacementMap[$identifier])) { + $identifier = $this->replacementMap[$identifier]; } return $this->plugins[$identifier] ?? null; @@ -457,7 +469,7 @@ public function findByIdentifier(PluginBase|string $identifier, bool $ignoreRepl */ public function hasPlugin(PluginBase|string $plugin): bool { - $normalized = $this->getNormalizedIdentifier($plugin); + $normalized = $this->getNormalizedIdentifier($plugin, true); return isset($this->plugins[$normalized]) || isset($this->replacementMap[$normalized]); } @@ -518,7 +530,7 @@ public function getVendorAndPluginNames(): array * Resolves a plugin identifier (Author.Plugin) from a plugin class name * (Author\Plugin) or PluginBase instance. */ - public function getIdentifier(PluginBase|string $plugin): string + public function getIdentifier(PluginBase|string $plugin, bool $lower = false): string { $namespace = Str::normalizeClassName($plugin); if (strpos($namespace, '\\') === null) { @@ -529,7 +541,7 @@ public function getIdentifier(PluginBase|string $plugin): string $slice = array_slice($parts, 1, 2); $namespace = implode('.', $slice); - return $namespace; + return $lower ? strtolower($namespace) : $namespace; } /** @@ -565,9 +577,10 @@ public function normalizeIdentifier(string $code): string * Returns the normalized identifier (i.e. Winter.Blog) from the provided * string or PluginBase instance. */ - public function getNormalizedIdentifier(PluginBase|string $plugin): string + public function getNormalizedIdentifier(PluginBase|string $plugin, bool $lower = false): string { - return $this->normalizeIdentifier($this->getIdentifier($plugin)); + $identifier = $this->normalizeIdentifier($this->getIdentifier($plugin)); + return $lower ? strtolower($identifier) : $identifier; } /** @@ -600,7 +613,7 @@ public function getRegistrationMethodValues(string $methodName): array public function getPluginFlags(PluginBase|string $plugin): array { - $code = $this->getNormalizedIdentifier($plugin); + $code = $this->getNormalizedIdentifier($plugin, true); return $this->pluginFlags[$code] ?? []; } @@ -609,7 +622,7 @@ public function getPluginFlags(PluginBase|string $plugin): array */ protected function flagPlugin(PluginBase|string $plugin, string $flag): void { - $code = $this->getNormalizedIdentifier($plugin); + $code = $this->getNormalizedIdentifier($plugin, true); $this->pluginFlags[$code][$flag] = true; } @@ -618,7 +631,7 @@ protected function flagPlugin(PluginBase|string $plugin, string $flag): void */ protected function unflagPlugin(PluginBase|string $plugin, string $flag): void { - $code = $this->getNormalizedIdentifier($plugin); + $code = $this->getNormalizedIdentifier($plugin, true); unset($this->pluginFlags[$code][$flag]); } @@ -652,7 +665,7 @@ protected function loadDisabled(): void */ public function isDisabled(PluginBase|string $plugin): bool { - $code = $this->getNormalizedIdentifier($plugin); + $code = $this->getNormalizedIdentifier($plugin, true); // @TODO: Limit this to only disabled flags if we add more than disabled flags return !empty($this->pluginFlags[$code]); @@ -671,9 +684,18 @@ public function getReplacementMap(): array */ public function getActiveReplacementMap(PluginBase|string $plugin = null): array|string|null { - return $plugin - ? $this->activeReplacementMap[$this->getNormalizedIdentifier($plugin)] ?? null - : $this->activeReplacementMap; + if ($plugin) { + return $this->normalizedMap[ + $this->activeReplacementMap[$this->getNormalizedIdentifier($plugin, true)] ?? null + ] ?? null; + } + + $map = []; + foreach ($this->activeReplacementMap as $key => $value) { + $map[$this->normalizedMap[$key]] = $this->normalizedMap[$value]; + } + + return $map; } /** @@ -694,7 +716,12 @@ protected function detectPluginReplacements(): void // Only allow one of the replaced plugin or the replacing plugin to exist // at once depending on whether the version constraints are met or not - if ($this->plugins[$replacement]->canReplacePlugin($target, $this->plugins[$target]->getPluginVersion())) { + if ( + $this->plugins[$replacement]->canReplacePlugin( + $this->normalizeIdentifier($target), + $this->plugins[$target]->getPluginVersion() + ) + ) { // Set the plugin flags to disable the target plugin $this->flagPlugin($target, static::DISABLED_REPLACED); $this->unflagPlugin($replacement, static::DISABLED_REPLACEMENT_FAILED); diff --git a/modules/system/classes/SourceManifest.php b/modules/system/classes/SourceManifest.php index 24428f753a..677de5cf94 100644 --- a/modules/system/classes/SourceManifest.php +++ b/modules/system/classes/SourceManifest.php @@ -42,34 +42,18 @@ class SourceManifest /** * Constructor - * - * @param string $manifest Manifest file to load - * @param string $branches Branches manifest file to load - * @param bool $autoload Loads the manifest on construct */ - public function __construct($source = null, $forks = null, $autoload = true) + public function __construct(string $source = null, string $forks = null, bool $autoload = true) { - if (isset($source)) { - $this->setSource($source); - } else { - $this->setSource( - Config::get( - 'cms.sourceManifestUrl', - 'https://raw.githubusercontent.com/wintercms/meta/master/manifest/builds.json' - ) - ); - } + $this->setSource($source ?? Config::get( + 'cms.sourceManifestUrl', + 'https://raw.githubusercontent.com/wintercms/meta/master/manifest/builds.json' + )); - if (isset($forks)) { - $this->setForksSource($forks); - } else { - $this->setForksSource( - Config::get( - 'cms.forkManifestUrl', - 'https://raw.githubusercontent.com/wintercms/meta/master/manifest/forks.json' - ) - ); - } + $this->setForksSource($forks ?? Config::get( + 'cms.forkManifestUrl', + 'https://raw.githubusercontent.com/wintercms/meta/master/manifest/forks.json' + )); if ($autoload) { $this->loadSource(); @@ -79,28 +63,18 @@ public function __construct($source = null, $forks = null, $autoload = true) /** * Sets the source manifest URL. - * - * @param string $source - * @return void */ - public function setSource($source) + public function setSource(string $source): void { - if (is_string($source)) { - $this->source = $source; - } + $this->source = $source; } /** * Sets the forked version manifest URL. - * - * @param string $forks - * @return void */ - public function setForksSource($forks) + public function setForksSource(string $forks): void { - if (is_string($forks)) { - $this->forksUrl = $forks; - } + $this->forksUrl = $forks; } /** @@ -108,7 +82,7 @@ public function setForksSource($forks) * * @throws ApplicationException If the manifest is invalid, or cannot be parsed. */ - public function loadSource() + public function loadSource(): static { if (file_exists($this->source)) { $source = file_get_contents($this->source); @@ -152,7 +126,7 @@ public function loadSource() * * @throws ApplicationException If the manifest is invalid, or cannot be parsed. */ - public function loadForks() + public function loadForks(): static { if (file_exists($this->forksUrl)) { $forks = file_get_contents($this->forksUrl); @@ -196,9 +170,8 @@ public function loadForks() * * @param integer $build Build number. * @param FileManifest $manifest The file manifest to add as a build. - * @return void */ - public function addBuild($build, FileManifest $manifest) + public function addBuild($build, FileManifest $manifest): void { $parent = $this->determineParent($build); @@ -219,10 +192,8 @@ public function addBuild($build, FileManifest $manifest) /** * Gets all builds. - * - * @return array */ - public function getBuilds() + public function getBuilds(): array { return array_values(array_map(function ($build) { return $build['version']; @@ -233,9 +204,8 @@ public function getBuilds() * Generates the JSON data to be stored with the source manifest. * * @throws ApplicationException If no builds have been added to this source manifest. - * @return string */ - public function generate() + public function generate(): string { if (!count($this->builds)) { throw new ApplicationException( @@ -270,9 +240,8 @@ public function generate() * * @param string|integer $build Build version to get the filelist state for. * @throws ApplicationException If the specified build has not been added to the source manifest. - * @return array */ - public function getState($build) + public function getState(mixed $build): array { if (is_string($build)) { $build = $this->getVersionInt($build); @@ -328,9 +297,8 @@ public function getState($build) * * @param FileManifest $manifest The file manifest to compare against the source. * @param bool $detailed If true, the list of files modified, added and deleted will be included in the result. - * @return array */ - public function compare(FileManifest $manifest, $detailed = false) + public function compare(FileManifest $manifest, bool $detailed = false): array { $modules = $manifest->getModuleChecksums(); @@ -429,9 +397,8 @@ public function compare(FileManifest $manifest, $detailed = false) * @param FileManifest $manifest The current build's file manifest. * @param FileManifest|string|integer $previous Either a previous manifest, or the previous build number as an int * or string, used to determine changes with this build. - * @return array */ - protected function processChanges(FileManifest $manifest, $previous = null) + protected function processChanges(FileManifest $manifest, mixed $previous = null): array { // If no previous build has been provided, all files are added if (is_null($previous)) { @@ -478,7 +445,10 @@ protected function processChanges(FileManifest $manifest, $previous = null) return $changes; } - protected function determineParent(string $build) + /** + * Determine the parent of the provided build number + */ + protected function determineParent(string $build): ?array { $buildInt = $this->getVersionInt($build); @@ -503,11 +473,9 @@ protected function determineParent(string $build) /** * Converts a version string into an integer for comparison. * - * @param string $version * @throws ApplicationException if a version string does not match the format "major.minor.path" - * @return int */ - protected function getVersionInt(string $version) + protected function getVersionInt(string $version): int { // Get major.minor.patch versions if (!preg_match('/^([0-9]+)\.([0-9]+)\.([0-9]+)/', $version, $versionParts)) { diff --git a/modules/system/console/WinterTest.php b/modules/system/console/WinterTest.php index a0709742e9..f66b15b21f 100644 --- a/modules/system/console/WinterTest.php +++ b/modules/system/console/WinterTest.php @@ -7,9 +7,10 @@ use Symfony\Component\Process\Process; use System\Classes\PluginManager; use Winter\Storm\Exception\ApplicationException; +use Config; /** - * Console command to run tests for plugins or the Winter CMS core. + * Console command to run tests for plugins and modules. * * If a plugin is provided, this command will search for a `phpunit.xml` file inside the plugin's directory and run its tests. * @@ -17,6 +18,11 @@ */ class WinterTest extends Command { + /** + * @var string|null The default command name for lazy loading. + */ + protected static $defaultName = 'winter:test'; + /** * @var string The console command name. */ @@ -25,7 +31,12 @@ class WinterTest extends Command /** * @var string The console command signature as ignoreValidationErrors causes options not to be registered. */ - protected $signature = 'winter:test {?--p|plugin=} {?--c|configuration=} {?--o|core}'; + protected $signature = 'winter:test + {phpunitArgs?* : Arguments to pass through to PHPUnit} + {?--c|configuration= : A specific phpunit xml file} + {?--p|plugin=* : List of plugins to test} + {?--m|module=* : List of modules to test} + '; /** * @var string The console command description. @@ -61,62 +72,55 @@ public function __construct() */ public function handle() { - $arguments = $this->getAdditionalArguments(); + $arguments = $this->argument('phpunitArgs'); if (($config = $this->option('configuration')) && file_exists($config)) { return $this->execPhpUnit($config, $arguments); } $configs = $this->getPhpUnitConfigs(); - - if ($this->option('core')) { - if (!$configs['core']) { - throw new ApplicationException("Unable to find the core's phpunit.xml file. Try downloading it from GitHub."); + $exitCode = null; + + // loop over arguments and run specified tests + foreach (['module', 'plugin'] as $type) { + if ($this->option($type)) { + foreach ($this->option($type) as $target) { + $target = strtolower($target); + if (!isset($configs[$type . 's'][$target])) { + throw new ApplicationException(sprintf( + 'Unable to find %s %s\'s phpunit.xml file', + $type, + $target + )); + } + $this->info(sprintf('Running tests for %s: %s', $type, $target)); + $exit = $this->execPhpUnit($configs[$type . 's'][$target], $arguments); + // keep non 0 exit codes for return + $exitCode = !$exitCode ? $exit : $exitCode; + } } - $this->info('Running tests for: Winter CMS core'); - - return $this->execPhpUnit($configs['core'], $arguments); } - if ($plugin = $this->option('plugin')) { - if (!isset($configs['plugins'][strtolower($plugin)])) { - throw new ApplicationException(sprintf("Unable to find %s\'s phpunit.xml file", $plugin)); - } - $this->info('Running tests for plugin: ' . PluginManager::instance()->normalizeIdentifier($plugin)); - - return $this->execPhpUnit($configs['plugins'][strtolower($plugin)], $arguments); + // if we ran a specific test above we should have an exit code + if (!is_null($exitCode)) { + return $exitCode; } - $exitCode = 0; - - foreach (['core', 'plugins'] as $type) { - if (is_array($configs[$type])) { - foreach ($configs[$type] as $plugin => $config) { - $this->info('Running tests for plugin: ' . PluginManager::instance()->normalizeIdentifier($plugin)); - $exit = $this->execPhpUnit($config, $arguments); - $exitCode = $exitCode === 0 ? $exit : $exitCode; - } - continue; + // default to running all defined configs found + foreach (['modules', 'plugins'] as $type) { + foreach ($configs[$type] as $name => $config) { + $this->info( + $type === 'plugins' + ? 'Running tests for plugin: ' . PluginManager::instance()->normalizeIdentifier($name) + : 'Running tests for module: ' . $name + ); + $exit = $this->execPhpUnit($config, $arguments); + // keep non 0 exit codes for return + $exitCode = !$exitCode ? $exit : $exitCode; } - - $this->info('Running tests for Winter CMS: ' . $type); - $exit = $this->execPhpUnit($configs[$type], $arguments); - $exitCode = $exitCode === 0 ? $exit : $exitCode; } - return $exitCode; - } - - /** - * Get the console command options. - */ - protected function getOptions(): array - { - return [ - ['plugin', 'p', InputOption::VALUE_OPTIONAL, 'The name of the plugin. Ex: AuthorName.PluginName', null], - ['configuration', 'c', InputOption::VALUE_OPTIONAL, 'The path to a PHPUnit XML config file', null], - ['core', 'o', InputOption::VALUE_NONE, 'Run the Winter CMS core tests'], - ]; + return $exitCode ?? 0; } /** @@ -173,10 +177,17 @@ protected function execPhpUnit(string $config, array $args): int protected function getPhpUnitConfigs(): array { $configs = [ - 'core' => $this->getPhpUnitXmlFile(base_path()), + 'modules' => [], 'plugins' => [] ]; + foreach (Config::get('cms.loadModules', ['System', 'Cms', 'Backend']) as $module) { + $module = strtolower($module); + if ($path = $this->getPhpUnitXmlFile(base_path('modules/' . $module))) { + $configs['modules'][$module] = $path; + } + } + foreach (PluginManager::instance()->getPlugins() as $plugin) { if ($path = $this->getPhpUnitXmlFile($plugin->getPluginPath())) { $configs['plugins'][strtolower($plugin->getPluginIdentifier())] = $path; @@ -193,68 +204,18 @@ protected function getPhpUnitConfigs(): array protected function getPhpUnitXmlFile(string $path): ?string { // If a phpunit.xml file exists, returns its path - $distFilePath = $path . DIRECTORY_SEPARATOR . 'phpunit.xml'; - if (file_exists($distFilePath)) { - return $distFilePath; - } + $configFilePath = $path . DIRECTORY_SEPARATOR . 'phpunit.xml'; - // Fallback to phpunit.xml.dist file path if it exists - $configFilePath = $path . DIRECTORY_SEPARATOR . 'phpunit.xml.dist'; if (file_exists($configFilePath)) { return $configFilePath; } - return null; - } - - /** - * Strips out commands arguments and options in order to return arguments/options for PHPUnit. - */ - protected function getAdditionalArguments(): array - { - $arguments = $_SERVER['argv']; - - // First two are always "artisan" and "winter:test" - $arguments = array_slice($arguments, 2); - - // If nothing to do then just return - if (!count($arguments)) { - return $arguments; - } - - // Get the arguments provided by this command - foreach ($this->getOptions() as $argument) { - // For position 0 & 1, pass their names with appropriate dashes - for ($i = 0; $i < 2; $i++) { - $arguments = $this->removeArgument($arguments, str_repeat('-', 2 - $i) . $argument[$i]); - } - } - - return $arguments; - } - - /** - * Removes flags from argument list and their value if present - */ - protected function removeArgument(array $arguments, string $remove): array - { - // find args that have trailing chars - $key = array_values(preg_grep("/^({$remove}|{$remove}=).*/i", $arguments)); - $remove = (isset($key[0])) ? $key[0] : $remove; - - // find the position of arguments to remove - if (($position = array_search($remove, $arguments)) === false) { - return $arguments; - } - - // remove argument - unset($arguments[$position]); - - // if the next item in the array is not a flag, consider it a value of the removed argument - if (isset($arguments[$position + 1]) && substr($arguments[$position + 1], 0, 1) !== '-') { - unset($arguments[$position + 1]); + // Fallback to phpunit.xml.dist file path if it exists + $distFilePath = $path . DIRECTORY_SEPARATOR . 'phpunit.xml.dist'; + if (file_exists($distFilePath)) { + return $distFilePath; } - return array_values($arguments); + return null; } } diff --git a/modules/system/phpunit.xml b/modules/system/phpunit.xml new file mode 100644 index 0000000000..6b6057c712 --- /dev/null +++ b/modules/system/phpunit.xml @@ -0,0 +1,22 @@ + + + + + ./tests + + + + + + + + diff --git a/tests/unit/system/AliasesTest.php b/modules/system/tests/AliasesTest.php similarity index 90% rename from tests/unit/system/AliasesTest.php rename to modules/system/tests/AliasesTest.php index 88649f088b..7a5b93ff3a 100644 --- a/tests/unit/system/AliasesTest.php +++ b/modules/system/tests/AliasesTest.php @@ -1,5 +1,9 @@ - + ./tests @@ -32,67 +32,72 @@ Plugins can be tested by creating a file called `phpunit.xml` in the base direct 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. - 'Hi!']); - $this->assertEquals(1, $post->id); - } + $post = Post::create(['title' => 'Hi!']); + $this->assertEquals(1, $post->id); } +} +``` -The test class should extend the base class `PluginTestCase` and this is a special class that will set up the Winter 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: +The test class should extend the base class `System\Tests\Boostrap\PluginTestCase` and this is a special class that will set up the Winter 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 artisan winter:up - php artisan plugin:refresh Acme.Blog - [php artisan plugin:refresh , ...] +```bash +php artisan winter:up +php artisan plugin:refresh Acme.Blog +[php artisan plugin:refresh , ...] +``` > **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. - use System\Classes\PluginManager; +```php +use System\Classes\PluginManager; +use System\Tests\Bootstrap\PluginTestCase; - class BaseTestCase extends PluginTestCase +class BaseTestCase extends PluginTestCase +{ + public function setUp(): void { - public function setUp(): void - { - parent::setUp(); + parent::setUp(); - // Get the plugin manager - $pluginManager = PluginManager::instance(); + // Get the plugin manager + $pluginManager = PluginManager::instance(); - // Register the plugins to make features like file configuration available - $pluginManager->registerAll(true); + // Register the plugins to make features like file configuration available + $pluginManager->registerAll(true); - // Boot all the plugins to test with dependencies of this plugin - $pluginManager->bootAll(true); - } + // Boot all the plugins to test with dependencies of this plugin + $pluginManager->bootAll(true); + } - public function tearDown(): void - { - parent::tearDown(); + public function tearDown(): void + { + parent::tearDown(); - // Get the plugin manager - $pluginManager = PluginManager::instance(); + // Get the plugin manager + $pluginManager = PluginManager::instance(); - // Ensure that plugins are registered again for the next test - $pluginManager->unregisterAll(); - } + // Ensure that plugins are registered again for the next test + $pluginManager->unregisterAll(); } +} +``` #### Changing database engine for plugins tests -By default Winter CMS 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`. - -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. +By default Winter CMS uses SQLite stored in memory for the plugin testing environment. If you want to override the default behavior 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. -## System testing +## Winter core modules testing -To perform unit testing on the core Winter files, you should download a development copy using composer or cloning the git repo. This will ensure you have the `tests/` directory. +To perform unit testing on the core Winter modules run `artisan winter:test -m system -m backend -m cms`. ### Unit tests diff --git a/tests/PluginTestCase.php b/modules/system/tests/bootstrap/PluginTestCase.php similarity index 93% rename from tests/PluginTestCase.php rename to modules/system/tests/bootstrap/PluginTestCase.php index 82be3779b6..58e18caa89 100644 --- a/tests/PluginTestCase.php +++ b/modules/system/tests/bootstrap/PluginTestCase.php @@ -1,10 +1,16 @@ make('Illuminate\Contracts\Console\Kernel')->bootstrap(); $app['cache']->setDefaultDriver('array'); @@ -51,7 +57,7 @@ public function createApplication() /* * Modify the plugin path away from the test context */ - $app->setPluginsPath(realpath(base_path().Config::get('cms.pluginsPath'))); + $app->setPluginsPath(realpath(base_path() . Config::get('cms.pluginsPath'))); return $app; } @@ -126,7 +132,7 @@ protected function runPluginRefreshCommand($code, $throwException = true) if (!$throwException) { return; } - throw new Exception(sprintf('Invalid plugin code: "%s"', $code)); + throw new \Exception(sprintf('Invalid plugin code: "%s"', $code)); } $manager = PluginManager::instance(); diff --git a/tests/TestCase.php b/modules/system/tests/bootstrap/TestCase.php similarity index 93% rename from tests/TestCase.php rename to modules/system/tests/bootstrap/TestCase.php index a4d5b1569d..3bdb052718 100644 --- a/tests/TestCase.php +++ b/modules/system/tests/bootstrap/TestCase.php @@ -1,8 +1,11 @@ make('Illuminate\Contracts\Console\Kernel')->bootstrap(); diff --git a/tests/bootstrap.php b/modules/system/tests/bootstrap/app.php similarity index 60% rename from tests/bootstrap.php rename to modules/system/tests/bootstrap/app.php index 6e1d5a9fd5..9be7e9d5db 100644 --- a/tests/bootstrap.php +++ b/modules/system/tests/bootstrap/app.php @@ -1,17 +1,19 @@ register(); diff --git a/tests/unit/system/classes/AutoDatasourceTest.php b/modules/system/tests/classes/AutoDatasourceTest.php similarity index 93% rename from tests/unit/system/classes/AutoDatasourceTest.php rename to modules/system/tests/classes/AutoDatasourceTest.php index bc459cd40c..d3550ee691 100644 --- a/tests/unit/system/classes/AutoDatasourceTest.php +++ b/modules/system/tests/classes/AutoDatasourceTest.php @@ -1,5 +1,8 @@ datasource = new AutoDatasource([ 'database' => new DbDatasource('test', 'cms_theme_templates'), - 'filesystem' => new FileDatasource(base_path('tests/fixtures/themes/test'), App::make('files')), + 'filesystem' => new FileDatasource( + base_path('modules/system/tests/fixtures/themes/test'), + \App::make('files') + ), ]); } diff --git a/tests/unit/system/classes/CombineAssetsTest.php b/modules/system/tests/classes/CombineAssetsTest.php similarity index 90% rename from tests/unit/system/classes/CombineAssetsTest.php rename to modules/system/tests/classes/CombineAssetsTest.php index 5c5d313bdb..a34dbca8bb 100644 --- a/tests/unit/system/classes/CombineAssetsTest.php +++ b/modules/system/tests/classes/CombineAssetsTest.php @@ -1,5 +1,8 @@ assertNotNull($url); $this->assertRegExp('/\w+[-]\d+/i', $url); // Must contain hash-number @@ -55,7 +58,7 @@ public function testCombine() 'assets/js/script1.js', 'assets/js/script2.js' ], - base_path().'/tests/fixtures/themes/test' + base_path() . '/modules/system/tests/fixtures/themes/test' ); $this->assertNotNull($url); $this->assertRegExp('/\w+[-]\d+/i', $url); // Must contain hash-number @@ -87,7 +90,7 @@ public function testGetTargetPath() public function testMakeCacheId() { $sampleResources = ['assets/css/style1.css', 'assets/css/style2.css']; - $samplePath = base_path().'/tests/fixtures/cms/themes/test'; + $samplePath = base_path() . '/modules/system/tests/fixtures/cms/themes/test'; $combiner = CombineAssets::instance(); self::setProtectedProperty($combiner, 'localPath', $samplePath); diff --git a/tests/unit/system/classes/CoreLangTest.php b/modules/system/tests/classes/CoreLangTest.php similarity index 94% rename from tests/unit/system/classes/CoreLangTest.php rename to modules/system/tests/classes/CoreLangTest.php index 54899a8125..d66a0dbe13 100644 --- a/tests/unit/system/classes/CoreLangTest.php +++ b/modules/system/tests/classes/CoreLangTest.php @@ -1,6 +1,10 @@ fileManifest = new FileManifest(base_path('tests/fixtures/manifest/1_0_1'), ['test', 'test2']); + $this->fileManifest = new FileManifest( + base_path('modules/system/tests/fixtures/manifest/1_0_1'), + ['test', 'test2'] + ); } public function testGetFiles() diff --git a/tests/unit/system/classes/ImageResizerTest.php b/modules/system/tests/classes/ImageResizerTest.php similarity index 94% rename from tests/unit/system/classes/ImageResizerTest.php rename to modules/system/tests/classes/ImageResizerTest.php index 27b051a612..eafbefd3fd 100644 --- a/tests/unit/system/classes/ImageResizerTest.php +++ b/modules/system/tests/classes/ImageResizerTest.php @@ -1,5 +1,8 @@ getConfig()); // Resize with an customised defaults - $this->markTestSkipped('@TODO: Something is going funky with serialized closures in PHP 8.0 / Laravel 9.x'); Event::listen('system.resizer.getDefaultOptions', function (&$options) { $options = array_merge($options, [ 'mode' => 'fit', @@ -253,7 +259,7 @@ public function testURLSources() // URL for a FileModel instance (absolute URL) $fileModel = new FileModel(); - $fileModel->fromFile(base_path('tests/fixtures/plugins/database/tester/assets/images/avatar.png')); + $fileModel->fromFile(base_path('modules/system/tests/fixtures/plugins/database/tester/assets/images/avatar.png')); $fileModel->save(); $imageResizer = new ImageResizer( @@ -268,7 +274,7 @@ public function testURLSources() // URL of a FileModel instance (relative URL) $fileModel = new FileModel(); - $fileModel->fromFile(base_path('tests/fixtures/plugins/database/tester/assets/images/avatar.png')); + $fileModel->fromFile(base_path('modules/system/tests/fixtures/plugins/database/tester/assets/images/avatar.png')); $fileModel->save(); $imageResizer = new ImageResizer( @@ -283,7 +289,7 @@ public function testDirectSources() { // FileModel instance itself $fileModel = new FileModel(); - $fileModel->fromFile(base_path('tests/fixtures/plugins/database/tester/assets/images/avatar.png')); + $fileModel->fromFile(base_path('modules/system/tests/fixtures/plugins/database/tester/assets/images/avatar.png')); $fileModel->save(); $imageResizer = new ImageResizer( @@ -346,7 +352,7 @@ public function testGetResizedUrl() Config::set('cms.linkPolicy', 'detect'); $url = $imageResizer->getResizedUrl(); - $this->assertTrue(starts_with($url, Config::get('cms.storage.resized.path', '/tests/storage/app/resized'))); + $this->assertTrue(starts_with($url, Config::get('cms.storage.resized.path', '/storage/tests/app/resized'))); } public function testGetResizerUrl() @@ -386,7 +392,7 @@ protected function copyMedia() mkdir($mediaPath, 0777, true); } - foreach (glob(base_path('tests/fixtures/media/*')) as $file) { + foreach (glob(base_path('modules/system/tests/fixtures/media/*')) as $file) { $path = pathinfo($file); copy($file, $mediaPath . DIRECTORY_SEPARATOR . $path['basename']); } diff --git a/tests/unit/system/classes/MarkupManagerTest.php b/modules/system/tests/classes/MarkupManagerTest.php similarity index 93% rename from tests/unit/system/classes/MarkupManagerTest.php rename to modules/system/tests/classes/MarkupManagerTest.php index a415b49a25..d5453d193d 100644 --- a/tests/unit/system/classes/MarkupManagerTest.php +++ b/modules/system/tests/classes/MarkupManagerTest.php @@ -1,5 +1,8 @@ manager->loadPlugins(); - $this->assertCount(12, $result); + $this->assertCount(static::INSTALLED_PLUGIN_COUNT, $result); $this->assertArrayHasKey('Winter.NoUpdates', $result); $this->assertArrayHasKey('Winter.Sample', $result); $this->assertArrayHasKey('Winter.Tester', $result); @@ -156,14 +165,14 @@ public function testGetPluginPath() { $result = $this->manager->getPluginPath('Winter\Tester'); $basePath = str_replace('\\', '/', base_path()); - $this->assertEquals($basePath . '/tests/fixtures/plugins/winter/tester', $result); + $this->assertEquals($basePath . '/modules/system/tests/fixtures/plugins/winter/tester', $result); } public function testGetPlugins() { $result = $this->manager->getPlugins(); - $this->assertCount(9, $result); + $this->assertCount(static::ENABLED_PLUGIN_COUNT, $result); $this->assertArrayHasKey('Winter.NoUpdates', $result); $this->assertArrayHasKey('Winter.Sample', $result); $this->assertArrayHasKey('Winter.Tester', $result); @@ -223,7 +232,7 @@ public function testGetPluginNamespaces() { $result = $this->manager->getPluginNamespaces(); - $this->assertCount(13, $result); + $this->assertCount(static::PLUGIN_NAMESPACE_COUNT, $result); $this->assertArrayHasKey('\winter\noupdates', $result); $this->assertArrayHasKey('\winter\sample', $result); $this->assertArrayHasKey('\winter\tester', $result); @@ -277,7 +286,7 @@ public function testPluginDetails() public function testUnregisterall() { $result = $this->manager->getPlugins(); - $this->assertCount(9, $result); + $this->assertCount(static::ENABLED_PLUGIN_COUNT, $result); $this->manager->unregisterAll(); $this->assertEmpty($this->manager->getPlugins()); @@ -346,6 +355,102 @@ public function testReplacement() $this->assertEquals('Winter.Replacement', $this->manager->findByIdentifier('Winter.Original')->getPluginIdentifier()); } + public function testHasPluginReplacement() + { + // check a replaced plugin + $this->assertTrue($this->manager->hasPlugin('Winter.Original')); + $this->assertTrue($this->manager->isDisabled('Winter.Original')); + // check a replacement plugin + $this->assertTrue($this->manager->hasPlugin('Winter.Replacement')); + $this->assertFalse($this->manager->isDisabled('Winter.Replacement')); + // check a plugin where the replacement is invalid + $this->assertTrue($this->manager->hasPlugin('Winter.InvalidReplacement')); + $this->assertTrue($this->manager->isDisabled('Winter.InvalidReplacement')); + // check a plugin replacing a plugin not found on disk + $this->assertTrue($this->manager->hasPlugin('Winter.ReplaceNotInstalled')); + $this->assertFalse($this->manager->isDisabled('Winter.ReplaceNotInstalled')); + // ensure searching for the alias of a replacement (plugin not installed) + $this->assertTrue($this->manager->hasPlugin('Winter.NotInstalled')); + + $this->assertInstanceOf(\Winter\Replacement\Plugin::class, $this->manager->findByIdentifier('Winter.Original')); + $this->assertInstanceOf(\Winter\Replacement\Plugin::class, $this->manager->findByIdentifier('Winter.Replacement')); + + // check getting a plugin via it's not installed original plugin identifier + $this->assertInstanceOf(\Winter\ReplaceNotInstalled\Plugin::class, $this->manager->findByIdentifier('Winter.NotInstalled')); + $this->assertNull($this->manager->findByIdentifier('Winter.NotInstalled', true)); + + // force getting the original plugin + $this->assertInstanceOf(\Winter\Original\Plugin::class, $this->manager->findByIdentifier('Winter.Original', true)); + } + + public function testHasPluginReplacementMixedCase() + { + // test checking casing of installed plugin (resolved via getNormalizedIdentifier()) + $this->assertTrue($this->manager->hasPlugin('Winter.ReplaceNotInstalled')); + $this->assertTrue($this->manager->hasPlugin('Winter.replaceNotInstalled')); + $this->assertTrue($this->manager->hasPlugin('Winter.replacenotInstalled')); + $this->assertTrue($this->manager->hasPlugin('winter.replacenotInstalled')); + $this->assertTrue($this->manager->hasPlugin('winter.replacenotinstalled')); + + // test checking casing of installed replaced plugin (resolved via getNormalizedIdentifier() & replacementMap) + $this->assertTrue($this->manager->hasPlugin('Winter.Original')); + $this->assertTrue($this->manager->hasPlugin('Winter.original')); + $this->assertTrue($this->manager->hasPlugin('winter.original')); + + // test checking casing of uninstalled plugin (resolved via strtolower() on replacement keys) + $this->assertTrue($this->manager->hasPlugin('Winter.NotInstalled')); + $this->assertTrue($this->manager->hasPlugin('Winter.notInstalled')); + $this->assertTrue($this->manager->hasPlugin('winter.notInstalled')); + $this->assertTrue($this->manager->hasPlugin('Winter.notinstalled')); + } + + public function testExistsReplacementMixedCase() + { + // test checking casing of installed plugin (resolved via getNormalizedIdentifier()) + $this->assertTrue($this->manager->exists('Winter.ReplaceNotInstalled')); + $this->assertTrue($this->manager->exists('Winter.replaceNotInstalled')); + $this->assertTrue($this->manager->exists('Winter.replacenotInstalled')); + $this->assertTrue($this->manager->exists('winter.replacenotInstalled')); + $this->assertTrue($this->manager->exists('winter.replacenotinstalled')); + + // test checking casing of installed replaced plugin (resolved via getNormalizedIdentifier() & replacementMap) + $this->assertFalse($this->manager->exists('Winter.Original')); + $this->assertFalse($this->manager->exists('Winter.original')); + $this->assertFalse($this->manager->exists('winter.original')); + + // test checking casing of uninstalled plugin (resolved via strtolower() on replacement keys) + $this->assertTrue($this->manager->exists('Winter.NotInstalled')); + $this->assertTrue($this->manager->exists('Winter.notInstalled')); + $this->assertTrue($this->manager->exists('winter.notInstalled')); + $this->assertTrue($this->manager->exists('Winter.notinstalled')); + } + + public function testFindByIdentifierReplacementMixedCase() + { + // test resolving plugin with mixed casing + $this->assertInstanceOf(\Winter\ReplaceNotInstalled\Plugin::class, $this->manager->findByIdentifier('Winter.ReplaceNotInstalled')); + $this->assertInstanceOf(\Winter\ReplaceNotInstalled\Plugin::class, $this->manager->findByIdentifier('Winter.replaceNotInstalled')); + $this->assertInstanceOf(\Winter\ReplaceNotInstalled\Plugin::class, $this->manager->findByIdentifier('Winter.replacenotInstalled')); + $this->assertInstanceOf(\Winter\ReplaceNotInstalled\Plugin::class, $this->manager->findByIdentifier('winter.replacenotInstalled')); + $this->assertInstanceOf(\Winter\ReplaceNotInstalled\Plugin::class, $this->manager->findByIdentifier('winter.replacenotinstalled')); + + // test resolving replacement plugin with mixed casing + $this->assertInstanceOf(\Winter\Replacement\Plugin::class, $this->manager->findByIdentifier('Winter.Original')); + $this->assertInstanceOf(\Winter\Replacement\Plugin::class, $this->manager->findByIdentifier('Winter.original')); + $this->assertInstanceOf(\Winter\Replacement\Plugin::class, $this->manager->findByIdentifier('winter.original')); + + // test resolving original plugin with mixed casing when ignoring replacements + $this->assertInstanceOf(\Winter\Original\Plugin::class, $this->manager->findByIdentifier('Winter.Original', true)); + $this->assertInstanceOf(\Winter\Original\Plugin::class, $this->manager->findByIdentifier('Winter.original', true)); + $this->assertInstanceOf(\Winter\Original\Plugin::class, $this->manager->findByIdentifier('winter.original', true)); + + // test resolving replacement plugin of uninstalled plugin with mixed casing + $this->assertInstanceOf(\Winter\ReplaceNotInstalled\Plugin::class, $this->manager->findByIdentifier('Winter.NotInstalled')); + $this->assertInstanceOf(\Winter\ReplaceNotInstalled\Plugin::class, $this->manager->findByIdentifier('Winter.notInstalled')); + $this->assertInstanceOf(\Winter\ReplaceNotInstalled\Plugin::class, $this->manager->findByIdentifier('winter.notInstalled')); + $this->assertInstanceOf(\Winter\ReplaceNotInstalled\Plugin::class, $this->manager->findByIdentifier('Winter.notinstalled')); + } + public function testGetReplacements() { $replacementPluginReplaces = $this->manager->findByIdentifier('Winter.Replacement')->getReplaces(); diff --git a/tests/unit/system/classes/SourceManifestTest.php b/modules/system/tests/classes/SourceManifestTest.php similarity index 86% rename from tests/unit/system/classes/SourceManifestTest.php rename to modules/system/tests/classes/SourceManifestTest.php index 8fc7267b21..3b3ed20ea3 100644 --- a/tests/unit/system/classes/SourceManifestTest.php +++ b/modules/system/tests/classes/SourceManifestTest.php @@ -1,5 +1,8 @@ builds = [ - '1.0.0' => new FileManifest(base_path('tests/fixtures/manifest/1_0_0'), ['test', 'test2']), - '1.0.1' => new FileManifest(base_path('tests/fixtures/manifest/1_0_1'), ['test', 'test2']), - '1.0.2' => new FileManifest(base_path('tests/fixtures/manifest/1_0_2'), ['test', 'test2']), - '1.1.0' => new FileManifest(base_path('tests/fixtures/manifest/1_1_0'), ['test', 'test2', 'test3']), - '1.1.1' => new FileManifest(base_path('tests/fixtures/manifest/1_1_1'), ['test', 'test2', 'test3']), - '1.0.3' => new FileManifest(base_path('tests/fixtures/manifest/1_0_3'), ['test', 'test2']), + '1.0.0' => new FileManifest( + base_path('modules/system/tests/fixtures/manifest/1_0_0'), + ['test', 'test2'] + ), + '1.0.1' => new FileManifest( + base_path('modules/system/tests/fixtures/manifest/1_0_1'), + ['test', 'test2'] + ), + '1.0.2' => new FileManifest( + base_path('modules/system/tests/fixtures/manifest/1_0_2'), + ['test', 'test2'] + ), + '1.1.0' => new FileManifest( + base_path('modules/system/tests/fixtures/manifest/1_1_0'), + ['test', 'test2', 'test3'] + ), + '1.1.1' => new FileManifest( + base_path('modules/system/tests/fixtures/manifest/1_1_1'), + ['test', 'test2', 'test3'] + ), + '1.0.3' => new FileManifest( + base_path('modules/system/tests/fixtures/manifest/1_0_3'), + ['test', 'test2'] + ), ]; $this->sourceManifest = new SourceManifest($this->manifestPath(), $this->forksPath(), false); @@ -252,13 +273,13 @@ public function testCompareModified() $this->createManifest(); // Hot-swap "tests/fixtures/manifest/1_1_1/modules/test/file3.php" - $old = file_get_contents(base_path('tests/fixtures/manifest/1_1_1/modules/test/file3.php')); - file_put_contents(base_path('tests/fixtures/manifest/1_1_1/modules/test/file3.php'), 'getFiles(); - file_put_contents(base_path('tests/fixtures/manifest/1_1_1/modules/test/file3.php'), $old); + file_put_contents(base_path('modules/system/tests/fixtures/manifest/1_1_1/modules/test/file3.php'), $old); $this->assertEquals([ 'build' => '1.1.1', @@ -272,12 +293,12 @@ public function testCompareModifiedSecondBranch() $this->createManifest(); // Add "tests/fixtures/manifest/1_0_3/modules/test/file3.php" - file_put_contents(base_path('tests/fixtures/manifest/1_0_3/modules/test/file3.php'), 'getFiles(); - unlink(base_path('tests/fixtures/manifest/1_0_3/modules/test/file3.php')); + unlink(base_path('modules/system/tests/fixtures/manifest/1_0_3/modules/test/file3.php')); $this->assertEquals([ 'build' => '1.0.3', @@ -310,11 +331,11 @@ protected function deleteManifest() protected function manifestPath() { - return base_path('tests/fixtures/manifest/builds.json'); + return base_path('modules/system/tests/fixtures/manifest/builds.json'); } protected function forksPath() { - return base_path('tests/fixtures/manifest/forks.json'); + return base_path('modules/system/tests/fixtures/manifest/forks.json'); } } diff --git a/tests/unit/system/classes/UpdatesControllerTest.php b/modules/system/tests/classes/UpdatesControllerTest.php similarity index 92% rename from tests/unit/system/classes/UpdatesControllerTest.php rename to modules/system/tests/classes/UpdatesControllerTest.php index 7994848650..0a557f8f8f 100644 --- a/tests/unit/system/classes/UpdatesControllerTest.php +++ b/modules/system/tests/classes/UpdatesControllerTest.php @@ -1,5 +1,8 @@ 'Winter Sample Plugin', + 'description' => 'Sample plugin used by unit tests.', + 'author' => 'Alexey Bobkov, Samuel Georges', + 'replaces' => [ + 'Winter.NotInstalled' => '>=1.0.3' + ] + ]; + } +} diff --git a/modules/system/tests/fixtures/plugins/winter/replacenotinstalled/updates/version.yaml b/modules/system/tests/fixtures/plugins/winter/replacenotinstalled/updates/version.yaml new file mode 100644 index 0000000000..979448dee1 --- /dev/null +++ b/modules/system/tests/fixtures/plugins/winter/replacenotinstalled/updates/version.yaml @@ -0,0 +1,2 @@ +1.0.0: Initial build +1.0.1: Updated plugin diff --git a/tests/fixtures/plugins/winter/sample/Plugin.php b/modules/system/tests/fixtures/plugins/winter/sample/Plugin.php similarity index 100% rename from tests/fixtures/plugins/winter/sample/Plugin.php rename to modules/system/tests/fixtures/plugins/winter/sample/Plugin.php diff --git a/tests/fixtures/plugins/winter/sample/updates/version.yaml b/modules/system/tests/fixtures/plugins/winter/sample/updates/version.yaml similarity index 100% rename from tests/fixtures/plugins/winter/sample/updates/version.yaml rename to modules/system/tests/fixtures/plugins/winter/sample/updates/version.yaml diff --git a/tests/fixtures/plugins/winter/tester/Plugin.php b/modules/system/tests/fixtures/plugins/winter/tester/Plugin.php similarity index 100% rename from tests/fixtures/plugins/winter/tester/Plugin.php rename to modules/system/tests/fixtures/plugins/winter/tester/Plugin.php diff --git a/tests/fixtures/plugins/winter/tester/classes/Users.php b/modules/system/tests/fixtures/plugins/winter/tester/classes/Users.php similarity index 100% rename from tests/fixtures/plugins/winter/tester/classes/Users.php rename to modules/system/tests/fixtures/plugins/winter/tester/classes/Users.php diff --git a/tests/fixtures/plugins/winter/tester/components/Archive.php b/modules/system/tests/fixtures/plugins/winter/tester/components/Archive.php similarity index 100% rename from tests/fixtures/plugins/winter/tester/components/Archive.php rename to modules/system/tests/fixtures/plugins/winter/tester/components/Archive.php diff --git a/tests/fixtures/plugins/winter/tester/components/Categories.php b/modules/system/tests/fixtures/plugins/winter/tester/components/Categories.php similarity index 100% rename from tests/fixtures/plugins/winter/tester/components/Categories.php rename to modules/system/tests/fixtures/plugins/winter/tester/components/Categories.php diff --git a/tests/fixtures/plugins/winter/tester/components/Comments.php b/modules/system/tests/fixtures/plugins/winter/tester/components/Comments.php similarity index 100% rename from tests/fixtures/plugins/winter/tester/components/Comments.php rename to modules/system/tests/fixtures/plugins/winter/tester/components/Comments.php diff --git a/tests/fixtures/plugins/winter/tester/components/ContentBlock.php b/modules/system/tests/fixtures/plugins/winter/tester/components/ContentBlock.php similarity index 100% rename from tests/fixtures/plugins/winter/tester/components/ContentBlock.php rename to modules/system/tests/fixtures/plugins/winter/tester/components/ContentBlock.php diff --git a/tests/fixtures/plugins/winter/tester/components/MainMenu.php b/modules/system/tests/fixtures/plugins/winter/tester/components/MainMenu.php similarity index 100% rename from tests/fixtures/plugins/winter/tester/components/MainMenu.php rename to modules/system/tests/fixtures/plugins/winter/tester/components/MainMenu.php diff --git a/tests/fixtures/plugins/winter/tester/components/Post.php b/modules/system/tests/fixtures/plugins/winter/tester/components/Post.php similarity index 100% rename from tests/fixtures/plugins/winter/tester/components/Post.php rename to modules/system/tests/fixtures/plugins/winter/tester/components/Post.php diff --git a/tests/fixtures/plugins/winter/tester/components/mainmenu/default.htm b/modules/system/tests/fixtures/plugins/winter/tester/components/mainmenu/default.htm similarity index 100% rename from tests/fixtures/plugins/winter/tester/components/mainmenu/default.htm rename to modules/system/tests/fixtures/plugins/winter/tester/components/mainmenu/default.htm diff --git a/tests/fixtures/plugins/winter/tester/components/mainmenu/items.htm b/modules/system/tests/fixtures/plugins/winter/tester/components/mainmenu/items.htm similarity index 100% rename from tests/fixtures/plugins/winter/tester/components/mainmenu/items.htm rename to modules/system/tests/fixtures/plugins/winter/tester/components/mainmenu/items.htm diff --git a/tests/fixtures/plugins/winter/tester/components/post/default.htm b/modules/system/tests/fixtures/plugins/winter/tester/components/post/default.htm similarity index 100% rename from tests/fixtures/plugins/winter/tester/components/post/default.htm rename to modules/system/tests/fixtures/plugins/winter/tester/components/post/default.htm diff --git a/tests/fixtures/plugins/winter/tester/formwidgets/Preview.php b/modules/system/tests/fixtures/plugins/winter/tester/formwidgets/Preview.php similarity index 100% rename from tests/fixtures/plugins/winter/tester/formwidgets/Preview.php rename to modules/system/tests/fixtures/plugins/winter/tester/formwidgets/Preview.php diff --git a/tests/fixtures/plugins/winter/tester/rules/BeLikeBobRule.php b/modules/system/tests/fixtures/plugins/winter/tester/rules/BeLikeBobRule.php similarity index 100% rename from tests/fixtures/plugins/winter/tester/rules/BeLikeBobRule.php rename to modules/system/tests/fixtures/plugins/winter/tester/rules/BeLikeBobRule.php diff --git a/tests/fixtures/plugins/winter/tester/updates/create_blog_settings_table.php b/modules/system/tests/fixtures/plugins/winter/tester/updates/create_blog_settings_table.php similarity index 100% rename from tests/fixtures/plugins/winter/tester/updates/create_blog_settings_table.php rename to modules/system/tests/fixtures/plugins/winter/tester/updates/create_blog_settings_table.php diff --git a/tests/fixtures/plugins/winter/tester/updates/drop_blog_settings_table.php b/modules/system/tests/fixtures/plugins/winter/tester/updates/drop_blog_settings_table.php similarity index 100% rename from tests/fixtures/plugins/winter/tester/updates/drop_blog_settings_table.php rename to modules/system/tests/fixtures/plugins/winter/tester/updates/drop_blog_settings_table.php diff --git a/tests/fixtures/plugins/winter/tester/updates/fix_database.php b/modules/system/tests/fixtures/plugins/winter/tester/updates/fix_database.php similarity index 100% rename from tests/fixtures/plugins/winter/tester/updates/fix_database.php rename to modules/system/tests/fixtures/plugins/winter/tester/updates/fix_database.php diff --git a/tests/fixtures/plugins/winter/tester/updates/some_upgrade_file.php b/modules/system/tests/fixtures/plugins/winter/tester/updates/some_upgrade_file.php similarity index 100% rename from tests/fixtures/plugins/winter/tester/updates/some_upgrade_file.php rename to modules/system/tests/fixtures/plugins/winter/tester/updates/some_upgrade_file.php diff --git a/tests/fixtures/plugins/winter/tester/updates/version.yaml b/modules/system/tests/fixtures/plugins/winter/tester/updates/version.yaml similarity index 100% rename from tests/fixtures/plugins/winter/tester/updates/version.yaml rename to modules/system/tests/fixtures/plugins/winter/tester/updates/version.yaml diff --git a/modules/system/tests/fixtures/themes/apitest/.gitignore b/modules/system/tests/fixtures/themes/apitest/.gitignore new file mode 100644 index 0000000000..42b41d19d3 --- /dev/null +++ b/modules/system/tests/fixtures/themes/apitest/.gitignore @@ -0,0 +1,2 @@ +*.htm +testobjects/*.htm \ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/assets/css/style1.css b/modules/system/tests/fixtures/themes/test/assets/css/style1.css new file mode 100644 index 0000000000..e69de29bb2 diff --git a/modules/system/tests/fixtures/themes/test/assets/css/style2.css b/modules/system/tests/fixtures/themes/test/assets/css/style2.css new file mode 100644 index 0000000000..e69de29bb2 diff --git a/modules/system/tests/fixtures/themes/test/assets/images/winter.png b/modules/system/tests/fixtures/themes/test/assets/images/winter.png new file mode 100644 index 0000000000..7cfa17951b Binary files /dev/null and b/modules/system/tests/fixtures/themes/test/assets/images/winter.png differ diff --git a/modules/system/tests/fixtures/themes/test/assets/js/script1.js b/modules/system/tests/fixtures/themes/test/assets/js/script1.js new file mode 100644 index 0000000000..b8bbe4e135 --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/assets/js/script1.js @@ -0,0 +1 @@ +console.log('script1.js'); diff --git a/modules/system/tests/fixtures/themes/test/assets/js/script2.js b/modules/system/tests/fixtures/themes/test/assets/js/script2.js new file mode 100644 index 0000000000..54e00dea3b --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/assets/js/script2.js @@ -0,0 +1 @@ +console.log('script2.js'); diff --git a/modules/system/tests/fixtures/themes/test/assets/js/subdir/script1.js b/modules/system/tests/fixtures/themes/test/assets/js/subdir/script1.js new file mode 100644 index 0000000000..bc27e099c0 --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/assets/js/subdir/script1.js @@ -0,0 +1 @@ +console.log('subdir/script1.js'); diff --git a/modules/system/tests/fixtures/themes/test/content/a/a-content.htm b/modules/system/tests/fixtures/themes/test/content/a/a-content.htm new file mode 100644 index 0000000000..5f9de3933c --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/content/a/a-content.htm @@ -0,0 +1 @@ +A content \ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/content/html-content.htm b/modules/system/tests/fixtures/themes/test/content/html-content.htm new file mode 100644 index 0000000000..9fca008a96 --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/content/html-content.htm @@ -0,0 +1 @@ +Stephen Saucier changed his profile picture — 7 hrs ago \ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/content/layout-content.txt b/modules/system/tests/fixtures/themes/test/content/layout-content.txt new file mode 100644 index 0000000000..920c278b49 --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/content/layout-content.txt @@ -0,0 +1 @@ +LAYOUT CONTENT \ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/content/markdown-content.md b/modules/system/tests/fixtures/themes/test/content/markdown-content.md new file mode 100644 index 0000000000..58429128ec --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/content/markdown-content.md @@ -0,0 +1 @@ +Be brave, be **bold**, live *italic* \ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/content/page-content.htm b/modules/system/tests/fixtures/themes/test/content/page-content.htm new file mode 100644 index 0000000000..887d78d9cd --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/content/page-content.htm @@ -0,0 +1 @@ +PAGE CONTENT \ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/content/text-content.txt b/modules/system/tests/fixtures/themes/test/content/text-content.txt new file mode 100644 index 0000000000..c055462e5d --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/content/text-content.txt @@ -0,0 +1 @@ +Pen is than the sword, HTML is than the text \ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/layouts/a/a-layout.htm b/modules/system/tests/fixtures/themes/test/layouts/a/a-layout.htm new file mode 100644 index 0000000000..c4f1ab9057 --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/layouts/a/a-layout.htm @@ -0,0 +1 @@ +
LAYOUT CONTENT {{ page() }}
\ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/layouts/ajax-test.htm b/modules/system/tests/fixtures/themes/test/layouts/ajax-test.htm new file mode 100644 index 0000000000..d57dd296db --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/layouts/ajax-test.htm @@ -0,0 +1,10 @@ +description = "This layout tests the AJAX events" +== +function onTest() { + $this['var'] = 'layout'; +} +function onTestLayout() { + $this['var'] = 'layout-test'; +} +== +{{ page() }} \ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/layouts/content.htm b/modules/system/tests/fixtures/themes/test/layouts/content.htm new file mode 100644 index 0000000000..7bc638e2d8 --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/layouts/content.htm @@ -0,0 +1 @@ +
{{ content('layout-content.txt') }}{{ page() }}
\ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/layouts/cycle-test.htm b/modules/system/tests/fixtures/themes/test/layouts/cycle-test.htm new file mode 100644 index 0000000000..9d79d760f9 --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/layouts/cycle-test.htm @@ -0,0 +1,15 @@ +description = "This layout tests the page life cycle" +== +function onStart() { + $this['layoutStartVar'] = 1; +} + +function onBeforePageStart() { + $this['layoutBeforePageStartVar'] = 2; +} + +function onEnd() { + $this['layoutEndVar'] = 5; +} +== +{{ page() }} \ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/layouts/no-php.htm b/modules/system/tests/fixtures/themes/test/layouts/no-php.htm new file mode 100644 index 0000000000..ee167f81cb --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/layouts/no-php.htm @@ -0,0 +1 @@ +
{{ page() }}
\ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/layouts/partials.htm b/modules/system/tests/fixtures/themes/test/layouts/partials.htm new file mode 100644 index 0000000000..7974106e38 --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/layouts/partials.htm @@ -0,0 +1 @@ +
{{ partial('layout-partial') }}{{ page() }}
\ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/layouts/php-parser-test.htm b/modules/system/tests/fixtures/themes/test/layouts/php-parser-test.htm new file mode 100644 index 0000000000..3f4f1a8c51 --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/layouts/php-parser-test.htm @@ -0,0 +1,10 @@ +description = "Layout for testing the CMS PHP parser" +== +function onStart() { + +} + +function onEnd() { +} +== +{{ layoutStartVar }}{{ layoutBeforePageStartVar }}{{ pageStartVar }}{{ pageEndVar }}{{ layoutEndVar }} \ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/layouts/placeholder.htm b/modules/system/tests/fixtures/themes/test/layouts/placeholder.htm new file mode 100644 index 0000000000..ad6ea14da2 --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/layouts/placeholder.htm @@ -0,0 +1 @@ +
LAYOUT CONTENT {% placeholder test default %}DEFAULT{% endplaceholder %} {{ page() }}
{% placeholder second %} \ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/layouts/sidebar.htm b/modules/system/tests/fixtures/themes/test/layouts/sidebar.htm new file mode 100644 index 0000000000..eb10b585d1 --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/layouts/sidebar.htm @@ -0,0 +1 @@ +
{% page %}
\ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/pages/404.htm b/modules/system/tests/fixtures/themes/test/pages/404.htm new file mode 100644 index 0000000000..583e8fd069 --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/pages/404.htm @@ -0,0 +1,3 @@ +url = "404" +== +

Page not found

\ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/pages/a/a-page.htm b/modules/system/tests/fixtures/themes/test/pages/a/a-page.htm new file mode 100644 index 0000000000..fbd83d69ce --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/pages/a/a-page.htm @@ -0,0 +1,4 @@ +url = "/apage" +layout = "a/a-layout" +== +

This page is a subdirectory

\ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/pages/ajax-test.htm b/modules/system/tests/fixtures/themes/test/pages/ajax-test.htm new file mode 100644 index 0000000000..7af37c437b --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/pages/ajax-test.htm @@ -0,0 +1,8 @@ +url = "/ajax-test" +layout = "ajax-test" +== +function onTest() { + $this['var'] = 'page'; +} +== +{{ layoutStartVar }}{{ layoutBeforePageStartVar }}{{ pageStartVar }}{{ pageEndVar }}{{ layoutEndVar }} \ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/pages/authors.htm b/modules/system/tests/fixtures/themes/test/pages/authors.htm new file mode 100644 index 0000000000..bf938f7feb --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/pages/authors.htm @@ -0,0 +1,4 @@ +url = "/authors/:author_id?no-author|^[0-9]+$" +== +

Authors page

+

This is the Authors page

\ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/pages/b/b-page.htm b/modules/system/tests/fixtures/themes/test/pages/b/b-page.htm new file mode 100644 index 0000000000..9a3cb6a635 --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/pages/b/b-page.htm @@ -0,0 +1,3 @@ +url = "/bpage" +== +

This page is a subdirectory

\ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/pages/b/c/c-page.htm b/modules/system/tests/fixtures/themes/test/pages/b/c/c-page.htm new file mode 100644 index 0000000000..10915cbea2 --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/pages/b/c/c-page.htm @@ -0,0 +1,3 @@ +url = "/cpage" +== +

This page is a subdirectory

\ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/pages/blog-archive.htm b/modules/system/tests/fixtures/themes/test/pages/blog-archive.htm new file mode 100644 index 0000000000..6f28cc8fcb --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/pages/blog-archive.htm @@ -0,0 +1,4 @@ +url = "/blog/archive-page/:page?1" +== +

Blog Archive

+

Hi there!

\ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/pages/blog-category.htm b/modules/system/tests/fixtures/themes/test/pages/blog-category.htm new file mode 100644 index 0000000000..0f9389013f --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/pages/blog-category.htm @@ -0,0 +1,4 @@ +url = "/blog/category-page/:category_name?*" +== +

Blog category

+

This is a blog category page

\ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/pages/blog-post.htm b/modules/system/tests/fixtures/themes/test/pages/blog-post.htm new file mode 100644 index 0000000000..b39ac35356 --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/pages/blog-post.htm @@ -0,0 +1,4 @@ +url = "/blog/post/:url_title" +== +

Blog post

+

This is a blog post page

\ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/pages/code-namespaces-aliases.htm b/modules/system/tests/fixtures/themes/test/pages/code-namespaces-aliases.htm new file mode 100644 index 0000000000..951726af69 --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/pages/code-namespaces-aliases.htm @@ -0,0 +1,13 @@ +url = "/code-namespaces" +== + +== +

Page

\ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/pages/code-namespaces.htm b/modules/system/tests/fixtures/themes/test/pages/code-namespaces.htm new file mode 100644 index 0000000000..1313f826dc --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/pages/code-namespaces.htm @@ -0,0 +1,13 @@ +url = "/code-namespaces" +== + +== +

Page

\ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/pages/component-custom-render.htm b/modules/system/tests/fixtures/themes/test/pages/component-custom-render.htm new file mode 100644 index 0000000000..9fc2c5d549 --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/pages/component-custom-render.htm @@ -0,0 +1,10 @@ +url = "/component-custom-render" + +[Winter\Tester\Components\ContentBlock theblock] +== + +{% component 'theblock' %} + +{% component 'theblock' output="Would you look over Picasso's shoulder" %} + +{% component 'theblock' output='And tell him about his brush strokes?' %} diff --git a/modules/system/tests/fixtures/themes/test/pages/component-partial-alias-override.htm b/modules/system/tests/fixtures/themes/test/pages/component-partial-alias-override.htm new file mode 100644 index 0000000000..094712dd86 --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/pages/component-partial-alias-override.htm @@ -0,0 +1,5 @@ +url = "/component-partial-alias-override" + +[Winter\Tester\Components\Post overRide1] +== +{% component 'overRide1' %} \ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/pages/component-partial-nesting.htm b/modules/system/tests/fixtures/themes/test/pages/component-partial-nesting.htm new file mode 100644 index 0000000000..41d18f7bbe --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/pages/component-partial-nesting.htm @@ -0,0 +1,3 @@ +url = "/component-partial-nesting" +== +{% partial 'nesting/level1' %} \ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/pages/component-partial-override.htm b/modules/system/tests/fixtures/themes/test/pages/component-partial-override.htm new file mode 100644 index 0000000000..42f95a85dd --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/pages/component-partial-override.htm @@ -0,0 +1,5 @@ +url = "/component-partial-override" + +[testPost] +== +{% component 'testPost' %} \ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/pages/component-partial.htm b/modules/system/tests/fixtures/themes/test/pages/component-partial.htm new file mode 100644 index 0000000000..beb429194f --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/pages/component-partial.htm @@ -0,0 +1,5 @@ +url = "/component-partial" + +[Winter\Tester\Components\Post post] +== +{% component 'post' %} \ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/pages/cycle-test.htm b/modules/system/tests/fixtures/themes/test/pages/cycle-test.htm new file mode 100644 index 0000000000..3f7e8aa389 --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/pages/cycle-test.htm @@ -0,0 +1,12 @@ +url = "/cycle-test" +layout = "cycle-test" +== +function onStart() { + $this['pageStartVar'] = 3; +} + +function onEnd() { + $this['pageEndVar'] = 4; +} +== +{{ layoutStartVar }}{{ layoutBeforePageStartVar }}{{ pageStartVar }}{{ pageEndVar }}{{ layoutEndVar }} \ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/pages/filters-test.htm b/modules/system/tests/fixtures/themes/test/pages/filters-test.htm new file mode 100644 index 0000000000..ac6b767690 --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/pages/filters-test.htm @@ -0,0 +1,13 @@ +url = "/filters-test/:url_title?" +== +{# Check pageUrl for current page #} +{{ '' | page }} -> {{ '/filters-test/current-slug' | app }} +{# Check pageUrl for persistent URL parameters #} +{{ 'blog-post' | page }} -> {{ '/blog/post/current-slug' | app }} +{# Check pageUrl for providing values for URL parameters #} +{{ 'blog-post' | page({url_title: 'test-slug'}) }} -> {{ '/blog/post/test-slug' | app }} +{# Check pageUrl for disabling persistent URL parameters #} +{{ 'blog-post' | page({}, false) }} -> {{ '/blog/post/default' | app }} +{# Check pageUrl for disabling persistent URL parameters with the second argument being routePersistence #} +{{ 'blog-post' | page(false) }} -> {{ '/blog/post/default' | app }} + diff --git a/modules/system/tests/fixtures/themes/test/pages/index.htm b/modules/system/tests/fixtures/themes/test/pages/index.htm new file mode 100644 index 0000000000..13913b0e8f --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/pages/index.htm @@ -0,0 +1,3 @@ +url = "/" +== +

My Webpage

\ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/pages/no-component-class.htm b/modules/system/tests/fixtures/themes/test/pages/no-component-class.htm new file mode 100644 index 0000000000..d9e406a4e6 --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/pages/no-component-class.htm @@ -0,0 +1,5 @@ +url = "/no-component-class" + +[PeterPan\Nevernever\Land noComponentExist] +== +

Hey

diff --git a/modules/system/tests/fixtures/themes/test/pages/no-component.htm b/modules/system/tests/fixtures/themes/test/pages/no-component.htm new file mode 100644 index 0000000000..0a7761b474 --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/pages/no-component.htm @@ -0,0 +1,3 @@ +url = "/no-component" +== +

Hey

{% component 'noComponentExist' %} \ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/pages/no-layout.htm b/modules/system/tests/fixtures/themes/test/pages/no-layout.htm new file mode 100644 index 0000000000..06abad0383 --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/pages/no-layout.htm @@ -0,0 +1,4 @@ +url = "/no-layout" +layout = "caramba" +== +

Hey

\ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/pages/no-partial.htm b/modules/system/tests/fixtures/themes/test/pages/no-partial.htm new file mode 100644 index 0000000000..65af950640 --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/pages/no-partial.htm @@ -0,0 +1,4 @@ +url = "/no-partial" +== +

Hey

+{% partial 'caramba' %} diff --git a/modules/system/tests/fixtures/themes/test/pages/no-soft-component-class.htm b/modules/system/tests/fixtures/themes/test/pages/no-soft-component-class.htm new file mode 100644 index 0000000000..9559b16dcf --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/pages/no-soft-component-class.htm @@ -0,0 +1,5 @@ +url = "/no-soft-component-class" + +[@PeterPan\Nevernever\Land noComponentExist] +== +

Hey

\ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/pages/optional-full-php-tags.htm b/modules/system/tests/fixtures/themes/test/pages/optional-full-php-tags.htm new file mode 100644 index 0000000000..1c93ff1467 --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/pages/optional-full-php-tags.htm @@ -0,0 +1,14 @@ +url = "/cycle-test" +layout = "cycle-test" +== + +== +{{ layoutStartVar }}{{ layoutBeforePageStartVar }}{{ pageStartVar }}{{ pageEndVar }}{{ layoutEndVar }} \ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/pages/optional-short-php-tags.htm b/modules/system/tests/fixtures/themes/test/pages/optional-short-php-tags.htm new file mode 100644 index 0000000000..2401ae9bcb --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/pages/optional-short-php-tags.htm @@ -0,0 +1,14 @@ +url = "/cycle-test" +layout = "cycle-test" +== + +== +{{ layoutStartVar }}{{ layoutBeforePageStartVar }}{{ pageStartVar }}{{ pageEndVar }}{{ layoutEndVar }} \ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/pages/throw-php.htm b/modules/system/tests/fixtures/themes/test/pages/throw-php.htm new file mode 100644 index 0000000000..1785a3a382 --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/pages/throw-php.htm @@ -0,0 +1,7 @@ +url = "/throw-php" +== +function onStart() { + test(); +} +== +

This page will throw an exception

\ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/pages/with-component.htm b/modules/system/tests/fixtures/themes/test/pages/with-component.htm new file mode 100644 index 0000000000..eff57d3e0b --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/pages/with-component.htm @@ -0,0 +1,11 @@ +url = "/with-component" +layout = "content" + +[testArchive] +posts-per-page = "69" +== +

This page uses components.

+{% for post in testArchive.posts %} +

{{ post.title }}

+

{{ post.content }}

+{% endfor %} \ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/pages/with-components.htm b/modules/system/tests/fixtures/themes/test/pages/with-components.htm new file mode 100644 index 0000000000..0e5ad47185 --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/pages/with-components.htm @@ -0,0 +1,14 @@ +url = "/with-components" +layout = "content" + +[testArchive firstAlias] +posts-per-page = "6" + +[Winter\Tester\Components\Archive secondAlias] +posts-per-page = "9" +== +

This page uses components.

+{% for post in secondAlias.posts %} +

{{ post.title }}

+

{{ post.content }}

+{% endfor %} \ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/pages/with-content.htm b/modules/system/tests/fixtures/themes/test/pages/with-content.htm new file mode 100644 index 0000000000..c47e05e580 --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/pages/with-content.htm @@ -0,0 +1,4 @@ +url = "/with-content" +layout = "content" +== +

Hey {% content "page-content.htm" %} {% content "a/a-content.htm" %}

\ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/pages/with-layout.htm b/modules/system/tests/fixtures/themes/test/pages/with-layout.htm new file mode 100644 index 0000000000..9908d6ed7f --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/pages/with-layout.htm @@ -0,0 +1,4 @@ +url = "/with-layout" +layout = "sidebar" +== +

Hey

\ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/pages/with-partials.htm b/modules/system/tests/fixtures/themes/test/pages/with-partials.htm new file mode 100644 index 0000000000..5e1531c26b --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/pages/with-partials.htm @@ -0,0 +1,4 @@ +url = "/with-partials" +layout = "partials" +== +

Hey {% partial "page-partial" firstName="Homer" lastName="Simpson" %} {% partial "a/a-partial" %}

\ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/pages/with-placeholder.htm b/modules/system/tests/fixtures/themes/test/pages/with-placeholder.htm new file mode 100644 index 0000000000..05601d3e59 --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/pages/with-placeholder.htm @@ -0,0 +1,11 @@ +url = "/with-placeholder" +layout = "placeholder" +== +{% put test %} + BLOCK + {% default %} +{% endput %} +{% put second %} + SECOND BLOCK +{% endput %} +

Hey PAGE CONTENT

\ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/pages/with-soft-component-class-alias.htm b/modules/system/tests/fixtures/themes/test/pages/with-soft-component-class-alias.htm new file mode 100644 index 0000000000..072b1e2140 --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/pages/with-soft-component-class-alias.htm @@ -0,0 +1,11 @@ +url = "/with-soft-component-class-alias" +layout = "content" + +[@testArchive someAlias] +posts-per-page = "69" +== +

This page uses components.

+{% for post in someAlias.posts %} +

{{ post.title }}

+

{{ post.content }}

+{% endfor %} diff --git a/modules/system/tests/fixtures/themes/test/pages/with-soft-component-class.htm b/modules/system/tests/fixtures/themes/test/pages/with-soft-component-class.htm new file mode 100644 index 0000000000..330dc565ec --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/pages/with-soft-component-class.htm @@ -0,0 +1,11 @@ +url = "/with-soft-component-class" +layout = "content" + +[@testArchive] +posts-per-page = "69" +== +

This page uses components.

+{% for post in testArchive.posts %} +

{{ post.title }}

+

{{ post.content }}

+{% endfor %} diff --git a/modules/system/tests/fixtures/themes/test/partials/a/a-partial.htm b/modules/system/tests/fixtures/themes/test/partials/a/a-partial.htm new file mode 100644 index 0000000000..c081986734 --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/partials/a/a-partial.htm @@ -0,0 +1 @@ +A partial \ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/partials/ajax-result.htm b/modules/system/tests/fixtures/themes/test/partials/ajax-result.htm new file mode 100644 index 0000000000..05fcf37093 --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/partials/ajax-result.htm @@ -0,0 +1 @@ +{{ var }} \ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/partials/ajax-second-result.htm b/modules/system/tests/fixtures/themes/test/partials/ajax-second-result.htm new file mode 100644 index 0000000000..2147e41889 --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/partials/ajax-second-result.htm @@ -0,0 +1 @@ +second \ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/partials/layout-partial.htm b/modules/system/tests/fixtures/themes/test/partials/layout-partial.htm new file mode 100644 index 0000000000..1a38c3962a --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/partials/layout-partial.htm @@ -0,0 +1 @@ +LAYOUT PARTIAL \ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/partials/nesting/level1.htm b/modules/system/tests/fixtures/themes/test/partials/nesting/level1.htm new file mode 100644 index 0000000000..c9fcb87857 --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/partials/nesting/level1.htm @@ -0,0 +1,6 @@ +[Winter\Tester\Components\MainMenu override2] +[Winter\Tester\Components\Post override3] +== +

Level 1

+{% component 'override2' %} +{% component 'override3' %} diff --git a/modules/system/tests/fixtures/themes/test/partials/nesting/level2.htm b/modules/system/tests/fixtures/themes/test/partials/nesting/level2.htm new file mode 100644 index 0000000000..ff772d4afd --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/partials/nesting/level2.htm @@ -0,0 +1,6 @@ +[Winter\Tester\Components\Post post] +[Winter\Tester\Components\Post override4] +== +

Level 2

+{% component 'post' %} +{% component 'override4' %} \ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/partials/nesting/level3.htm b/modules/system/tests/fixtures/themes/test/partials/nesting/level3.htm new file mode 100644 index 0000000000..5c4059a9ea --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/partials/nesting/level3.htm @@ -0,0 +1,4 @@ +[Winter\Tester\Components\MainMenu mainMenu] +== +

Level 3

+{% component 'mainMenu' %} diff --git a/modules/system/tests/fixtures/themes/test/partials/override1/default.htm b/modules/system/tests/fixtures/themes/test/partials/override1/default.htm new file mode 100644 index 0000000000..b93cfda167 --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/partials/override1/default.htm @@ -0,0 +1 @@ +

I am an override alias partial! Yay

\ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/partials/override2/default.htm b/modules/system/tests/fixtures/themes/test/partials/override2/default.htm new file mode 100644 index 0000000000..7fb329768e --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/partials/override2/default.htm @@ -0,0 +1,7 @@ +
    +{% partial __SELF__ ~ "::items" items=__SELF__.menuItems %} +{% partial __SELF__ ~ "::items" items=__SELF__.menuItems %} +{% partial __SELF__ ~ "::items" items=__SELF__.menuItems %} +
+ +{% partial 'nesting/level2' %} \ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/partials/override2/items.htm b/modules/system/tests/fixtures/themes/test/partials/override2/items.htm new file mode 100644 index 0000000000..0c77fb3c75 --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/partials/override2/items.htm @@ -0,0 +1,3 @@ +{% for item in items %} + {{ item }} +{% endfor %} \ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/partials/override3/default.htm b/modules/system/tests/fixtures/themes/test/partials/override3/default.htm new file mode 100644 index 0000000000..c49f68778a --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/partials/override3/default.htm @@ -0,0 +1 @@ +

Insert post here

\ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/partials/override4/default.htm b/modules/system/tests/fixtures/themes/test/partials/override4/default.htm new file mode 100644 index 0000000000..0b884776e0 --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/partials/override4/default.htm @@ -0,0 +1,3 @@ +

I am another post, deep down

+ +{% partial 'nesting/level3' %} \ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/partials/page-partial.htm b/modules/system/tests/fixtures/themes/test/partials/page-partial.htm new file mode 100644 index 0000000000..c31a9b29e6 --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/partials/page-partial.htm @@ -0,0 +1 @@ +PAGE PARTIAL {{ firstName }} {{ lastName }} \ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/partials/testpost/default.htm b/modules/system/tests/fixtures/themes/test/partials/testpost/default.htm new file mode 100644 index 0000000000..ebc57e24da --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/partials/testpost/default.htm @@ -0,0 +1 @@ +

I am an override partial! Yay

\ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/temporary/.gitignore b/modules/system/tests/fixtures/themes/test/temporary/.gitignore new file mode 100644 index 0000000000..c96a04f008 --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/temporary/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/testobjects/component.htm b/modules/system/tests/fixtures/themes/test/testobjects/component.htm new file mode 100644 index 0000000000..d8a2110acb --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/testobjects/component.htm @@ -0,0 +1,5 @@ +var = value +[testArchive] +posts-per-page = 10 +== +

This is a paragraph

\ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/testobjects/components.htm b/modules/system/tests/fixtures/themes/test/testobjects/components.htm new file mode 100644 index 0000000000..aae5da8a7a --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/testobjects/components.htm @@ -0,0 +1,8 @@ +var = value +[testArchive firstAlias] +posts-per-page = "6" + +[Winter\Tester\Components\Post secondAlias] +show-featured = "true" +== +

This is a paragraph

\ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/testobjects/compound.htm b/modules/system/tests/fixtures/themes/test/testobjects/compound.htm new file mode 100644 index 0000000000..7174624bcb --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/testobjects/compound.htm @@ -0,0 +1,10 @@ +var = value +[section] +version = 10 +== +function onBeforeDisplay($controller) +{ + $controller->data['something'] = 'some value'; +} +== +

This is a paragraph

\ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/testobjects/plain.html b/modules/system/tests/fixtures/themes/test/testobjects/plain.html new file mode 100644 index 0000000000..cd817bccba --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/testobjects/plain.html @@ -0,0 +1 @@ +

This is a test HTML content file.

\ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/testobjects/subdir/obj.html b/modules/system/tests/fixtures/themes/test/testobjects/subdir/obj.html new file mode 100644 index 0000000000..9502022abd --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/testobjects/subdir/obj.html @@ -0,0 +1 @@ +

This is an object in a subdirectory.

\ No newline at end of file diff --git a/modules/system/tests/fixtures/themes/test/testobjects/viewbag.htm b/modules/system/tests/fixtures/themes/test/testobjects/viewbag.htm new file mode 100644 index 0000000000..0a4268e52d --- /dev/null +++ b/modules/system/tests/fixtures/themes/test/testobjects/viewbag.htm @@ -0,0 +1,5 @@ +var = value +[viewBag] +title = "Toxicity" +== +

Chop Suey!

\ No newline at end of file diff --git a/tests/js/.babelrc b/modules/system/tests/js/.babelrc similarity index 100% rename from tests/js/.babelrc rename to modules/system/tests/js/.babelrc diff --git a/tests/js/.gitignore b/modules/system/tests/js/.gitignore similarity index 100% rename from tests/js/.gitignore rename to modules/system/tests/js/.gitignore diff --git a/tests/js/README.md b/modules/system/tests/js/README.md similarity index 100% rename from tests/js/README.md rename to modules/system/tests/js/README.md diff --git a/tests/js/cases/snowboard/ajax/Request.test.js b/modules/system/tests/js/cases/snowboard/ajax/Request.test.js similarity index 100% rename from tests/js/cases/snowboard/ajax/Request.test.js rename to modules/system/tests/js/cases/snowboard/ajax/Request.test.js diff --git a/tests/js/cases/snowboard/extras/DataConfig.test.js b/modules/system/tests/js/cases/snowboard/extras/DataConfig.test.js similarity index 96% rename from tests/js/cases/snowboard/extras/DataConfig.test.js rename to modules/system/tests/js/cases/snowboard/extras/DataConfig.test.js index 339f0c09d3..7f6a642245 100644 --- a/tests/js/cases/snowboard/extras/DataConfig.test.js +++ b/modules/system/tests/js/cases/snowboard/extras/DataConfig.test.js @@ -14,7 +14,7 @@ describe('The Data Config extra functionality', function () { 'modules/system/assets/js/snowboard/build/snowboard.vendor.js', 'modules/system/assets/js/snowboard/build/snowboard.base.js', 'modules/system/assets/js/snowboard/build/snowboard.extras.js', - 'tests/js/fixtures/dataConfig/DataConfigFixture.js', + 'modules/system/tests/js/fixtures/dataConfig/DataConfigFixture.js', ]) .render( `
runPluginRefreshCommand('Database.Tester'); } @@ -21,7 +25,7 @@ public function testDeleteFlagDestroyRelationship() Model::reguard(); $this->assertEmpty($user->photos); - $user->photos()->create(['data' => base_path().'/tests/fixtures/plugins/database/tester/assets/images/avatar.png']); + $user->photos()->create(['data' => base_path() . '/modules/system/tests/fixtures/plugins/database/tester/assets/images/avatar.png']); $user->reloadRelations(); $this->assertNotEmpty($user->photos); @@ -39,7 +43,7 @@ public function testDeleteFlagDeleteModel() Model::reguard(); $this->assertEmpty($user->photos); - $user->photos()->create(['data' => base_path().'/tests/fixtures/plugins/database/tester/assets/images/avatar.png']); + $user->photos()->create(['data' => base_path() . '/modules/system/tests/fixtures/plugins/database/tester/assets/images/avatar.png']); $user->reloadRelations(); $this->assertNotEmpty($user->photos); diff --git a/tests/unit/plugins/database/AttachOneModelTest.php b/modules/system/tests/plugins/database/AttachOneModelTest.php similarity index 77% rename from tests/unit/plugins/database/AttachOneModelTest.php rename to modules/system/tests/plugins/database/AttachOneModelTest.php index 08dab04dd0..c7ba1307dc 100644 --- a/tests/unit/plugins/database/AttachOneModelTest.php +++ b/modules/system/tests/plugins/database/AttachOneModelTest.php @@ -1,9 +1,13 @@ runPluginRefreshCommand('Database.Tester'); } @@ -24,7 +28,7 @@ public function testSetRelationValue() Model::reguard(); // Set by string - $user->avatar = base_path().'/tests/fixtures/plugins/database/tester/assets/images/avatar.png'; + $user->avatar = base_path() . '/modules/system/tests/fixtures/plugins/database/tester/assets/images/avatar.png'; // @todo $user->avatar currently sits as a string, not good for validation // this should really assert as an UploadedFile instead. @@ -38,7 +42,7 @@ public function testSetRelationValue() // Set by Uploaded file $sample = $user->avatar; $upload = new UploadedFile( - base_path().'/tests/fixtures/plugins/database/tester/assets/images/avatar.png', + base_path() . '/modules/system/tests/fixtures/plugins/database/tester/assets/images/avatar.png', $sample->file_name, $sample->content_type, null, @@ -65,7 +69,7 @@ public function testDeleteFlagDestroyRelationship() Model::reguard(); $this->assertNull($user->avatar); - $user->avatar()->create(['data' => base_path().'/tests/fixtures/plugins/database/tester/assets/images/avatar.png']); + $user->avatar()->create(['data' => base_path() . '/modules/system/tests/fixtures/plugins/database/tester/assets/images/avatar.png']); $user->reloadRelations(); $this->assertNotNull($user->avatar); @@ -83,7 +87,7 @@ public function testDeleteFlagDeleteModel() Model::reguard(); $this->assertNull($user->avatar); - $user->avatar()->create(['data' => base_path().'/tests/fixtures/plugins/database/tester/assets/images/avatar.png']); + $user->avatar()->create(['data' => base_path() . '/modules/system/tests/fixtures/plugins/database/tester/assets/images/avatar.png']); $user->reloadRelations(); $this->assertNotNull($user->avatar); @@ -98,7 +102,7 @@ public function testDeleteFlagSoftDeleteModel() $user = SoftDeleteUser::create(['name' => 'Stevie', 'email' => 'stevie@example.com']); Model::reguard(); - $user->avatar()->create(['data' => base_path().'/tests/fixtures/plugins/database/tester/assets/images/avatar.png']); + $user->avatar()->create(['data' => base_path() . '/modules/system/tests/fixtures/plugins/database/tester/assets/images/avatar.png']); $this->assertNotNull($user->avatar); $avatarId = $user->avatar->id; diff --git a/tests/unit/plugins/database/BelongsToManyModelTest.php b/modules/system/tests/plugins/database/BelongsToManyModelTest.php similarity index 91% rename from tests/unit/plugins/database/BelongsToManyModelTest.php rename to modules/system/tests/plugins/database/BelongsToManyModelTest.php index 531da84cb6..71150db329 100644 --- a/tests/unit/plugins/database/BelongsToManyModelTest.php +++ b/modules/system/tests/plugins/database/BelongsToManyModelTest.php @@ -1,9 +1,14 @@ runPluginRefreshCommand('Database.Tester'); } @@ -174,8 +179,8 @@ public function testDeferredBinding() public function testDetachAfterDelete() { // Needed for other "delete" events - include_once base_path().'/tests/fixtures/plugins/database/tester/models/User.php'; - include_once base_path().'/tests/fixtures/plugins/database/tester/models/EventLog.php'; + include_once base_path() . '/modules/system/tests/fixtures/plugins/database/tester/models/User.php'; + include_once base_path() . '/modules/system/tests/fixtures/plugins/database/tester/models/EventLog.php'; Model::unguard(); $author = Author::create(['name' => 'Stevie', 'email' => 'stevie@example.com']); @@ -187,10 +192,10 @@ public function testDetachAfterDelete() $author->roles()->add($role1); $author->roles()->add($role2); $author->roles()->add($role3); - $this->assertEquals(3, Db::table('database_tester_authors_roles')->where('author_id', $author->id)->count()); + $this->assertEquals(3, DB::table('database_tester_authors_roles')->where('author_id', $author->id)->count()); $author->delete(); - $this->assertEquals(0, Db::table('database_tester_authors_roles')->where('author_id', $author->id)->count()); + $this->assertEquals(0, DB::table('database_tester_authors_roles')->where('author_id', $author->id)->count()); } public function testConditionsWithPivotAttributes() diff --git a/tests/unit/plugins/database/BelongsToModelTest.php b/modules/system/tests/plugins/database/BelongsToModelTest.php similarity index 91% rename from tests/unit/plugins/database/BelongsToModelTest.php rename to modules/system/tests/plugins/database/BelongsToModelTest.php index 160bdf9b3a..5f96081a9b 100644 --- a/tests/unit/plugins/database/BelongsToModelTest.php +++ b/modules/system/tests/plugins/database/BelongsToModelTest.php @@ -1,7 +1,11 @@ runPluginRefreshCommand('Database.Tester'); } diff --git a/tests/unit/plugins/database/DeferredBindingTest.php b/modules/system/tests/plugins/database/DeferredBindingTest.php similarity index 91% rename from tests/unit/plugins/database/DeferredBindingTest.php rename to modules/system/tests/plugins/database/DeferredBindingTest.php index 0cb7db4870..a190410a94 100644 --- a/tests/unit/plugins/database/DeferredBindingTest.php +++ b/modules/system/tests/plugins/database/DeferredBindingTest.php @@ -1,8 +1,12 @@ runPluginRefreshCommand('Database.Tester'); } diff --git a/tests/unit/plugins/database/HasManyModelTest.php b/modules/system/tests/plugins/database/HasManyModelTest.php similarity index 92% rename from tests/unit/plugins/database/HasManyModelTest.php rename to modules/system/tests/plugins/database/HasManyModelTest.php index 0226f670f0..058b9a9e1b 100644 --- a/tests/unit/plugins/database/HasManyModelTest.php +++ b/modules/system/tests/plugins/database/HasManyModelTest.php @@ -1,8 +1,12 @@ runPluginRefreshCommand('Database.Tester'); } diff --git a/tests/unit/plugins/database/HasManyThroughModelTest.php b/modules/system/tests/plugins/database/HasManyThroughModelTest.php similarity index 78% rename from tests/unit/plugins/database/HasManyThroughModelTest.php rename to modules/system/tests/plugins/database/HasManyThroughModelTest.php index 99286a2cd0..568d91a0ce 100644 --- a/tests/unit/plugins/database/HasManyThroughModelTest.php +++ b/modules/system/tests/plugins/database/HasManyThroughModelTest.php @@ -1,9 +1,13 @@ runPluginRefreshCommand('Database.Tester'); } diff --git a/tests/unit/plugins/database/HasOneModelTest.php b/modules/system/tests/plugins/database/HasOneModelTest.php similarity index 93% rename from tests/unit/plugins/database/HasOneModelTest.php rename to modules/system/tests/plugins/database/HasOneModelTest.php index 375b85e385..7d0b4907c4 100644 --- a/tests/unit/plugins/database/HasOneModelTest.php +++ b/modules/system/tests/plugins/database/HasOneModelTest.php @@ -1,7 +1,11 @@ runPluginRefreshCommand('Database.Tester'); } diff --git a/tests/unit/plugins/database/HasOneThroughModelTest.php b/modules/system/tests/plugins/database/HasOneThroughModelTest.php similarity index 67% rename from tests/unit/plugins/database/HasOneThroughModelTest.php rename to modules/system/tests/plugins/database/HasOneThroughModelTest.php index 91be83b606..e121846afb 100644 --- a/tests/unit/plugins/database/HasOneThroughModelTest.php +++ b/modules/system/tests/plugins/database/HasOneThroughModelTest.php @@ -1,8 +1,12 @@ runPluginRefreshCommand('Database.Tester'); } diff --git a/tests/unit/plugins/database/MorphManyModelTest.php b/modules/system/tests/plugins/database/MorphManyModelTest.php similarity index 92% rename from tests/unit/plugins/database/MorphManyModelTest.php rename to modules/system/tests/plugins/database/MorphManyModelTest.php index ef0bb860e5..723046a742 100644 --- a/tests/unit/plugins/database/MorphManyModelTest.php +++ b/modules/system/tests/plugins/database/MorphManyModelTest.php @@ -1,10 +1,14 @@ runPluginRefreshCommand('Database.Tester'); } @@ -158,7 +162,6 @@ public function testDeferredBinding() $this->assertEquals(88, $tagForPost->posts->first()->pivot->added_by); // Commit deferred (model is deleted as per definition) - $this->markTestSkipped("Issues are back at it again"); $author->save(null, $sessionKey); $event = EventLog::find($eventId); $this->assertEquals(0, $author->event_log()->count()); diff --git a/tests/unit/plugins/database/MorphOneModelTest.php b/modules/system/tests/plugins/database/MorphOneModelTest.php similarity index 92% rename from tests/unit/plugins/database/MorphOneModelTest.php rename to modules/system/tests/plugins/database/MorphOneModelTest.php index 41bdc2c979..ce434eaac1 100644 --- a/tests/unit/plugins/database/MorphOneModelTest.php +++ b/modules/system/tests/plugins/database/MorphOneModelTest.php @@ -1,8 +1,12 @@ runPluginRefreshCommand('Database.Tester'); } diff --git a/tests/unit/plugins/database/MorphToModelTest.php b/modules/system/tests/plugins/database/MorphToModelTest.php similarity index 82% rename from tests/unit/plugins/database/MorphToModelTest.php rename to modules/system/tests/plugins/database/MorphToModelTest.php index fe78bdf1b0..bdae9f7aaf 100644 --- a/tests/unit/plugins/database/MorphToModelTest.php +++ b/modules/system/tests/plugins/database/MorphToModelTest.php @@ -1,8 +1,12 @@ runPluginRefreshCommand('Database.Tester'); } diff --git a/tests/unit/plugins/database/NestedTreeModelTest.php b/modules/system/tests/plugins/database/NestedTreeModelTest.php similarity index 95% rename from tests/unit/plugins/database/NestedTreeModelTest.php rename to modules/system/tests/plugins/database/NestedTreeModelTest.php index 49d46764c6..e533a8b319 100644 --- a/tests/unit/plugins/database/NestedTreeModelTest.php +++ b/modules/system/tests/plugins/database/NestedTreeModelTest.php @@ -1,7 +1,11 @@ runPluginRefreshCommand('Database.Tester'); $this->seedSampleTree(); diff --git a/tests/unit/plugins/database/NullableModelTest.php b/modules/system/tests/plugins/database/NullableModelTest.php similarity index 89% rename from tests/unit/plugins/database/NullableModelTest.php rename to modules/system/tests/plugins/database/NullableModelTest.php index a0092e6e85..14d93c9a1f 100644 --- a/tests/unit/plugins/database/NullableModelTest.php +++ b/modules/system/tests/plugins/database/NullableModelTest.php @@ -1,5 +1,8 @@ runPluginRefreshCommand('Database.Tester'); } diff --git a/tests/unit/plugins/database/PluginModelTest.php b/modules/system/tests/plugins/database/PluginModelTest.php similarity index 79% rename from tests/unit/plugins/database/PluginModelTest.php rename to modules/system/tests/plugins/database/PluginModelTest.php index 85d7e31b85..e0514958b5 100644 --- a/tests/unit/plugins/database/PluginModelTest.php +++ b/modules/system/tests/plugins/database/PluginModelTest.php @@ -1,5 +1,8 @@ runPluginRefreshCommand('Database.Tester'); } diff --git a/tests/unit/plugins/database/RevisionableModelTest.php b/modules/system/tests/plugins/database/RevisionableModelTest.php similarity index 95% rename from tests/unit/plugins/database/RevisionableModelTest.php rename to modules/system/tests/plugins/database/RevisionableModelTest.php index c8fa19a540..543ac7cd80 100644 --- a/tests/unit/plugins/database/RevisionableModelTest.php +++ b/modules/system/tests/plugins/database/RevisionableModelTest.php @@ -1,7 +1,11 @@ runPluginRefreshCommand('Database.Tester'); } diff --git a/tests/unit/plugins/database/SimpleTreeModelTest.php b/modules/system/tests/plugins/database/SimpleTreeModelTest.php similarity index 97% rename from tests/unit/plugins/database/SimpleTreeModelTest.php rename to modules/system/tests/plugins/database/SimpleTreeModelTest.php index c499ac5ba0..1ec3847440 100644 --- a/tests/unit/plugins/database/SimpleTreeModelTest.php +++ b/modules/system/tests/plugins/database/SimpleTreeModelTest.php @@ -1,7 +1,11 @@ runPluginRefreshCommand('Database.Tester'); $this->seedSampleTree(); diff --git a/tests/unit/plugins/database/SluggableModelTest.php b/modules/system/tests/plugins/database/SluggableModelTest.php similarity index 94% rename from tests/unit/plugins/database/SluggableModelTest.php rename to modules/system/tests/plugins/database/SluggableModelTest.php index 22cad1837c..c623337948 100644 --- a/tests/unit/plugins/database/SluggableModelTest.php +++ b/modules/system/tests/plugins/database/SluggableModelTest.php @@ -1,5 +1,8 @@ runPluginRefreshCommand('Database.Tester'); } diff --git a/tests/unit/plugins/database/SoftDeleteModelTest.php b/modules/system/tests/plugins/database/SoftDeleteModelTest.php similarity index 91% rename from tests/unit/plugins/database/SoftDeleteModelTest.php rename to modules/system/tests/plugins/database/SoftDeleteModelTest.php index 32c9c68b9a..597bffd3f9 100644 --- a/tests/unit/plugins/database/SoftDeleteModelTest.php +++ b/modules/system/tests/plugins/database/SoftDeleteModelTest.php @@ -1,5 +1,8 @@ runPluginRefreshCommand('Database.Tester'); } diff --git a/tests/unit/plugins/database/ValidationModelTest.php b/modules/system/tests/plugins/database/ValidationModelTest.php similarity index 80% rename from tests/unit/plugins/database/ValidationModelTest.php rename to modules/system/tests/plugins/database/ValidationModelTest.php index f6b9bcc9a1..08b44da257 100644 --- a/tests/unit/plugins/database/ValidationModelTest.php +++ b/modules/system/tests/plugins/database/ValidationModelTest.php @@ -1,5 +1,8 @@ runPluginRefreshCommand('Database.Tester'); } diff --git a/tests/unit/plugins/system/CustomValidatorRulesTest.php b/modules/system/tests/plugins/system/CustomValidatorRulesTest.php similarity index 81% rename from tests/unit/plugins/system/CustomValidatorRulesTest.php rename to modules/system/tests/plugins/system/CustomValidatorRulesTest.php index 8227a663d9..db3ef7b817 100644 --- a/tests/unit/plugins/system/CustomValidatorRulesTest.php +++ b/modules/system/tests/plugins/system/CustomValidatorRulesTest.php @@ -1,13 +1,18 @@ runPluginRefreshCommand('Winter.Tester'); } diff --git a/tests/unit/system/traits/AssetMakerTest.php b/modules/system/tests/traits/AssetMakerTest.php similarity index 86% rename from tests/unit/system/traits/AssetMakerTest.php rename to modules/system/tests/traits/AssetMakerTest.php index 606df95628..d32b35d897 100644 --- a/tests/unit/system/traits/AssetMakerTest.php +++ b/modules/system/tests/traits/AssetMakerTest.php @@ -1,9 +1,15 @@ createApplication(); $this->stub = new ViewMakerStub(); - $this->relativePath = $this->normalizePath('tests/unit/system/traits/viewmakerstub'); + $this->relativePath = $this->normalizePath('modules/system/tests/traits/viewmakerstub'); } public function testViewPaths() diff --git a/tests/unit/system/traits/viewmakerstub/_can_override_php_with_htm.php b/modules/system/tests/traits/viewmakerstub/_can_override_php_with_htm.php similarity index 100% rename from tests/unit/system/traits/viewmakerstub/_can_override_php_with_htm.php rename to modules/system/tests/traits/viewmakerstub/_can_override_php_with_htm.php diff --git a/tests/unit/system/traits/viewmakerstub/_overridden.php b/modules/system/tests/traits/viewmakerstub/_overridden.php similarity index 100% rename from tests/unit/system/traits/viewmakerstub/_overridden.php rename to modules/system/tests/traits/viewmakerstub/_overridden.php diff --git a/tests/unit/system/traits/viewmakerstub/_relative_no_ext.php b/modules/system/tests/traits/viewmakerstub/_relative_no_ext.php similarity index 100% rename from tests/unit/system/traits/viewmakerstub/_relative_no_ext.php rename to modules/system/tests/traits/viewmakerstub/_relative_no_ext.php diff --git a/tests/unit/system/traits/viewmakerstub/folder/_no_ext.php b/modules/system/tests/traits/viewmakerstub/folder/_no_ext.php similarity index 100% rename from tests/unit/system/traits/viewmakerstub/folder/_no_ext.php rename to modules/system/tests/traits/viewmakerstub/folder/_no_ext.php diff --git a/tests/unit/system/traits/viewmakerstub/layouts/_layout_partial.php b/modules/system/tests/traits/viewmakerstub/layouts/_layout_partial.php similarity index 100% rename from tests/unit/system/traits/viewmakerstub/layouts/_layout_partial.php rename to modules/system/tests/traits/viewmakerstub/layouts/_layout_partial.php diff --git a/tests/unit/system/traits/viewmakerstub/layouts/default.php b/modules/system/tests/traits/viewmakerstub/layouts/default.php similarity index 100% rename from tests/unit/system/traits/viewmakerstub/layouts/default.php rename to modules/system/tests/traits/viewmakerstub/layouts/default.php diff --git a/tests/unit/system/traits/viewmakerstub/specific.php b/modules/system/tests/traits/viewmakerstub/specific.php similarity index 100% rename from tests/unit/system/traits/viewmakerstub/specific.php rename to modules/system/tests/traits/viewmakerstub/specific.php diff --git a/tests/unit/system/traits/viewmakerstub/symbols.php b/modules/system/tests/traits/viewmakerstub/symbols.php similarity index 100% rename from tests/unit/system/traits/viewmakerstub/symbols.php rename to modules/system/tests/traits/viewmakerstub/symbols.php diff --git a/tests/unit/system/traits/viewmakerstub/view.php b/modules/system/tests/traits/viewmakerstub/view.php similarity index 100% rename from tests/unit/system/traits/viewmakerstub/view.php rename to modules/system/tests/traits/viewmakerstub/view.php diff --git a/tests/unit/system/traits/viewmakerstuboverride/_can_override_php_with_htm.htm b/modules/system/tests/traits/viewmakerstuboverride/_can_override_php_with_htm.htm similarity index 100% rename from tests/unit/system/traits/viewmakerstuboverride/_can_override_php_with_htm.htm rename to modules/system/tests/traits/viewmakerstuboverride/_can_override_php_with_htm.htm diff --git a/tests/unit/system/traits/viewmakerstuboverride/_overridden.php b/modules/system/tests/traits/viewmakerstuboverride/_overridden.php similarity index 100% rename from tests/unit/system/traits/viewmakerstuboverride/_overridden.php rename to modules/system/tests/traits/viewmakerstuboverride/_overridden.php diff --git a/tests/unit/system/twig/FilterTest.php b/modules/system/tests/twig/FilterTest.php similarity index 97% rename from tests/unit/system/twig/FilterTest.php rename to modules/system/tests/twig/FilterTest.php index cd06cea073..7354ed1d06 100644 --- a/tests/unit/system/twig/FilterTest.php +++ b/modules/system/tests/twig/FilterTest.php @@ -1,5 +1,9 @@ - ./tests/unit + ./modules/system + ./modules/cms + ./modules/backend diff --git a/storage/.gitignore b/storage/.gitignore index 9b1dffd90f..617c22a6af 100644 --- a/storage/.gitignore +++ b/storage/.gitignore @@ -1 +1,2 @@ *.sqlite +/tests diff --git a/tests/.gitignore b/tests/.gitignore deleted file mode 100644 index 5d252d7c9f..0000000000 --- a/tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -storage \ No newline at end of file diff --git a/tests/unit/backend/widgets/FormTest.php b/tests/unit/backend/widgets/FormTest.php deleted file mode 100644 index bcfd630d00..0000000000 --- a/tests/unit/backend/widgets/FormTest.php +++ /dev/null @@ -1,235 +0,0 @@ -actingAs($user); - - $form = $this->restrictedFormFixture(); - - $form->render(); - $this->assertNull($form->getField('testRestricted')); - } - - public function testRestrictedFieldWithUserWithWrongPermissions() - { - $user = new UserFixture; - $this->actingAs($user->withPermission('test.wrong_permission', true)); - - $form = $this->restrictedFormFixture(); - - $form->render(); - $this->assertNull($form->getField('testRestricted')); - } - - public function testRestrictedFieldWithUserWithRightPermissions() - { - $user = new UserFixture; - $this->actingAs($user->withPermission('test.access_field', true)); - - $form = $this->restrictedFormFixture(); - - $form->render(); - $this->assertNotNull($form->getField('testRestricted')); - } - - public function testRestrictedFieldWithUserWithRightWildcardPermissions() - { - $user = new UserFixture; - $this->actingAs($user->withPermission('test.access_field', true)); - - $form = new Form(null, [ - 'model' => new FormTestModel, - 'arrayName' => 'array', - 'fields' => [ - 'testField' => [ - 'type' => 'text', - 'label' => 'Test 1' - ], - 'testRestricted' => [ - 'type' => 'text', - 'label' => 'Test 2', - 'permission' => 'test.*' - ] - ] - ]); - - $form->render(); - $this->assertNotNull($form->getField('testRestricted')); - } - - public function testRestrictedFieldWithSuperuser() - { - $user = new UserFixture; - $this->actingAs($user->asSuperUser()); - - $form = $this->restrictedFormFixture(); - - $form->render(); - $this->assertNotNull($form->getField('testRestricted')); - } - - public function testRestrictedFieldSinglePermissionWithUserWithWrongPermissions() - { - $user = new UserFixture; - $this->actingAs($user->withPermission('test.wrong_permission', true)); - - $form = $this->restrictedFormFixture(true); - - $form->render(); - $this->assertNull($form->getField('testRestricted')); - } - - public function testRestrictedFieldSinglePermissionWithUserWithRightPermissions() - { - $user = new UserFixture; - $this->actingAs($user->withPermission('test.access_field', true)); - - $form = $this->restrictedFormFixture(true); - - $form->render(); - $this->assertNotNull($form->getField('testRestricted')); - } - - public function testCheckboxlistTrigger() - { - $form = new Form(null, [ - 'model' => new FormTestModel, - 'arrayName' => 'array', - 'fields' => [ - 'trigger' => [ - 'type' => 'checkboxlist', - 'options' => [ - '1' => 'Value One' - ] - ], - 'triggered' => [ - 'type' => 'text', - 'trigger' => [ - 'field' => 'trigger[]', - 'action' => 'show', - 'condition' => 'value[1]' - ] - ] - ] - ]); - - $form->render(); - - $attributes = $form->getField('triggered')->getAttributes('container', false); - $this->assertEquals('[name="array[trigger][]"]', array_get($attributes, 'data-trigger')); - } - - public function testOptionsGeneration() - { - $form = new Form(null, [ - 'model' => new FormTestModel, - 'arrayName' => 'array', - 'fields' => [ - 'static_method_options' => [ - 'type' => 'dropdown', - 'options' => 'FormHelper::staticMethodOptions', - 'expect' => ['static', 'method'], - ], - 'callable_options' => [ - 'type' => 'dropdown', - 'options' => [\FormHelper::class, 'staticMethodOptions'], - 'expect' => ['static', 'method'], - ], - 'model_method_options' => [ - 'type' => 'dropdown', - 'options' => 'modelCustomOptionsMethod', - 'expect' => ['model', 'custom', 'options'], - ], - 'defined_options' => [ - 'type' => 'dropdown', - 'options' => ['value1', 'value2'], - 'expect' => ['value1', 'value2'], - ], - 'defined_options_key_value' => [ - 'type' => 'dropdown', - 'options' => [ - 'key1' => 'value1', - 'key2' => 'value2', - ], - 'expect' => [ - 'key1' => 'value1', - 'key2' => 'value2', - ], - ], - 'field_name_on_model_options_method' => [ - 'type' => 'dropdown', - 'expect' => ['model', 'field name', 'options method'], - ], - 'get_dropdown_options_method' => [ - 'type' => 'dropdown', - 'expect' => ['dropdown', 'options'], - ], - ] - ]); - - $form->render(); - - foreach ($form->getFields() as $name => $field) { - $this->assertEquals($field->options(), $field->config['expect']); - } - } - - protected function restrictedFormFixture(bool $singlePermission = false) - { - return new Form(null, [ - 'model' => new FormTestModel, - 'arrayName' => 'array', - 'fields' => [ - 'testField' => [ - 'type' => 'text', - 'label' => 'Test 1' - ], - 'testRestricted' => [ - 'type' => 'text', - 'label' => 'Test 2', - 'permissions' => ($singlePermission) ? 'test.access_field' : [ - 'test.access_field' - ] - ] - ] - ]); - } -} diff --git a/tests/unit/plugins/backend/ImportModelDbTest.php b/tests/unit/plugins/backend/ImportModelDbTest.php deleted file mode 100644 index 61a1d8ea95..0000000000 --- a/tests/unit/plugins/backend/ImportModelDbTest.php +++ /dev/null @@ -1,42 +0,0 @@ - base_path().'/tests/fixtures/backend/reference/file1.txt', - 'is_public' => false, - ]); - - $file2 = FileModel::create([ - 'data' => base_path().'/tests/fixtures/backend/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.' - ); - } -}