Skip to content

Commit

Permalink
EZEE-3465: Tests refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
barw4 committed Feb 9, 2021
1 parent 26f1583 commit 33fbbfc
Showing 1 changed file with 35 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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
*/
Expand Down

0 comments on commit 33fbbfc

Please sign in to comment.