-
Notifications
You must be signed in to change notification settings - Fork 11
/
SlugTest.php
69 lines (59 loc) · 2.07 KB
/
SlugTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
namespace Particle\Tests\Filter\FilterRule;
use Particle\Filter\Filter;
class SlugTest extends \PHPUnit_Framework_TestCase
{
/**
* @var Filter
*/
protected $filter;
/**
* Prepare the filter
*/
public function setUp()
{
$this->filter = new Filter();
}
/**
* @dataProvider getSlugResults
* @param string $value
* @param string $filteredValue
* @param string $field
* @param string $fieldValue
*/
public function testSlugFilterRule($value, $filteredValue, $field, $fieldValue)
{
$this->filter->value('test')->slug($field);
$result = $this->filter->filter([
'test' => $value,
$field => $fieldValue,
]);
$this->assertSame($filteredValue, $result['test']);
}
/**
* @return array
*/
public function getSlugResults()
{
return [
['', '', '', ''],
['This is a great stuff to slug !', 'this-is-a-great-stuff-to-slug', '', ''],
['That too with somê spéciàl châractèr$ from €ope !', 'that-too-with-some-special-character-from-europe', '', ''],
['A æ Übérmensch på høyeste nivå! И я люблю PHP ! fi', 'a-ae-ubermensch-pa-hoyeste-niva-i-a-lublu-php-fi', '', ''],
['', 'this-is-a-great-stuff-to-slug', 'test', 'This is a great stuff to slug !'],
['', 'that-too-with-some-special-character-from-europe', 'test', 'That too with somê spéciàl châractèr$ from €ope !'],
['', 'a-ae-ubermensch-pa-hoyeste-niva-i-a-lublu-php-fi', 'test', 'A æ Übérmensch på høyeste nivå! И я люблю PHP ! fi'],
];
}
/**
* Test that a slug based of a non existing key, does not exist.
*/
public function testSlugFilterEmptyIfNotAvailable()
{
$this->filter->value('slug')->slug('title');
$result = $this->filter->filter([
'not-title' => 'Definitely not a title to slug',
]);
$this->assertSame(['not-title' => 'Definitely not a title to slug'], $result);
}
}