Skip to content

Commit

Permalink
FRW-1817 Adjusted Dynamic Multistore Test Coverage (#10800)
Browse files Browse the repository at this point in the history
FRW-1817 Adjusted Dynamic Multistore Test Coverage
  • Loading branch information
vol4onok authored Mar 20, 2024
1 parent e2813c1 commit f6f4d5e
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 2 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"spryker/http": "*",
"spryker/router": "*",
"spryker/silex": "*",
"spryker/store": "*",
"spryker/testify": "*"
},
"suggest": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

use Codeception\Test\Unit;
use Spryker\Shared\Application\Log\Processor\EnvironmentProcessor;
use SprykerTest\Shared\Application\ApplicationSharedTester;

/**
* Auto-generated group annotations
Expand All @@ -23,15 +24,60 @@
*/
class EnvironmentProcessorTest extends Unit
{
/**
* @var \SprykerTest\Shared\Application\ApplicationSharedTester
*/
protected ApplicationSharedTester $tester;

/**
* @return void
*/
public function testInvokeShouldAddEnvironmentInformationToRecordsExtra(): void
{
$processor = new EnvironmentProcessor();
$record = ['extra'];
$result = $processor($record);
$result = $processor([$this->tester::EXTRA]);

$this->assertArrayHasKey(EnvironmentProcessor::EXTRA, $result['extra']);
}

/**
* @return void
*/
public function testInvokeAddsStoreAndLocaleDataWhenDynamicStoreEnabled(): void
{
if (!$this->tester->isDynamicStoreEnabled()) {
$this->markTestSkipped('Test is valid for Dynamic Store on-mode only.');
}

// Arrange
$processor = new EnvironmentProcessor();

// Act
$result = $processor([$this->tester::EXTRA]);

// Assert
$this->assertArrayNotHasKey(EnvironmentProcessor::STORE, $result[$this->tester::EXTRA][EnvironmentProcessor::EXTRA]);
$this->assertArrayNotHasKey(EnvironmentProcessor::LOCALE, $result[$this->tester::EXTRA][EnvironmentProcessor::EXTRA]);
}

/**
* @return void
*/
public function testInvokeAddsStoreAndLocaleDataWhenDynamicStoreDisabled(): void
{
if ($this->tester->isDynamicStoreEnabled()) {
$this->markTestSkipped('Test is valid for disabled Dynamic Store on-mode only.');
}
// Arrange
$processor = new EnvironmentProcessor();

// Act
$result = $processor([$this->tester::EXTRA]);

// Assert
$this->assertArrayHasKey(EnvironmentProcessor::STORE, $result[$this->tester::EXTRA][EnvironmentProcessor::EXTRA]);
$this->assertArrayHasKey(EnvironmentProcessor::LOCALE, $result[$this->tester::EXTRA][EnvironmentProcessor::EXTRA]);
$this->assertIsString($result[$this->tester::EXTRA][EnvironmentProcessor::EXTRA][EnvironmentProcessor::STORE]);
$this->assertIsString($result[$this->tester::EXTRA][EnvironmentProcessor::EXTRA][EnvironmentProcessor::LOCALE]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,9 @@
class ApplicationSharedTester extends Actor
{
use _generated\ApplicationSharedTesterActions;

/**
* @var string
*/
public const EXTRA = 'extra';
}
1 change: 1 addition & 0 deletions tests/SprykerTest/Shared/Application/codeception.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ suites:
enabled:
- Asserts
- \SprykerTest\Shared\Testify\Helper\Environment
- \SprykerTest\Shared\Store\Helper\StoreDataHelper

0 comments on commit f6f4d5e

Please sign in to comment.