FileRuleProviderTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 PHPUnit_Framework_TestCase;
  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 PHPUnit_Framework_TestCase
  23. {
  24. /**
  25. * @test
  26. * @covers Cocur\Slugify\RuleProvider\FileRuleProvider::__construct()
  27. * @covers Cocur\Slugify\RuleProvider\FileRuleProvider::getRules()
  28. */
  29. public function getRulesReturnsRulesReadFromJsonFile()
  30. {
  31. vfsStream::setup('fixtures', null, [
  32. 'german.json' => '{"ä": "a"}',
  33. 'austrian.json' => '{"ß": "sz"}',
  34. ]);
  35. $provider = new FileRuleProvider(vfsStream::url('fixtures'));
  36. $this->assertEquals(['ä' => 'a'], $provider->getRules('german'));
  37. $this->assertEquals(['ß' => 'sz'], $provider->getRules('austrian'));
  38. }
  39. }