Skip to content

Commit

Permalink
refactor #13597 Core Configuration style and tests improvements (Zale…
Browse files Browse the repository at this point in the history
…s0123)

This PR was merged into the 1.11 branch.

Discussion
----------

| Q               | A
| --------------- | -----
| Branch?         | 1.11
| Bug fix?        | no
| New feature?    | no
| BC breaks?      | no
| Deprecations?   | no
| Related tickets |
| License         | MIT

Applying comments from #13594, I've also enabled some tests that were not run at all 💃 

Commits
-------

19ba403 Arrow function in configuration
82e4b96 Enable tests that were not tagged as tests
  • Loading branch information
lchrusciel authored Feb 4, 2022
2 parents a310c2d + 82e4b96 commit 37dab55
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ public function getConfigTreeBuilder(): TreeBuilder
->integerNode('batch_size')
->defaultValue(100)
->validate()
->ifTrue(function (int $batchSize): bool {
return $batchSize <= 0;
})
->ifTrue(fn(int $batchSize): bool => $batchSize <= 0)
->thenInvalid('Expected value bigger than 0, but got %s.')
->end()
->end()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

final class CircularDependencyBreakingErrorListenerPassTest extends AbstractCompilerPassTestCase
{
/** @test */
public function it_register_circular_dependency_breaking_error_listener_when_exception_listener_is_registered(): void
{
$this->container->setDefinition('exception_listener', new Definition('ExceptionListener'));
Expand All @@ -30,6 +31,7 @@ public function it_register_circular_dependency_breaking_error_listener_when_exc
$this->assertContainerBuilderHasService(CircularDependencyBreakingErrorListener::class);
}

/** @test */
public function it_does_nothing_when_exception_listener_is_not_registered(): void
{
$this->compile();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

final class CircularDependencyBreakingExceptionListenerPassTest extends AbstractCompilerPassTestCase
{
/** @test */
public function it_register_circular_dependency_breaking_error_listener_when_exception_listener_is_registered(): void
{
$this->container->setDefinition('twig.exception_listener', new Definition('ExceptionListener'));
Expand All @@ -30,6 +31,7 @@ public function it_register_circular_dependency_breaking_error_listener_when_exc
$this->assertContainerBuilderHasService(CircularDependencyBreakingExceptionListener::class);
}

/** @test */
public function it_does_nothing_when_exception_listener_is_not_registered(): void
{
$this->compile();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ final class ConfigurationTest extends TestCase
{
use ConfigurationTestCaseTrait;

/**
* @test
*/
/** @test */
public function it_configures_batch_size_to_100_by_default(): void
{
$this->assertProcessedConfigurationEquals(
Expand All @@ -34,9 +32,7 @@ public function it_configures_batch_size_to_100_by_default(): void
);
}

/**
* @test
*/
/** @test */
public function it_allows_for_assigning_integer_as_batch_size(): void
{
$this->assertProcessedConfigurationEquals(
Expand All @@ -46,19 +42,15 @@ public function it_allows_for_assigning_integer_as_batch_size(): void
);
}

/**
* @test
*/
/** @test */
public function it_throws_an_exception_if_value_other_then_integer_is_declared_as_batch_size(): void
{
$this->assertConfigurationIsInvalid([['catalog_promotions' => ['batch_size' => 'rep']]]);

$this->assertConfigurationIsInvalid([['catalog_promotions' => ['batch_size' => 10.1]]]);
}

/**
* @test
*/
/** @test */
public function it_throws_an_exception_if_value_of_batch_size_is_lower_then_1(): void
{
$this->assertConfigurationIsInvalid(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,57 +20,43 @@

final class SyliusCoreExtensionTest extends AbstractExtensionTestCase
{
/**
* @test
*/
/** @test */
public function it_autoconfigures_prepending_doctrine_migrations_with_proper_migrations_path_for_test_env(): void
{
$this->testPrependingDoctrineMigrations('test');
}

/**
* @test
*/
/** @test */
public function it_autoconfigures_prepending_doctrine_migrations_with_proper_migrations_path_for_test_cached_env(): void
{
$this->testPrependingDoctrineMigrations('test_cached');
}

/**
* @test
*/
/** @test */
public function it_autoconfigures_prepending_doctrine_migrations_with_proper_migrations_path_for_dev_env(): void
{
$this->testPrependingDoctrineMigrations('dev');
}

/**
* @test
*/
/** @test */
public function it_does_not_autoconfigure_prepending_doctrine_migrations_if_it_is_disabled_for_test_env(): void
{
$this->testNotPrependingDoctrineMigrations('test');
}

/**
* @test
*/
/** @test */
public function it_does_not_autoconfigure_prepending_doctrine_migrations_if_it_is_disabled_for_test_cached_env(): void
{
$this->testNotPrependingDoctrineMigrations('test_cached');
}

/**
* @test
*/
/** @test */
public function it_does_not_autoconfigure_prepending_doctrine_migrations_if_it_is_disabled_for_dev_env(): void
{
$this->testNotPrependingDoctrineMigrations('dev');
}

/**
* @test
*/
/** @test */
public function it_loads_batch_size_parameter_value_properly(): void
{
$this->container->setParameter('kernel.environment', 'dev');
Expand All @@ -80,9 +66,7 @@ public function it_loads_batch_size_parameter_value_properly(): void
$this->assertContainerBuilderHasParameter('sylius_core.catalog_promotions.batch_size', 200);
}

/**
* @test
*/
/** @test */
public function it_loads_default_batch_size_properly(): void
{
$this->container->setParameter('kernel.environment', 'dev');
Expand Down

0 comments on commit 37dab55

Please sign in to comment.