FileRuleProviderTest.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * This file is part of cocur/slugify.
  4. *
  5. * (c) Florian Eckerstorfer <florian@eckerstorfer.co>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Cocur\Slugify\Tests\RuleProvider;
  11. use Cocur\Slugify\RuleProvider\FileRuleProvider;
  12. use org\bovigo\vfs\vfsStream;
  13. use Mockery\Adapter\Phpunit\MockeryTestCase;
  14. /**
  15. * FileRuleProviderTest
  16. *
  17. * @package Cocur\Slugify\RuleProvider
  18. * @author Florian Eckerstorfer
  19. * @copyright 2015 Florian Eckerstorfer
  20. * @group unit
  21. */
  22. class FileRuleProviderTest extends MockeryTestCase
  23. {
  24. /**
  25. * @covers \Cocur\Slugify\RuleProvider\FileRuleProvider::__construct()
  26. * @covers \Cocur\Slugify\RuleProvider\FileRuleProvider::getRules()
  27. */
  28. public function testGetRulesReturnsRulesReadFromJsonFile()
  29. {
  30. vfsStream::setup('fixtures', null, [
  31. 'german.json' => '{"ä": "a"}',
  32. 'austrian.json' => '{"ß": "sz"}',
  33. ]);
  34. $provider = new FileRuleProvider(vfsStream::url('fixtures'));
  35. $this->assertEquals(['ä' => 'a'], $provider->getRules('german'));
  36. $this->assertEquals(['ß' => 'sz'], $provider->getRules('austrian'));
  37. }
  38. }