Passed
Push — master ( 702f73...7013df )
by Gordon
02:35
created

SluggableObjectTest::test_upper_case()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
namespace Suilven\Sluggable\Tests;
3
4
use SilverStripe\CMS\Model\SiteTree;
0 ignored issues
show
Bug introduced by
The type SilverStripe\CMS\Model\SiteTree was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
5
use SilverStripe\Core\Config\Config;
0 ignored issues
show
Bug introduced by
The type SilverStripe\Core\Config\Config was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use SilverStripe\Core\Injector\Injector;
0 ignored issues
show
Bug introduced by
The type SilverStripe\Core\Injector\Injector was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use SilverStripe\Core\Kernel;
0 ignored issues
show
Bug introduced by
The type SilverStripe\Core\Kernel was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use SilverStripe\Core\Startup\ScheduledFlushDiscoverer;
0 ignored issues
show
Bug introduced by
The type SilverStripe\Core\Startup\ScheduledFlushDiscoverer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use SilverStripe\Dev\SapphireTest;
0 ignored issues
show
Bug introduced by
The type SilverStripe\Dev\SapphireTest was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use Suilven\Sluggable\Extension\Sluggable;
11
use Suilven\Sluggable\Helper\SluggableHelper;
12
use Suilven\Sluggable\Tests\Model\SluggestTestObject;
13
14
class SluggableObjectTest extends SapphireTest
15
{
16
    protected static $extra_dataobjects = [
17
        SluggestTestObject::class
18
    ];
19
20
    public function testLowerCase()
21
    {
22
        $this->assertEquals('this-is-lower-case', $this->getSlugFromDataObject('this is lower case'));
23
    }
24
25
    public function test_upper_case()
26
    {
27
        $this->assertEquals('this-is-upper-case', $this->getSlugFromDataObject('THIS IS UPPER CASE'));
28
    }
29
30
    public function text_mixed_case()
31
    {
32
        $this->assertEquals('this-is-mixed-case', $this->getSlugFromDataObject('THIs-Is-Mixed-case'));
33
    }
34
35
    public function test_empty_string()
36
    {
37
        $this->assertEquals('', $this->getSlugFromDataObject(''));
38
    }
39
40
    public function test_duplicate_string()
41
    {
42
        $this->assertEquals('duplicate', $this->getSlugFromDataObject('Duplicate'));
43
        $this->assertEquals('duplicate-1', $this->getSlugFromDataObject('Duplicate'));
44
        $this->assertEquals('duplicate-2', $this->getSlugFromDataObject('Duplicate'));
45
46
    }
47
48
    private function getSlugFromDataObject($title)
49
    {
50
        $object = new SluggestTestObject();
51
        $object->DisplayName = $title;
52
        $object->write();
53
        return $object->Slug;
54
    }
55
}
56