138 lines
7.4 KiB
YAML
138 lines
7.4 KiB
YAML
|
name: BundleEntryReaderTest
|
||
|
class_comment: '# * @author Bernhard Schussek <bschussek@gmail.com>'
|
||
|
dependencies:
|
||
|
- name: MockObject
|
||
|
type: class
|
||
|
source: PHPUnit\Framework\MockObject\MockObject
|
||
|
- name: TestCase
|
||
|
type: class
|
||
|
source: PHPUnit\Framework\TestCase
|
||
|
- name: BundleEntryReader
|
||
|
type: class
|
||
|
source: Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReader
|
||
|
- name: BundleEntryReaderInterface
|
||
|
type: class
|
||
|
source: Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReaderInterface
|
||
|
- name: MissingResourceException
|
||
|
type: class
|
||
|
source: Symfony\Component\Intl\Exception\MissingResourceException
|
||
|
- name: ResourceBundleNotFoundException
|
||
|
type: class
|
||
|
source: Symfony\Component\Intl\Exception\ResourceBundleNotFoundException
|
||
|
properties: []
|
||
|
methods:
|
||
|
- name: testMergeDataWithFallbackData
|
||
|
visibility: public
|
||
|
parameters:
|
||
|
- name: childData
|
||
|
- name: parentData
|
||
|
- name: result
|
||
|
comment: "# * @author Bernhard Schussek <bschussek@gmail.com>\n# */\n# class BundleEntryReaderTest\
|
||
|
\ extends TestCase\n# {\n# private const RES_DIR = '/res/dir';\n# \n# private\
|
||
|
\ BundleEntryReader $reader;\n# private MockObject&BundleEntryReaderInterface\
|
||
|
\ $readerImpl;\n# \n# private const DATA = [\n# 'Entries' => [\n# 'Foo' => 'Bar',\n\
|
||
|
# 'Bar' => 'Baz',\n# ],\n# 'Foo' => 'Bar',\n# 'Version' => '2.0',\n# ];\n# \n\
|
||
|
# private const FALLBACK_DATA = [\n# 'Entries' => [\n# 'Foo' => 'Foo',\n# 'Bam'\
|
||
|
\ => 'Lah',\n# ],\n# 'Baz' => 'Foo',\n# 'Version' => '1.0',\n# ];\n# \n# private\
|
||
|
\ const MERGED_DATA = [\n# // no recursive merging -> too complicated\n# 'Entries'\
|
||
|
\ => [\n# 'Foo' => 'Bar',\n# 'Bar' => 'Baz',\n# ],\n# 'Baz' => 'Foo',\n# 'Version'\
|
||
|
\ => '2.0',\n# 'Foo' => 'Bar',\n# ];\n# \n# protected function setUp(): void\n\
|
||
|
# {\n# $this->readerImpl = $this->createMock(BundleEntryReaderInterface::class);\n\
|
||
|
# $this->reader = new BundleEntryReader($this->readerImpl);\n# }\n# \n# public\
|
||
|
\ function testForwardCallToRead()\n# {\n# $this->readerImpl->expects($this->once())\n\
|
||
|
# ->method('read')\n# ->with(self::RES_DIR, 'root')\n# ->willReturn(self::DATA);\n\
|
||
|
# \n# $this->assertSame(self::DATA, $this->reader->read(self::RES_DIR, 'root'));\n\
|
||
|
# }\n# \n# public function testReadEntireDataFileIfNoIndicesGiven()\n# {\n# $this->readerImpl->expects($this->exactly(2))\n\
|
||
|
# ->method('read')\n# ->willReturnCallback(function (...$args) {\n# static $series\
|
||
|
\ = [\n# [[self::RES_DIR, 'en'], self::DATA],\n# [[self::RES_DIR, 'root'], self::FALLBACK_DATA],\n\
|
||
|
# ];\n# \n# [$expectedArgs, $return] = array_shift($series);\n# $this->assertSame($expectedArgs,\
|
||
|
\ $args);\n# \n# return $return;\n# })\n# ;\n# \n# $this->assertSame(self::MERGED_DATA,\
|
||
|
\ $this->reader->readEntry(self::RES_DIR, 'en', []));\n# }\n# \n# public function\
|
||
|
\ testReadExistingEntry()\n# {\n# $this->readerImpl->expects($this->once())\n\
|
||
|
# ->method('read')\n# ->with(self::RES_DIR, 'root')\n# ->willReturn(self::DATA);\n\
|
||
|
# \n# $this->assertSame('Bar', $this->reader->readEntry(self::RES_DIR, 'root',\
|
||
|
\ ['Entries', 'Foo']));\n# }\n# \n# public function testReadNonExistingEntry()\n\
|
||
|
# {\n# $this->expectException(MissingResourceException::class);\n# $this->readerImpl->expects($this->once())\n\
|
||
|
# ->method('read')\n# ->with(self::RES_DIR, 'root')\n# ->willReturn(self::DATA);\n\
|
||
|
# \n# $this->reader->readEntry(self::RES_DIR, 'root', ['Entries', 'NonExisting']);\n\
|
||
|
# }\n# \n# public function testFallbackIfEntryDoesNotExist()\n# {\n# $this->readerImpl->expects($this->exactly(2))\n\
|
||
|
# ->method('read')\n# ->willReturnCallback(function (...$args) {\n# static $series\
|
||
|
\ = [\n# [[self::RES_DIR, 'en_GB'], self::DATA],\n# [[self::RES_DIR, 'en'], self::FALLBACK_DATA],\n\
|
||
|
# ];\n# \n# [$expectedArgs, $return] = array_shift($series);\n# $this->assertSame($expectedArgs,\
|
||
|
\ $args);\n# \n# return $return;\n# })\n# ;\n# \n# $this->assertSame('Lah', $this->reader->readEntry(self::RES_DIR,\
|
||
|
\ 'en_GB', ['Entries', 'Bam']));\n# }\n# \n# public function testDontFallbackIfEntryDoesNotExistAndFallbackDisabled()\n\
|
||
|
# {\n# $this->expectException(MissingResourceException::class);\n# $this->readerImpl->expects($this->once())\n\
|
||
|
# ->method('read')\n# ->with(self::RES_DIR, 'en_GB')\n# ->willReturn(self::DATA);\n\
|
||
|
# \n# $this->reader->readEntry(self::RES_DIR, 'en_GB', ['Entries', 'Bam'], false);\n\
|
||
|
# }\n# \n# public function testFallbackIfLocaleDoesNotExist()\n# {\n# $exception\
|
||
|
\ = new ResourceBundleNotFoundException();\n# $series = [\n# [[self::RES_DIR,\
|
||
|
\ 'en_GB'], $exception],\n# [[self::RES_DIR, 'en'], self::FALLBACK_DATA],\n# ];\n\
|
||
|
# \n# $this->readerImpl->expects($this->exactly(2))\n# ->method('read')\n# ->willReturnCallback(function\
|
||
|
\ (...$args) use (&$series) {\n# [$expectedArgs, $return] = array_shift($series);\n\
|
||
|
# $this->assertSame($expectedArgs, $args);\n# \n# if ($return instanceof \\Exception)\
|
||
|
\ {\n# throw $return;\n# }\n# \n# return $return;\n# })\n# ;\n# \n# $this->assertSame('Lah',\
|
||
|
\ $this->reader->readEntry(self::RES_DIR, 'en_GB', ['Entries', 'Bam']));\n# }\n\
|
||
|
# \n# public function testDontFallbackIfLocaleDoesNotExistAndFallbackDisabled()\n\
|
||
|
# {\n# $this->expectException(MissingResourceException::class);\n# $this->readerImpl->expects($this->once())\n\
|
||
|
# ->method('read')\n# ->with(self::RES_DIR, 'en_GB')\n# ->willThrowException(new\
|
||
|
\ ResourceBundleNotFoundException());\n# \n# $this->reader->readEntry(self::RES_DIR,\
|
||
|
\ 'en_GB', ['Entries', 'Bam'], false);\n# }\n# \n# public static function provideMergeableValues()\n\
|
||
|
# {\n# return [\n# ['foo', null, 'foo'],\n# [null, 'foo', 'foo'],\n# [['foo',\
|
||
|
\ 'bar'], null, ['foo', 'bar']],\n# [['foo', 'bar'], [], ['foo', 'bar']],\n# [null,\
|
||
|
\ ['baz'], ['baz']],\n# [[], ['baz'], ['baz']],\n# [['foo', 'bar'], ['baz'], ['baz',\
|
||
|
\ 'foo', 'bar']],\n# ];\n# }\n# \n# /**\n# * @dataProvider provideMergeableValues"
|
||
|
- name: testDontMergeDataIfFallbackDisabled
|
||
|
visibility: public
|
||
|
parameters:
|
||
|
- name: childData
|
||
|
- name: parentData
|
||
|
- name: result
|
||
|
comment: '# * @dataProvider provideMergeableValues'
|
||
|
- name: testMergeExistingEntryWithExistingFallbackEntry
|
||
|
visibility: public
|
||
|
parameters:
|
||
|
- name: childData
|
||
|
- name: parentData
|
||
|
- name: result
|
||
|
comment: '# * @dataProvider provideMergeableValues'
|
||
|
- name: testMergeNonExistingEntryWithExistingFallbackEntry
|
||
|
visibility: public
|
||
|
parameters:
|
||
|
- name: childData
|
||
|
- name: parentData
|
||
|
- name: result
|
||
|
comment: '# * @dataProvider provideMergeableValues'
|
||
|
- name: testMergeExistingEntryWithNonExistingFallbackEntry
|
||
|
visibility: public
|
||
|
parameters:
|
||
|
- name: childData
|
||
|
- name: parentData
|
||
|
- name: result
|
||
|
comment: '# * @dataProvider provideMergeableValues'
|
||
|
- name: testFailIfEntryFoundNeitherInParentNorChild
|
||
|
visibility: public
|
||
|
parameters: []
|
||
|
comment: null
|
||
|
- name: testMergeTraversables
|
||
|
visibility: public
|
||
|
parameters:
|
||
|
- name: childData
|
||
|
- name: parentData
|
||
|
- name: result
|
||
|
comment: '# * @dataProvider provideMergeableValues'
|
||
|
- name: testFollowLocaleAliases
|
||
|
visibility: public
|
||
|
parameters:
|
||
|
- name: childData
|
||
|
- name: parentData
|
||
|
- name: result
|
||
|
comment: '# * @dataProvider provideMergeableValues'
|
||
|
traits:
|
||
|
- PHPUnit\Framework\MockObject\MockObject
|
||
|
- PHPUnit\Framework\TestCase
|
||
|
- Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReader
|
||
|
- Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReaderInterface
|
||
|
- Symfony\Component\Intl\Exception\MissingResourceException
|
||
|
- Symfony\Component\Intl\Exception\ResourceBundleNotFoundException
|
||
|
interfaces: []
|