Completed
Push — master ( 35c535...a21b50 )
by Damian
05:54
created

BlogTagTest::testAllowMultibyteUrlSegment()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 12
Ratio 100 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 12
loc 12
rs 9.4285
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
3
/**
4
 * @mixin PHPUnit_Framework_TestCase
5
 */
6
class BlogTagTest extends FunctionalTest
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
7
{
8
    /**
9
     * @var string
10
     */
11
    public static $fixture_file = 'blog.yml';
12
13
    /**
14
     * {@inheritdoc}
15
     */
16
    public function setUp()
17
    {
18
        parent::setUp();
19
20
        SS_Datetime::set_mock_now('2013-10-10 20:00:00');
21
    }
22
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function tearDown()
27
    {
28
        SS_Datetime::clear_mock_now();
29
30
        parent::tearDown();
31
    }
32
33
    /**
34
     * Tests that any blog posts returned from $tag->BlogPosts() many_many are published, both by
35
     * normal 'save & publish' functionality and by publish date.
36
     */
37 View Code Duplication
    public function testBlogPosts()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
38
    {
39
        $member = Member::currentUser();
40
41
        if ($member) {
42
            $member->logout();
43
        }
44
45
        $this->objFromFixture('BlogPost', 'FirstBlogPost');
46
47
        /**
48
         * @var BlogTag $tag
49
         */
50
        $tag = $this->objFromFixture('BlogTag', 'FirstTag');
51
52
        $this->assertEquals(1, $tag->BlogPosts()->count(), 'Tag blog post count');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogTagTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
53
    }
54
55
    /**
56
     * @see https://github.com/silverstripe/silverstripe-blog/issues/376
57
     */
58 View Code Duplication
    public function testAllowMultibyteUrlSegment()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
59
    {
60
        $blog = $this->objFromFixture('Blog', 'FirstBlog');
61
        $tag = new BlogTag();
62
        $tag->BlogID = $blog->ID;
63
        $tag->Title = 'تست';
64
        $tag->write();
65
        // urlencoded
66
        $this->assertEquals('%D8%AA%D8%B3%D8%AA', $tag->URLSegment);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogTagTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
67
        $link = Controller::join_links($tag->Blog()->Link(), 'tag', '%D8%AA%D8%B3%D8%AA');
68
        $this->assertEquals($link, $tag->getLink());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogTagTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
69
    }
70
71
    /**
72
     * The first blog can be viewed by anybody.
73
     */
74
    public function testCanView()
75
    {
76
        $this->useDraftSite();
77
78
        $admin = $this->objFromFixture('Member', 'Admin');
79
        $editor = $this->objFromFixture('Member', 'Editor');
80
81
        $tag = $this->objFromFixture('BlogTag', 'FirstTag');
82
83
        $this->assertTrue($tag->canView($admin), 'Admin should be able to view tag.');
0 ignored issues
show
Bug introduced by
It seems like $admin defined by $this->objFromFixture('Member', 'Admin') on line 78 can also be of type object<DataObject>; however, DataObject::canView() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertTrue() does not seem to exist on object<BlogTagTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
84
        $this->assertTrue($tag->canView($editor), 'Editor should be able to view tag.');
0 ignored issues
show
Bug introduced by
It seems like $editor defined by $this->objFromFixture('Member', 'Editor') on line 79 can also be of type object<DataObject>; however, DataObject::canView() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertTrue() does not seem to exist on object<BlogTagTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
85
86
        $tag = $this->objFromFixture('BlogTag', 'SecondTag');
87
88
        $this->assertTrue($tag->canView($admin), 'Admin should be able to view tag.');
0 ignored issues
show
Bug introduced by
It seems like $admin defined by $this->objFromFixture('Member', 'Admin') on line 78 can also be of type object<DataObject>; however, DataObject::canView() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertTrue() does not seem to exist on object<BlogTagTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
89
        $this->assertFalse($tag->canView($editor), 'Editor should not be able to view tag.');
0 ignored issues
show
Bug introduced by
It seems like $editor defined by $this->objFromFixture('Member', 'Editor') on line 79 can also be of type object<DataObject>; however, DataObject::canView() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertFalse() does not seem to exist on object<BlogTagTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
90
    }
91
92 View Code Duplication
    public function testCanEdit()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
93
    {
94
        $this->useDraftSite();
95
96
        $admin = $this->objFromFixture('Member', 'Admin');
97
        $editor = $this->objFromFixture('Member', 'Editor');
98
99
        $tag = $this->objFromFixture('BlogTag', 'FirstTag');
100
101
        $this->assertTrue($tag->canEdit($admin), 'Admin should be able to edit tag.');
0 ignored issues
show
Bug introduced by
It seems like $admin defined by $this->objFromFixture('Member', 'Admin') on line 96 can also be of type object<DataObject>; however, DataObject::canEdit() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertTrue() does not seem to exist on object<BlogTagTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
102
        $this->assertTrue($tag->canEdit($editor), 'Editor should be able to edit tag.');
0 ignored issues
show
Bug introduced by
It seems like $editor defined by $this->objFromFixture('Member', 'Editor') on line 97 can also be of type object<DataObject>; however, DataObject::canEdit() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertTrue() does not seem to exist on object<BlogTagTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
103
104
        $tag = $this->objFromFixture('BlogTag', 'SecondTag');
105
106
        $this->assertTrue($tag->canEdit($admin), 'Admin should be able to edit tag.');
0 ignored issues
show
Bug introduced by
It seems like $admin defined by $this->objFromFixture('Member', 'Admin') on line 96 can also be of type object<DataObject>; however, DataObject::canEdit() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertTrue() does not seem to exist on object<BlogTagTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
107
        $this->assertFalse($tag->canEdit($editor), 'Editor should not be able to edit tag.');
0 ignored issues
show
Bug introduced by
It seems like $editor defined by $this->objFromFixture('Member', 'Editor') on line 97 can also be of type object<DataObject>; however, DataObject::canEdit() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertFalse() does not seem to exist on object<BlogTagTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
108
109
        $tag = $this->objFromFixture('BlogTag', 'ThirdTag');
110
111
        $this->assertTrue($tag->canEdit($admin), 'Admin should always be able to edit tags.');
0 ignored issues
show
Bug introduced by
It seems like $admin defined by $this->objFromFixture('Member', 'Admin') on line 96 can also be of type object<DataObject>; however, DataObject::canEdit() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertTrue() does not seem to exist on object<BlogTagTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
112
        $this->assertTrue($tag->canEdit($editor), 'Editor should be able to edit tag.');
0 ignored issues
show
Bug introduced by
It seems like $editor defined by $this->objFromFixture('Member', 'Editor') on line 97 can also be of type object<DataObject>; however, DataObject::canEdit() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertTrue() does not seem to exist on object<BlogTagTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
113
    }
114
115 View Code Duplication
    public function testCanCreate()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
116
    {
117
        $this->useDraftSite();
118
119
        $admin = $this->objFromFixture('Member', 'Admin');
120
        $editor = $this->objFromFixture('Member', 'Editor');
121
122
        $tag = singleton('BlogTag');
123
124
        $this->assertTrue($tag->canCreate($admin), 'Admin should be able to create tag.');
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<BlogTagTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
125
        $this->assertTrue($tag->canCreate($editor), 'Editor should be able to create tag.');
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<BlogTagTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
126
    }
127
128 View Code Duplication
    public function testCanDelete()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
129
    {
130
        $this->useDraftSite();
131
132
        $admin = $this->objFromFixture('Member', 'Admin');
133
        $editor = $this->objFromFixture('Member', 'Editor');
134
135
        $tag = $this->objFromFixture('BlogTag', 'FirstTag');
136
137
        $this->assertTrue($tag->canDelete($admin), 'Admin should be able to delete tag.');
0 ignored issues
show
Bug introduced by
It seems like $admin defined by $this->objFromFixture('Member', 'Admin') on line 132 can also be of type object<DataObject>; however, DataObject::canDelete() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertTrue() does not seem to exist on object<BlogTagTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
138
        $this->assertTrue($tag->canDelete($editor), 'Editor should be able to delete tag.');
0 ignored issues
show
Bug introduced by
It seems like $editor defined by $this->objFromFixture('Member', 'Editor') on line 133 can also be of type object<DataObject>; however, DataObject::canDelete() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertTrue() does not seem to exist on object<BlogTagTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
139
140
        $tag = $this->objFromFixture('BlogTag', 'SecondTag');
141
142
        $this->assertTrue($tag->canDelete($admin), 'Admin should be able to delete tag.');
0 ignored issues
show
Bug introduced by
It seems like $admin defined by $this->objFromFixture('Member', 'Admin') on line 132 can also be of type object<DataObject>; however, DataObject::canDelete() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertTrue() does not seem to exist on object<BlogTagTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
143
        $this->assertFalse($tag->canDelete($editor), 'Editor should not be able to delete tag.');
0 ignored issues
show
Bug introduced by
It seems like $editor defined by $this->objFromFixture('Member', 'Editor') on line 133 can also be of type object<DataObject>; however, DataObject::canDelete() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertFalse() does not seem to exist on object<BlogTagTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
144
145
        $tag = $this->objFromFixture('BlogTag', 'ThirdTag');
146
147
        $this->assertTrue($tag->canDelete($admin), 'Admin should always be able to delete tags.');
0 ignored issues
show
Bug introduced by
It seems like $admin defined by $this->objFromFixture('Member', 'Admin') on line 132 can also be of type object<DataObject>; however, DataObject::canDelete() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertTrue() does not seem to exist on object<BlogTagTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
148
        $this->assertTrue($tag->canDelete($editor), 'Editor should be able to delete tag.');
0 ignored issues
show
Bug introduced by
It seems like $editor defined by $this->objFromFixture('Member', 'Editor') on line 133 can also be of type object<DataObject>; however, DataObject::canDelete() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertTrue() does not seem to exist on object<BlogTagTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
149
    }
150
151
    public function testDuplicateTagsForURLSegment() {
152
        $blog = new Blog();
153
        $blog->Title = 'Testing for duplicates blog';
154
        $blog->write();
155
        $tag1 = new BlogTag();
156
        $tag1->Title = 'cat-test';
157
        $tag1->BlogID = $blog->ID;
158
        $tag1->write();
159
        $this->assertEquals('cat-test', $tag1->URLSegment);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogTagTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
160
161
        $tag2 = new BlogTag();
162
        $tag2->Title = 'cat test';
163
        $tag2->BlogID = $blog->ID;
164
        $tag2->write();
165
        $this->assertEquals('cat-test-0', $tag2->URLSegment);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogTagTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
166
167
    }
168
169 View Code Duplication
    public function testDuplicateTags() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
170
        $blog = new Blog();
171
        $blog->Title = 'Testing for duplicate tags';
172
        $blog->write();
173
174
        $tag = new BlogTag();
175
        $tag->Title = 'Test';
176
        $tag->BlogID = $blog->ID;
177
        $tag->write();
178
179
        $tag = new BlogTag();
180
        $tag->Title = 'Test';
181
        $tag->BlogID = $blog->ID;
182
        try {
183
            $tag->write();
184
            $this->fail('Duplicate BlogTag written');
0 ignored issues
show
Bug introduced by
The method fail() does not seem to exist on object<BlogTagTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
185
        } catch (ValidationException $e) {
186
            $codeList = $e->getResult()->codeList();
187
            $this->assertCount(1, $codeList);
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<BlogTagTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
188
            $this->assertEquals(BlogTag::DUPLICATE_EXCEPTION, $codeList[0]);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogTagTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
189
        }
190
    }
191
192
}
193