diff --git a/composer.lock b/composer.lock index 84fadea8c..a1cc1913c 100644 --- a/composer.lock +++ b/composer.lock @@ -4046,16 +4046,16 @@ }, { "name": "drupal/helfi_api_base", - "version": "2.5.3", + "version": "2.5.4", "source": { "type": "git", "url": "https://github.com/City-of-Helsinki/drupal-module-helfi-api-base.git", - "reference": "f5fab16526d75c612e420a68ebe933efb5c72a0e" + "reference": "2a0a4fb2ea863232dc3eed32a3e8104fdffab178" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/City-of-Helsinki/drupal-module-helfi-api-base/zipball/f5fab16526d75c612e420a68ebe933efb5c72a0e", - "reference": "f5fab16526d75c612e420a68ebe933efb5c72a0e", + "url": "https://api.github.com/repos/City-of-Helsinki/drupal-module-helfi-api-base/zipball/2a0a4fb2ea863232dc3eed32a3e8104fdffab178", + "reference": "2a0a4fb2ea863232dc3eed32a3e8104fdffab178", "shasum": "" }, "require": { @@ -4081,10 +4081,10 @@ ], "description": "Helfi - API Base", "support": { - "source": "https://github.com/City-of-Helsinki/drupal-module-helfi-api-base/tree/2.5.3", + "source": "https://github.com/City-of-Helsinki/drupal-module-helfi-api-base/tree/2.5.4", "issues": "https://github.com/City-of-Helsinki/drupal-module-helfi-api-base/issues" }, - "time": "2023-09-13T05:29:57+00:00" + "time": "2023-09-14T09:11:02+00:00" }, { "name": "drupal/helfi_azure_fs", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 1a56d5be1..0ae082a9a 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -41,9 +41,13 @@ ./tests/dtt/src/ExistingSite + ./public/modules/custom/*/tests/src/ExistingSite + ./public/modules/contrib/*/tests/src/ExistingSite ./tests/dtt/src/ExistingSiteJavascript + ./public/modules/custom/*/tests/src/ExistingSiteJavascript + ./public/modules/contrib/*/tests/src/ExistingSiteJavascript diff --git a/tests/dtt/src/ExistingSite/ExistingSiteTestBase.php b/tests/dtt/src/ExistingSite/ExistingSiteTestBase.php deleted file mode 100644 index 235177288..000000000 --- a/tests/dtt/src/ExistingSite/ExistingSiteTestBase.php +++ /dev/null @@ -1,34 +0,0 @@ -setupDefaultConfiguration(); - } - - /** - * {@inheritdoc} - */ - public function tearDown() : void { - parent::tearDown(); - $this->tearDownDefaultConfiguration(); - } - -} diff --git a/tests/dtt/src/ExistingSite/NewsContentTypeTest.php b/tests/dtt/src/ExistingSite/NewsContentTypeTest.php index 17f5fe492..82bbee1b4 100644 --- a/tests/dtt/src/ExistingSite/NewsContentTypeTest.php +++ b/tests/dtt/src/ExistingSite/NewsContentTypeTest.php @@ -5,6 +5,7 @@ namespace Drupal\Tests\dtt\ExistingSite; use Drupal\Core\Session\AccountInterface; +use Drupal\Tests\helfi_api_base\Functional\ExistingSiteTestBase; /** * Tests news endpoint. @@ -54,7 +55,11 @@ public function assertNodeCreation() : void { * Asserts that news json list has the expected item. */ public function assertJsonApiList() : void { - $this->drupalGetWithLanguage('/jsonapi/node/news'); + // Sort items by changed date to make sure our newly added item is visible. + $this->drupalGetWithLanguage('/jsonapi/node/news', options: ['query' => [ + 'sort[changed][path]' => 'changed', + 'sort[changed][direction]' => 'DESC', + ]]); $this->assertSession()->statusCodeEquals(200); $json = json_decode($this->getSession()->getPage()->getContent(), TRUE); diff --git a/tests/dtt/src/ExistingSiteJavascript/ExistingSiteJavascriptTestBase.php b/tests/dtt/src/ExistingSiteJavascript/ExistingSiteJavascriptTestBase.php deleted file mode 100644 index 9bd0725b1..000000000 --- a/tests/dtt/src/ExistingSiteJavascript/ExistingSiteJavascriptTestBase.php +++ /dev/null @@ -1,34 +0,0 @@ -setupDefaultConfiguration(); - } - - /** - * {@inheritdoc} - */ - public function tearDown() { - parent::tearDown(); - $this->tearDownDefaultConfiguration(); - } - -} diff --git a/tests/dtt/src/Traits/DefaultConfigurationTrait.php b/tests/dtt/src/Traits/DefaultConfigurationTrait.php deleted file mode 100644 index a0f100a03..000000000 --- a/tests/dtt/src/Traits/DefaultConfigurationTrait.php +++ /dev/null @@ -1,92 +0,0 @@ -getLanguage($langcode); - } - - /** - * Wrapper for drupalGet() to always set language code. - * - * @param string|\Drupal\Core\Url $url - * The url. - * @param string $langcode - * The langcode. - * @param array $options - * The options. - * @param array $headers - * The headers. - */ - protected function drupalGetWithLanguage(string|Url $url, string $langcode = 'en', array $options = [], array $headers = []) : void { - $options['language'] = $this->getLanguage($langcode); - $this->drupalGet($url, $options, $headers); - } - - /** - * Set up the default configuration. - */ - protected function setupDefaultConfiguration() : void { - $this->defaultLanguage = $this->getDefaultLanguageConfiguration() - ->get('selected_langcode'); - $this->setDefaultLanguage('en'); - } - - /** - * Restores the default configuration. - */ - protected function tearDownDefaultConfiguration() : void { - $this->setDefaultLanguage($this->defaultLanguage); - } - - /** - * Gets the configuration. - * - * @return \Drupal\Core\Config\Config - * The default configuration. - */ - protected function getDefaultLanguageConfiguration() : Config { - return \Drupal::configFactory() - ->getEditable('language.negotiation'); - } - - /** - * Sets the default language. - * - * @param string $langcode - * The langcode to set as default. - */ - protected function setDefaultLanguage(string $langcode) : void { - $this->getDefaultLanguageConfiguration() - ->set('selected_langcode', $langcode) - ->save(); - } - -}