ConfigurationTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /*
  3. * This file is part of the cocur/slugify package.
  4. *
  5. * (c) Enrico Stahn <enrico.stahn@gmail.com>
  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\Bridge\Symfony;
  11. use Cocur\Slugify\Bridge\Symfony\Configuration;
  12. use Symfony\Component\Config\Definition\Processor;
  13. class ConfigurationTest extends \PHPUnit_Framework_TestCase
  14. {
  15. public function testAll()
  16. {
  17. $configs = [
  18. [
  19. 'lowercase' => true,
  20. 'separator' => '_',
  21. 'regexp' => 'abcd',
  22. 'rulesets' => ['burmese', 'hindi']
  23. ],
  24. ];
  25. $this->process($configs);
  26. }
  27. /**
  28. * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidTypeException
  29. */
  30. public function testLowercaseOnlyAcceptsBoolean()
  31. {
  32. $configs = [['lowercase' => 'abc']];
  33. $this->process($configs);
  34. }
  35. /**
  36. * Processes an array of configurations and returns a compiled version.
  37. *
  38. * @param array $configs An array of raw configurations
  39. *
  40. * @return array A normalized array
  41. */
  42. protected function process($configs)
  43. {
  44. $processor = new Processor();
  45. return $processor->processConfiguration(new Configuration(), $configs);
  46. }
  47. }