SlugifyConverterTest.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 PHPUnit_Framework_TestCase;
  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 PHPUnit_Framework_TestCase
  23. {
  24. /**
  25. * @test
  26. * @covers Cocur\Slugify\Bridge\Plum\SlugifyConverter::__construct()
  27. * @covers Cocur\Slugify\Bridge\Plum\SlugifyConverter::convert()
  28. */
  29. public function convertSlugifiesString()
  30. {
  31. $slugify = Mockery::mock('Cocur\Slugify\SlugifyInterface');
  32. $slugify->shouldReceive('slugify')->with('Hello World')->once()->andReturn('hello_world');
  33. $converter = new SlugifyConverter($slugify);
  34. $this->assertSame('hello_world', $converter->convert('Hello World'));
  35. }
  36. /**
  37. * @test
  38. * @covers Cocur\Slugify\Bridge\Plum\SlugifyConverter::__construct()
  39. * @covers Cocur\Slugify\Bridge\Plum\SlugifyConverter::convert()
  40. */
  41. public function constructorCreatesSlugifyIfNoneIsProvided()
  42. {
  43. $converter = new SlugifyConverter();
  44. $this->assertSame('hello-world', $converter->convert('Hello World'));
  45. }
  46. }