|
@@ 51-74 (lines=24) @@
|
| 48 |
|
* |
| 49 |
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\SlugConverter::convert |
| 50 |
|
*/ |
| 51 |
|
public function testConvert() |
| 52 |
|
{ |
| 53 |
|
$slugConverter = $this->getSlugConverterMock(array('cleanupText')); |
| 54 |
|
$transformationProcessor = $this->getTransformationProcessorMock(); |
| 55 |
|
|
| 56 |
|
$text = 'test text č '; |
| 57 |
|
$transformedText = 'test text c '; |
| 58 |
|
$slug = 'test_text_c'; |
| 59 |
|
|
| 60 |
|
$transformationProcessor->expects($this->atLeastOnce()) |
| 61 |
|
->method('transform') |
| 62 |
|
->with($text, array('test_command1')) |
| 63 |
|
->will($this->returnValue($transformedText)); |
| 64 |
|
|
| 65 |
|
$slugConverter->expects($this->once()) |
| 66 |
|
->method('cleanupText') |
| 67 |
|
->with($this->equalTo($transformedText), $this->equalTo('test_cleanup1')) |
| 68 |
|
->will($this->returnValue($slug)); |
| 69 |
|
|
| 70 |
|
$this->assertEquals( |
| 71 |
|
$slug, |
| 72 |
|
$slugConverter->convert($text) |
| 73 |
|
); |
| 74 |
|
} |
| 75 |
|
|
| 76 |
|
/** |
| 77 |
|
* Test for the convert() method. |
|
@@ 81-104 (lines=24) @@
|
| 78 |
|
* |
| 79 |
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\SlugConverter::convert |
| 80 |
|
*/ |
| 81 |
|
public function testConvertWithDefaultTextFallback() |
| 82 |
|
{ |
| 83 |
|
$slugConverter = $this->getSlugConverterMock(array('cleanupText')); |
| 84 |
|
$transformationProcessor = $this->getTransformationProcessorMock(); |
| 85 |
|
|
| 86 |
|
$defaultText = 'test text č '; |
| 87 |
|
$transformedText = 'test text c '; |
| 88 |
|
$slug = 'test_text_c'; |
| 89 |
|
|
| 90 |
|
$transformationProcessor->expects($this->atLeastOnce()) |
| 91 |
|
->method('transform') |
| 92 |
|
->with($defaultText, array('test_command1')) |
| 93 |
|
->will($this->returnValue($transformedText)); |
| 94 |
|
|
| 95 |
|
$slugConverter->expects($this->once()) |
| 96 |
|
->method('cleanupText') |
| 97 |
|
->with($this->equalTo($transformedText), $this->equalTo('test_cleanup1')) |
| 98 |
|
->will($this->returnValue($slug)); |
| 99 |
|
|
| 100 |
|
$this->assertEquals( |
| 101 |
|
$slug, |
| 102 |
|
$slugConverter->convert('', $defaultText) |
| 103 |
|
); |
| 104 |
|
} |
| 105 |
|
|
| 106 |
|
/** |
| 107 |
|
* Test for the convert() method. |
|
@@ 111-134 (lines=24) @@
|
| 108 |
|
* |
| 109 |
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\SlugConverter::convert |
| 110 |
|
*/ |
| 111 |
|
public function testConvertWithGivenTransformation() |
| 112 |
|
{ |
| 113 |
|
$slugConverter = $this->getSlugConverterMock(array('cleanupText')); |
| 114 |
|
$transformationProcessor = $this->getTransformationProcessorMock(); |
| 115 |
|
|
| 116 |
|
$text = 'test text č '; |
| 117 |
|
$transformedText = 'test text c '; |
| 118 |
|
$slug = 'test_text_c'; |
| 119 |
|
|
| 120 |
|
$transformationProcessor->expects($this->atLeastOnce()) |
| 121 |
|
->method('transform') |
| 122 |
|
->with($text, array('test_command2')) |
| 123 |
|
->will($this->returnValue($transformedText)); |
| 124 |
|
|
| 125 |
|
$slugConverter->expects($this->once()) |
| 126 |
|
->method('cleanupText') |
| 127 |
|
->with($this->equalTo($transformedText), $this->equalTo('test_cleanup2')) |
| 128 |
|
->will($this->returnValue($slug)); |
| 129 |
|
|
| 130 |
|
$this->assertEquals( |
| 131 |
|
$slug, |
| 132 |
|
$slugConverter->convert($text, '_1', 'testTransformation2') |
| 133 |
|
); |
| 134 |
|
} |
| 135 |
|
|
| 136 |
|
public function providerForTestGetUniqueCounterValue() |
| 137 |
|
{ |