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 @@
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 @@ + +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 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" +== +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?*" +== +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" +== +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 = "/" +== +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" +== + +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/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 uses components.
+{% for post in testArchive.posts %} +{{ 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.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.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.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] +== +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 @@ +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( `