Skip to content

Commit

Permalink
Add fallback tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
demiankatz committed Dec 18, 2024
1 parent 3eead8d commit bcf3b0f
Showing 1 changed file with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,15 @@ class ChannelLoaderTest extends \PHPUnit\Framework\TestCase
public static function getRecordContextProvider(): array
{
return [
'no configuration' => [[], []],
'no configuration' => [[], [], ['record']],
'one provider' => [
[
'source.Solr' => [
'record' => ['bar'],
],
],
['bar'],
['record'],
],
'two providers, including config' => [
[
Expand All @@ -78,6 +79,26 @@ public static function getRecordContextProvider(): array
],
],
['bar', 'baz-extraConfig'],
['record'],
],
'override section' => [
[
'source.Solr' => [
'record' => ['bar'],
'recordTab' => ['override'],
],
],
['override'],
['recordTab', 'record'],
],
'proper section fallback' => [
[
'source.Solr' => [
'record' => ['bar'],
],
],
['bar'],
['recordTab', 'record'],
],
];
}
Expand All @@ -87,18 +108,19 @@ public static function getRecordContextProvider(): array
*
* @param array $config Configuration
* @param array $expectedChannelData The channel data we expect to retrieve
* @param array $sections Config sections to look at for provider settings
*
* @return void
*
* @dataProvider getRecordContextProvider
*/
public function testGetRecordContext(array $config, array $expectedChannelData): void
public function testGetRecordContext(array $config, array $expectedChannelData, array $sections): void
{
$mockRecord = $this->createMock(DefaultRecord::class);
$recordLoader = $this->getMockRecordLoader();
$recordLoader->expects($this->once())->method('load')->with('foo', 'Solr')->willReturn($mockRecord);
$loader = $this->getChannelLoader($config, $recordLoader);
$context = $loader->getRecordContext('foo');
$context = $loader->getRecordContext('foo', configSections: $sections);
$this->assertEquals(['driver', 'channels', 'token'], array_keys($context));
$this->assertEquals($mockRecord, $context['driver']);
$this->assertEquals($expectedChannelData, $context['channels']);
Expand Down

0 comments on commit bcf3b0f

Please sign in to comment.