From 28a98f0a3bcd6489baca131ed74657645b6d10f8 Mon Sep 17 00:00:00 2001 From: quicksketch Date: Fri, 20 Oct 2023 10:13:39 -0700 Subject: [PATCH] Issue #155: Run tests on pull requests. --- .github/misc/default.conf | 13 ++ .github/misc/settings.local.php | 8 + .github/workflows/functional-tests.yml | 59 ++++++ .../tests/metatag_app_links.tags.test | 2 + tests/metatag.bulk_revert.test | 2 + tests/metatag.core_tag_removal.test | 2 + tests/metatag.image.test | 2 + tests/metatag.locale.test | 2 + tests/metatag.node.test | 2 + tests/metatag.node.with_i18n.test | 2 + tests/metatag.output_caching.test | 2 + tests/metatag.string_handling.test | 2 + tests/metatag.string_handling_with_i18n.test | 2 + tests/metatag.tags.test | 6 +- tests/metatag.term.test | 2 + tests/metatag.term.with_i18n.test | 2 + tests/metatag.tests.info | 4 +- tests/metatag.unit.test | 2 + tests/metatag.user.test | 2 + tests/metatag.with_i18n_config.test | 2 + tests/metatag.with_i18n_disabled.test | 2 + tests/metatag.with_i18n_output.test | 2 + tests/metatag.with_me.test | 2 + tests/metatag.with_media.test | 2 + tests/metatag.with_panels.test | 176 ------------------ tests/metatag.with_profile2.test | 2 + tests/metatag.with_search_api.test | 2 + tests/metatag.with_views.test | 2 + tests/metatag.xss.test | 2 + 29 files changed, 132 insertions(+), 180 deletions(-) create mode 100644 .github/misc/default.conf create mode 100644 .github/misc/settings.local.php create mode 100644 .github/workflows/functional-tests.yml delete mode 100644 tests/metatag.with_panels.test diff --git a/.github/misc/default.conf b/.github/misc/default.conf new file mode 100644 index 0000000..8aa0b69 --- /dev/null +++ b/.github/misc/default.conf @@ -0,0 +1,13 @@ + + # Variables in this file will be substituted in step "Setup Apache". + DocumentRoot _PWD + + + AllowOverride All + Require all granted + + + + SetHandler "proxy:unix:/run/php/php_PHP_V-fpm.sock|fcgi://localhost" + + diff --git a/.github/misc/settings.local.php b/.github/misc/settings.local.php new file mode 100644 index 0000000..b02216f --- /dev/null +++ b/.github/misc/settings.local.php @@ -0,0 +1,8 @@ +> $GITHUB_ENV + echo 'USE_PHP_V=8.2' >> $GITHUB_ENV + + - name: Install MariaDB + uses: shogo82148/actions-setup-mysql@v1 + with: + mysql-version: 'mariadb-10.5' + root-password: 'root' + auto-start: true + + - name: Verify setup and create database + run: | + echo -e '[client]\nuser = root\npassword = root\nhost = 127.0.0.1' > ~/.my.cnf + mysql -e 'SELECT version()\G' + mysql -e 'CREATE DATABASE backdrop;' + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ env.USE_PHP_V }} + coverage: none + + - name: Checkout Backdrop core + uses: actions/checkout@v3 + with: + repository: backdrop/backdrop + + - name: Checkout module + uses: actions/checkout@v3 + with: + path: modules/${{ env.REPO_NAME }} + + - name: Setup Apache + run: | + sudo cp -f modules/${{ env.REPO_NAME }}/.github/misc/default.conf /etc/apache2/sites-available/000-default.conf + sudo sed -i -e "s?_PWD?$PWD?g" -e "s/_PHP_V/${{ env.USE_PHP_V }}/g" /etc/apache2/sites-available/000-default.conf + sudo apt-get install libapache2-mod-fcgid + sudo a2enmod rewrite proxy fcgid proxy_fcgi + sudo systemctl start apache2.service + sudo sed -i -e 's/user = www-data/user = runner/' /etc/php/${{ env.USE_PHP_V }}/fpm/pool.d/www.conf + sudo sed -i -e 's/listen.owner = www-data/listen.owner = runner/' /etc/php/${{ env.USE_PHP_V }}/fpm/pool.d/www.conf + sudo systemctl restart php${{ env.USE_PHP_V }}-fpm.service + + - name: Install Backdrop + run: | + cp modules/${{ env.REPO_NAME }}/.github/misc/settings.local.php . + core/scripts/install.sh --db-url=mysql://root:root@127.0.0.1/backdrop + + - name: Run functional tests + run: core/scripts/run-tests.sh --force --directory=modules/${{ env.REPO_NAME }} --verbose --color --concurrency=3 --cache --group Metatag 2>&1 diff --git a/metatag_app_links/tests/metatag_app_links.tags.test b/metatag_app_links/tests/metatag_app_links.tags.test index 87ab2e8..c91fcf8 100644 --- a/metatag_app_links/tests/metatag_app_links.tags.test +++ b/metatag_app_links/tests/metatag_app_links.tags.test @@ -4,6 +4,8 @@ * Tests that each of the Metatag App Links tags work correctly. */ +include_once __DIR__ . '/metatag.tags.test'; + class MetatagAppLinksTagsTest extends MetatagTagsTestBase { /** diff --git a/tests/metatag.bulk_revert.test b/tests/metatag.bulk_revert.test index d9e9e6a..d6968ee 100644 --- a/tests/metatag.bulk_revert.test +++ b/tests/metatag.bulk_revert.test @@ -4,6 +4,8 @@ * Tests for the Metatag module to ensure the bulk revert functionality works */ +include_once __DIR__ . '/metatag.helper.test'; + class MetatagBulkRevertTest extends MetatagTestHelper { /** * {@inheritdoc} diff --git a/tests/metatag.core_tag_removal.test b/tests/metatag.core_tag_removal.test index 95cbdab..2dbf622 100644 --- a/tests/metatag.core_tag_removal.test +++ b/tests/metatag.core_tag_removal.test @@ -4,6 +4,8 @@ * Tests for the Metatag module to ensure removal of core tags works correctly. */ +include_once __DIR__ . '/metatag.helper.test'; + class MetatagCoreTagRemovalTest extends MetatagTestHelper { /** diff --git a/tests/metatag.image.test b/tests/metatag.image.test index f9b9b94..ed24ca4 100644 --- a/tests/metatag.image.test +++ b/tests/metatag.image.test @@ -4,6 +4,8 @@ * Tests for the Metatag module to ensure image handling doesn't break. */ +include_once __DIR__ . '/metatag.helper.test'; + class MetatagCoreImageTest extends MetatagTestHelper { /** * {@inheritdoc} diff --git a/tests/metatag.locale.test b/tests/metatag.locale.test index 92f16fd..3668216 100644 --- a/tests/metatag.locale.test +++ b/tests/metatag.locale.test @@ -4,6 +4,8 @@ * Tests for the Metatag module to ensure Locale integration doesn't break. */ +include_once __DIR__ . '/metatag.helper.test'; + class MetatagCoreLocaleTest extends MetatagTestHelper { /** diff --git a/tests/metatag.node.test b/tests/metatag.node.test index 11e2733..e8c6a46 100644 --- a/tests/metatag.node.test +++ b/tests/metatag.node.test @@ -4,6 +4,8 @@ * Tests for the Metatag module and node entities. */ +include_once __DIR__ . '/metatag.helper.test'; + class MetatagCoreNodeTest extends MetatagTestHelper { /** diff --git a/tests/metatag.node.with_i18n.test b/tests/metatag.node.with_i18n.test index 6125140..9f6db2f 100644 --- a/tests/metatag.node.with_i18n.test +++ b/tests/metatag.node.with_i18n.test @@ -4,6 +4,8 @@ * Tests for the Metatag module to ensure i18n integration doesn't break. */ +include_once __DIR__ . '/metatag.helper.test'; + class MetatagCoreNodeWithI18nTest extends MetatagTestHelper { /** * {@inheritdoc} diff --git a/tests/metatag.output_caching.test b/tests/metatag.output_caching.test index b2a5900..bc6f7ba 100644 --- a/tests/metatag.output_caching.test +++ b/tests/metatag.output_caching.test @@ -3,6 +3,8 @@ * @file */ +include_once __DIR__ . '/metatag.helper.test'; + /** * Tests for the Metatag module's output caching */ diff --git a/tests/metatag.string_handling.test b/tests/metatag.string_handling.test index f0ba86e..9b7e84e 100644 --- a/tests/metatag.string_handling.test +++ b/tests/metatag.string_handling.test @@ -4,6 +4,8 @@ * Contains the tests for Metatag's string handling. */ +include_once __DIR__ . '/metatag.helper.test'; + /** * Tests the Metatag string handling. */ diff --git a/tests/metatag.string_handling_with_i18n.test b/tests/metatag.string_handling_with_i18n.test index 0d2b844..7d71904 100644 --- a/tests/metatag.string_handling_with_i18n.test +++ b/tests/metatag.string_handling_with_i18n.test @@ -4,6 +4,8 @@ * Contains the tests for Metatag's string handling. */ +include_once __DIR__ . '/metatag.string_handling.test'; + /** * Tests the Metatag string handling. */ diff --git a/tests/metatag.tags.test b/tests/metatag.tags.test index 2206e22..fe8acf3 100644 --- a/tests/metatag.tags.test +++ b/tests/metatag.tags.test @@ -4,6 +4,8 @@ * Tests that each of the Metatag base tags work correctly. */ +include_once __DIR__ . '/metatag.helper.test'; + class MetatagTagsTestBase extends MetatagTestHelper { /** @@ -103,9 +105,9 @@ class MetatagTagsTestBase extends MetatagTestHelper { } /** - * + * Tests the built-in tags provided directly by metatag.module. */ -class MetatagTagsTest extends MetatagTagsTestBase { +class MetatagBuiltInTagsTest extends MetatagTagsTestBase { /** * {@inheritdoc} diff --git a/tests/metatag.term.test b/tests/metatag.term.test index 26f8f04..356ae4d 100644 --- a/tests/metatag.term.test +++ b/tests/metatag.term.test @@ -4,6 +4,8 @@ * Tests for the Metatag module and taxonomy term entities. */ +include_once __DIR__ . '/metatag.helper.test'; + class MetatagCoreTermTest extends MetatagTestHelper { /** diff --git a/tests/metatag.term.with_i18n.test b/tests/metatag.term.with_i18n.test index cab639c..3f77413 100644 --- a/tests/metatag.term.with_i18n.test +++ b/tests/metatag.term.with_i18n.test @@ -4,6 +4,8 @@ * Tests for the Metatag module to ensure i18n integration doesn't break. */ +include_once __DIR__ . '/metatag.helper.test'; + class MetatagCoreTermWithI18nTest extends MetatagTestHelper { /** * {@inheritdoc} diff --git a/tests/metatag.tests.info b/tests/metatag.tests.info index b33ca07..e36b7d6 100644 --- a/tests/metatag.tests.info +++ b/tests/metatag.tests.info @@ -4,8 +4,8 @@ description = Unit tests for meta tags (sort-of) group = Metatag file = metatag.unit.test -[MetatagTagsTestBase] -name = Metatag base tag tests +[MetatagBuiltInTagsTest] +name = Metatag built-in tags tests description = Tests that each of the Metatag base tags work correctly. group = Metatag file = metatag.tags.test diff --git a/tests/metatag.unit.test b/tests/metatag.unit.test index cb2d73e..af2310a 100644 --- a/tests/metatag.unit.test +++ b/tests/metatag.unit.test @@ -4,6 +4,8 @@ * Unit tests for the Metatag module. */ +include_once __DIR__ . '/metatag.helper.test'; + /** * @todo These aren't really unit tests, we might need to fix that. */ diff --git a/tests/metatag.user.test b/tests/metatag.user.test index 0bde848..d971951 100644 --- a/tests/metatag.user.test +++ b/tests/metatag.user.test @@ -4,6 +4,8 @@ * Tests for the Metatag module and user entities. */ +include_once __DIR__ . '/metatag.helper.test'; + class MetatagCoreUserTest extends MetatagTestHelper { /** diff --git a/tests/metatag.with_i18n_config.test b/tests/metatag.with_i18n_config.test index 4187c8e..9303ac4 100644 --- a/tests/metatag.with_i18n_config.test +++ b/tests/metatag.with_i18n_config.test @@ -4,6 +4,8 @@ * Tests for the Metatag module to ensure i18n integration doesn't break. */ +include_once __DIR__ . '/metatag.helper.test'; + class MetatagCoreWithI18nConfigTest extends MetatagTestHelper { /** * {@inheritdoc} diff --git a/tests/metatag.with_i18n_disabled.test b/tests/metatag.with_i18n_disabled.test index 48e64a8..b500321 100644 --- a/tests/metatag.with_i18n_disabled.test +++ b/tests/metatag.with_i18n_disabled.test @@ -4,6 +4,8 @@ * Tests for the Metatag module to ensure i18n integration doesn't break. */ +include_once __DIR__ . '/metatag.helper.test'; + class MetatagCoreWithI18nDisabledTest extends MetatagTestHelper { /** * {@inheritdoc} diff --git a/tests/metatag.with_i18n_output.test b/tests/metatag.with_i18n_output.test index 316caed..c5e471e 100644 --- a/tests/metatag.with_i18n_output.test +++ b/tests/metatag.with_i18n_output.test @@ -4,6 +4,8 @@ * Tests for the Metatag module to ensure i18n integration doesn't break. */ +include_once __DIR__ . '/metatag.helper.test'; + class MetatagCoreWithI18nOutputTest extends MetatagTestHelper { /** * {@inheritdoc} diff --git a/tests/metatag.with_me.test b/tests/metatag.with_me.test index fd67849..c75593e 100644 --- a/tests/metatag.with_me.test +++ b/tests/metatag.with_me.test @@ -4,6 +4,8 @@ * Tests for the Metatag module for Me module integration. */ +include_once __DIR__ . '/metatag.helper.test'; + class MetatagCoreWithMeTest extends MetatagTestHelper { /** diff --git a/tests/metatag.with_media.test b/tests/metatag.with_media.test index 9356eb3..de69374 100644 --- a/tests/metatag.with_media.test +++ b/tests/metatag.with_media.test @@ -4,6 +4,8 @@ * Tests for the Metatag module for Media integration. */ +include_once __DIR__ . '/metatag.helper.test'; + class MetatagCoreWithMediaTest extends MetatagTestHelper { /** diff --git a/tests/metatag.with_panels.test b/tests/metatag.with_panels.test deleted file mode 100644 index 522493e..0000000 --- a/tests/metatag.with_panels.test +++ /dev/null @@ -1,176 +0,0 @@ - 'Metatag core tests with Panels', - 'description' => 'Test Metatag integration with the Panels module.', - 'group' => 'Metatag', - ); - } - - /** - * {@inheritdoc} - */ - function setUp(array $modules = array()) { - // We'll be using Panels but most of the work is actually in Page Manager. - $modules[] = 'page_manager'; - $modules[] = 'panels'; - - parent::setUp($modules); - } - - /** - * Test out a node_view Panels display with Metatag. - */ - public function testPanelsNodeView() { - $content_type = 'metatag_test'; - $content_type_path = str_replace('_', '-', $content_type); - $label = 'Test'; - - // Create a content type. - $this->createContentType($content_type, $label); - - // Create an admin user and log them in. - $perms = array( - // Needed for the content type. - 'create ' . $content_type . ' content', - 'delete any ' . $content_type . ' content', - 'edit any ' . $content_type . ' content', - - // Needed for Panels et al. - 'use page manager', - 'administer page manager', - ); - $this->adminUser = $this->createAdminUser($perms); - $this->drupalLogin($this->adminUser); - - // Create a test node. - - // Load the node form. - $this->drupalGet('node/add/' . $content_type_path); - $this->assertResponse(200); - - // Verify the page loaded correctly. - // @todo Update this to extract the page title. - $this->assertText(strip_tags(t('Create @name', array('@name' => $label)))); - - // Verify that it's possible to submit values to the form. - $this->drupalPost(NULL, array( - 'metatags[und][abstract][value]' => '[node:title] ponies', - 'title' => 'Who likes magic', - ), t('Save')); - $this->assertResponse(200); - - // Verify that the node saved correctly. - // $xpath = $this->xpath("//h1"); - $t_args = array('@type' => 'Test', '%title' => 'Who likes magic'); - // This doesn't work for some reason, it seems the HTML is stripped off - // during output so the %title's standard Backdrop wrappers don't match. - // $this->assertText(t('@type %title has been created.', $t_args)); - // .. so this has to be done instead. - $this->assertText(strip_tags(t('@type %title has been created.', $t_args))); - - // Save the node URL for later. - $node_url = $this->getUrl(); - - // Confirm the tags load correctly. - $this->confirmNodeTags(); - - // Enable the Page Manager display for nodes. - variable_set('page_manager_node_view_disabled', FALSE); - - // Confirm that the main Panels page loads correctly. - $this->drupalGet('admin/structure/pages'); - $this->assertResponse(200); - - // Confirm that the Panels node_view page loads. - $this->drupalGet('admin/structure/pages/edit/node_view'); - $this->assertResponse(200); - - // Confirm that a new variant can be added. - $this->drupalGet('admin/structure/pages/nojs/operation/node_view/actions/add'); - $this->assertResponse(200); - - // Create a variant. This is done as a series of form submissions. - $args = array( - 'title' => 'Test', - 'name' => 'test', - 'handler' => 'panel_context', - ); - $this->drupalPost('admin/structure/pages/nojs/operation/node_view/actions/add', $args, t('Create variant')); - $this->assertResponse(200); - $args = array( - 'layout' => 'flexible', - ); - $this->drupalPost(NULL, $args, t('Continue')); - $this->assertResponse(200); - $args = array(); - $this->drupalPost(NULL, $args, t('Continue')); - $this->assertResponse(200); - $args = array(); - $this->drupalPost(NULL, $args, t('Create variant')); - $this->assertResponse(200); - $this->assertText(t('The page has been updated. Changes will not be permanent until you save.')); - $args = array(); - $this->drupalPost(NULL, $args, t('Save')); - $this->assertResponse(200); - - // Confirm the process completed successfully. - $this->assertEqual($this->getUrl(), url('admin/structure/pages/edit/node_view', array('absolute' => TRUE))); - $this->assertText(t('Panel') . ': Test'); - - // Clear all caches, so we can start off properly. - backdrop_flush_all_caches(); - - // Load the node page again. - $this->confirmNodeTags($node_url); - } - - /** - * Confirm that the meta tags for the requested node load properly. - * - * @param string $path - * Optional path to load, if not present the current path will be used. - */ - function confirmNodeTags($path = NULL) { - if (!empty($path)) { - $this->drupalGet($path); - $this->assertResponse(200); - } - - // Verify the title is using the custom default for this content type. - $xpath = $this->xpath("//meta[@name='abstract']"); - $this->assertEqual(count($xpath), 1, 'Exactly one abstract meta tag found.'); - $this->assertEqual($xpath[0]['content'], 'Who likes magic ponies'); - } - - /** - * Test out a term_view Panels display with Metatag. - * - * @todo Write this. - */ - // public function testPanelsTermView() { - // // Enable the Page Manager display for terms. - // variable_set('page_manager_term_view_disabled', FALSE); - // } - - /** - * Test out a user_view Panels display with Metatag. - * - * @todo Write this. - */ - // public function testPanelsUserView() { - // // Enable the Page Manager display for users. - // variable_set('page_manager_user_view_disabled', FALSE); - // } - -} diff --git a/tests/metatag.with_profile2.test b/tests/metatag.with_profile2.test index 83a7f41..281b091 100644 --- a/tests/metatag.with_profile2.test +++ b/tests/metatag.with_profile2.test @@ -4,6 +4,8 @@ * Tests for the Metatag module for Profile2 integration. */ +include_once __DIR__ . '/metatag.helper.test'; + // Inherit from the User test so that its tests can be confirmed to still work // when the Profile2 module is enabled. class MetatagCoreWithProfile2Test extends MetatagCoreUserTest { diff --git a/tests/metatag.with_search_api.test b/tests/metatag.with_search_api.test index d39bc14..fc61c6c 100644 --- a/tests/metatag.with_search_api.test +++ b/tests/metatag.with_search_api.test @@ -4,6 +4,8 @@ * Tests for the Search API integration. */ +include_once __DIR__ . '/metatag.helper.test'; + /** * Class for testing the Search API integration. */ diff --git a/tests/metatag.with_views.test b/tests/metatag.with_views.test index e6e4c74..71026b0 100644 --- a/tests/metatag.with_views.test +++ b/tests/metatag.with_views.test @@ -5,6 +5,8 @@ * Metatag:Views. */ +include_once __DIR__ . '/metatag.helper.test'; + class MetatagCoreWithViewsTest extends MetatagTestHelper { /** * {@inheritdoc} diff --git a/tests/metatag.xss.test b/tests/metatag.xss.test index 595812e..737da7f 100644 --- a/tests/metatag.xss.test +++ b/tests/metatag.xss.test @@ -5,6 +5,8 @@ * Tests Metatag module to ensure there are no XSS scripting vulnerabilities. */ +include_once __DIR__ . '/metatag.helper.test'; + /** * MetatagCoreXSSTest extends MetatagTestHelper. */