From 33fbbfc827c900bcb3ea8cb4fe155030353cea90 Mon Sep 17 00:00:00 2001 From: Bartek Wajda Date: Mon, 8 Feb 2021 15:42:24 +0100 Subject: [PATCH] EZEE-3465: Tests refactor --- .../RepositoryConfigurationProviderTest.php | 54 ++++++++++++------- 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/eZ/Bundle/EzPublishCoreBundle/Tests/ApiLoader/RepositoryConfigurationProviderTest.php b/eZ/Bundle/EzPublishCoreBundle/Tests/ApiLoader/RepositoryConfigurationProviderTest.php index 8ff004fb8e7..5934ca97825 100644 --- a/eZ/Bundle/EzPublishCoreBundle/Tests/ApiLoader/RepositoryConfigurationProviderTest.php +++ b/eZ/Bundle/EzPublishCoreBundle/Tests/ApiLoader/RepositoryConfigurationProviderTest.php @@ -69,19 +69,13 @@ public function testGetRepositoryConfigNotSpecifiedRepository() } /** + * @dataProvider providerForRepositories + * * @expectedException \eZ\Bundle\EzPublishCoreBundle\ApiLoader\Exception\InvalidRepositoryException */ - public function testGetRepositoryConfigUndefinedRepository() + public function testGetRepositoryConfigUndefinedRepository(array $repositories): void { $configResolver = $this->getConfigResolverMock(); - $repositories = [ - 'main' => [ - 'engine' => 'foo', - ], - 'another' => [ - 'engine' => 'bar', - ], - ]; $configResolver ->expects($this->once()) @@ -93,26 +87,48 @@ public function testGetRepositoryConfigUndefinedRepository() $provider->getRepositoryConfig(); } - public function testGetDefaultAndCurrentRepositoryAlias(): void + /** + * @dataProvider providerForRepositories + */ + public function testGetDefaultRepositoryAlias(array $repositories): void { $configResolver = $this->getConfigResolverMock(); - $repositories = [ - 'first' => [ - 'engine' => 'foo', - ], - 'second' => [ - 'engine' => 'bar', - ], - ]; - $provider = new RepositoryConfigurationProvider($configResolver, $repositories); $provider->getRepositoryConfig(); $this->assertSame('first', $provider->getDefaultRepositoryAlias()); + } + + /** + * @dataProvider providerForRepositories + */ + public function testGetCurrentRepositoryAlias(array $repositories): void + { + $configResolver = $this->getConfigResolverMock(); + + $provider = new RepositoryConfigurationProvider($configResolver, $repositories); + $provider->getRepositoryConfig(); + $this->assertSame('first', $provider->getCurrentRepositoryAlias()); } + public function providerForRepositories(): array + { + return [ + [ + [ + 'first' => [ + 'engine' => 'foo', + ], + 'second' => [ + 'engine' => 'bar', + ], + ], + ], + ]; + } + /** * @return \PHPUnit\Framework\MockObject\MockObject|\eZ\Publish\Core\MVC\ConfigResolverInterface */