1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
- namespace Cocur\Slugify\Tests\Bridge\Symfony;
- use Cocur\Slugify\Bridge\Symfony\Configuration;
- use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
- use Symfony\Component\Config\Definition\Processor;
- use Mockery\Adapter\Phpunit\MockeryTestCase;
- class ConfigurationTest extends MockeryTestCase
- {
- public function testAll()
- {
- $configs = [
- [
- 'lowercase' => true,
- 'lowercase_after_regexp' => false,
- 'strip_tags' => false,
- 'separator' => '_',
- 'regexp' => 'abcd',
- 'rulesets' => ['burmese', 'hindi']
- ],
- ];
- $this->assertSame($configs[0], $this->process($configs));
- }
- public function testLowercaseOnlyAcceptsBoolean()
- {
- $this->expectException(InvalidTypeException::class);
- $configs = [['lowercase' => 'abc']];
- $this->process($configs);
- }
- public function testLowercaseAfterRegexpOnlyAcceptsBoolean()
- {
- $this->expectException(InvalidTypeException::class);
- $configs = [['lowercase_after_regexp' => 'abc']];
- $this->process($configs);
- }
- public function testStripTagsOnlyAcceptsBoolean()
- {
- $this->expectException(InvalidTypeException::class);
- $configs = [['strip_tags' => 'abc']];
- $this->process($configs);
- }
-
- protected function process($configs)
- {
- $processor = new Processor();
- return $processor->processConfiguration(new Configuration(), $configs);
- }
- }
|