SlugifyConverterTest.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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\Bridge\Plum;
  11. use Cocur\Slugify\Bridge\Plum\SlugifyConverter;
  12. use Mockery;
  13. use Mockery\Adapter\Phpunit\MockeryTestCase;
  14. /**
  15. * SlugifyConverterTest
  16. *
  17. * @package Cocur\Slugify\Bridge\Plum
  18. * @author Florian Eckerstorfer <florian@eckerstorfer.co>
  19. * @copyright 2012-2015 Florian Eckerstorfer
  20. * @group unit
  21. */
  22. class SlugifyConverterTest extends MockeryTestCase
  23. {
  24. /**
  25. * @covers \Cocur\Slugify\Bridge\Plum\SlugifyConverter::__construct()
  26. * @covers \Cocur\Slugify\Bridge\Plum\SlugifyConverter::convert()
  27. */
  28. public function testConvertSlugifiesString()
  29. {
  30. $slugify = Mockery::mock('Cocur\Slugify\SlugifyInterface');
  31. $slugify->shouldReceive('slugify')->with('Hello World')->once()->andReturn('hello_world');
  32. $converter = new SlugifyConverter($slugify);
  33. $this->assertSame('hello_world', $converter->convert('Hello World'));
  34. }
  35. /**
  36. * @covers \Cocur\Slugify\Bridge\Plum\SlugifyConverter::__construct()
  37. * @covers \Cocur\Slugify\Bridge\Plum\SlugifyConverter::convert()
  38. */
  39. public function testConstructorCreatesSlugifyIfNoneIsProvided()
  40. {
  41. $converter = new SlugifyConverter();
  42. $this->assertSame('hello-world', $converter->convert('Hello World'));
  43. }
  44. }