Skip to content

Commit

Permalink
Refactoring, DEV-219
Browse files Browse the repository at this point in the history
  • Loading branch information
sprankhub committed Nov 30, 2023
1 parent af83827 commit 0ef15fa
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 20 deletions.
14 changes: 1 addition & 13 deletions Test/Integration/AddScriptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,55 +23,43 @@ protected function setUp(): void
/**
* @magentoConfigFixture current_store web/cookiebot/enabled 1
* @magentoConfigFixture current_store cookiebot/id 123-456-789
* @magentoConfigFixture current_store web/cookiebot/use_eu_cdn 1
*/
public function testScriptAddedOnHomepage(): void
{
$this->dispatch('/');
self::assertStringContainsString($this->script, $this->getResponse()->getBody());
self::assertEquals('<script id="Cookiebot" data-cfasync="false" src="https://consent.cookiebot.eu/uc.js" data-cbid="" type="text/javascript" async></script>',
$this->script);
}

/**
* @magentoApiDataFixture Magento/Catalog/_files/product_simple.php
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
* @magentoConfigFixture current_store web/cookiebot/enabled 1
* @magentoConfigFixture current_store web/cookiebot/id 123-456-789
* @magentoConfigFixture current_store web/cookiebot/use_eu_cdn 0
*/
public function testScriptAddedOnProductPage(): void
{
$this->dispatch('/catalog/product/view/id/1');
self::assertStringContainsString($this->script, $this->getResponse()->getBody());
self::assertEquals('<script id="Cookiebot" data-cfasync="false" src="https://consent.cookiebot.com/uc.js" data-cbid="123-456-789" type="text/javascript" async></script>',
$this->script);
}

/**
* @magentoDataFixture Magento/Catalog/_files/category.php
* @magentoConfigFixture current_store web/cookiebot/enabled 1
* @magentoConfigFixture current_store web/cookiebot/id 123-456-789
* @magentoConfigFixture current_store web/cookiebot/use_eu_cdn 1
*/
public function testScriptAddedOnCategoryPage(): void
{
$this->dispatch('/catalog/category/view/id/333');
self::assertStringContainsString($this->script, $this->getResponse()->getBody());
self::assertEquals('<script id="Cookiebot" data-cfasync="false" src="https://consent.cookiebot.eu/uc.js" data-cbid="123-456-789" type="text/javascript" async></script>',
$this->script);
}

/**
* @magentoDataFixture Magento/Cms/_files/pages.php
* @magentoConfigFixture current_store web/cookiebot/enabled 1
* @magentoConfigFixture current_store web/cookiebot/id 123-456-789
* @magentoConfigFixture current_store web/cookiebot/use_eu_cdn 1
*/
public function testScriptAddedOnCmsPage(): void
{
$this->dispatch('/page100');
self::assertStringContainsString($this->script, $this->getResponse()->getBody());
self::assertEquals('<script id="Cookiebot" data-cfasync="false" src="https://consent.cookiebot.eu/uc.js" data-cbid="123-456-789" type="text/javascript" async></script>',
$this->script);
}
}
1 change: 0 additions & 1 deletion Test/Integration/Model/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,4 @@ public function testIfEuCdnEnabledConfigFunctionReturnsTrue(): void
{
self::assertTrue($this->config->useEuCdn());
}

}
10 changes: 4 additions & 6 deletions Test/Integration/Model/ScriptGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,18 @@ protected function setUp(): void
/**
* @magentoConfigFixture current_store web/cookiebot/use_eu_cdn 0
*/
public function testWhenUseEuCdnIsDisabled(): void
public function testDomainWhenUseEuCdnIsDisabled(): void
{
$generatedScript = ObjectManager::getInstance()->create(ScriptGenerator::class)->generate();
self::assertStringContainsString('https://consent.cookiebot.com/uc.js',
$generatedScript);
self::assertStringContainsString('https://consent.cookiebot.com/uc.js', $generatedScript);
}

/**
* @magentoConfigFixture current_store web/cookiebot/use_eu_cdn 1
*/
public function testWhenUseEuCdnIsEnabled(): void
public function testDomainWhenUseEuCdnIsEnabled(): void
{
$generatedScript = ObjectManager::getInstance()->create(ScriptGenerator::class)->generate();
self::assertStringContainsString('https://consent.cookiebot.eu/uc.js',
$generatedScript);
self::assertStringContainsString('https://consent.cookiebot.eu/uc.js', $generatedScript);
}
}

0 comments on commit 0ef15fa

Please sign in to comment.