Completed
Push — master ( 067f41...e7ef92 )
by Damian
02:10
created

BlogTagTest::testDuplicateTags()   A

Complexity

Conditions 2
Paths 3

Size

Total Lines 22
Code Lines 18

Duplication

Lines 22
Ratio 100 %
Metric Value
dl 22
loc 22
rs 9.2
cc 2
eloc 18
nc 3
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
     * The first blog can be viewed by anybody.
57
     */
58
    public function testCanView()
59
    {
60
        $this->useDraftSite();
61
62
        $admin = $this->objFromFixture('Member', 'Admin');
63
        $editor = $this->objFromFixture('Member', 'Editor');
64
65
        $tag = $this->objFromFixture('BlogTag', 'FirstTag');
66
67
        $this->assertTrue($tag->canView($admin), 'Admin should be able to view 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...
Bug introduced by
It seems like $admin defined by $this->objFromFixture('Member', 'Admin') on line 62 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...
68
        $this->assertTrue($tag->canView($editor), 'Editor should be able to view 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...
Bug introduced by
It seems like $editor defined by $this->objFromFixture('Member', 'Editor') on line 63 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...
69
70
        $tag = $this->objFromFixture('BlogTag', 'SecondTag');
71
72
        $this->assertTrue($tag->canView($admin), 'Admin should be able to view 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...
Bug introduced by
It seems like $admin defined by $this->objFromFixture('Member', 'Admin') on line 62 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...
73
        $this->assertFalse($tag->canView($editor), 'Editor should not be able to view tag.');
0 ignored issues
show
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...
Bug introduced by
It seems like $editor defined by $this->objFromFixture('Member', 'Editor') on line 63 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...
74
    }
75
76 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...
77
    {
78
        $this->useDraftSite();
79
80
        $admin = $this->objFromFixture('Member', 'Admin');
81
        $editor = $this->objFromFixture('Member', 'Editor');
82
83
        $tag = $this->objFromFixture('BlogTag', 'FirstTag');
84
85
        $this->assertTrue($tag->canEdit($admin), 'Admin should be able to edit 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...
Bug introduced by
It seems like $admin defined by $this->objFromFixture('Member', 'Admin') on line 80 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...
86
        $this->assertTrue($tag->canEdit($editor), 'Editor should be able to edit 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...
Bug introduced by
It seems like $editor defined by $this->objFromFixture('Member', 'Editor') on line 81 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...
87
88
        $tag = $this->objFromFixture('BlogTag', 'SecondTag');
89
90
        $this->assertTrue($tag->canEdit($admin), 'Admin should be able to edit 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...
Bug introduced by
It seems like $admin defined by $this->objFromFixture('Member', 'Admin') on line 80 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...
91
        $this->assertFalse($tag->canEdit($editor), 'Editor should not be able to edit tag.');
0 ignored issues
show
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...
Bug introduced by
It seems like $editor defined by $this->objFromFixture('Member', 'Editor') on line 81 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...
92
93
        $tag = $this->objFromFixture('BlogTag', 'ThirdTag');
94
95
        $this->assertTrue($tag->canEdit($admin), 'Admin should always be able to edit tags.');
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...
Bug introduced by
It seems like $admin defined by $this->objFromFixture('Member', 'Admin') on line 80 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...
96
        $this->assertTrue($tag->canEdit($editor), 'Editor should be able to edit 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...
Bug introduced by
It seems like $editor defined by $this->objFromFixture('Member', 'Editor') on line 81 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...
97
    }
98
99 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...
100
    {
101
        $this->useDraftSite();
102
103
        $admin = $this->objFromFixture('Member', 'Admin');
104
        $editor = $this->objFromFixture('Member', 'Editor');
105
106
        $tag = singleton('BlogTag');
107
108
        $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...
109
        $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...
110
    }
111
112 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...
113
    {
114
        $this->useDraftSite();
115
116
        $admin = $this->objFromFixture('Member', 'Admin');
117
        $editor = $this->objFromFixture('Member', 'Editor');
118
119
        $tag = $this->objFromFixture('BlogTag', 'FirstTag');
120
121
        $this->assertTrue($tag->canDelete($admin), 'Admin should be able to delete 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...
Bug introduced by
It seems like $admin defined by $this->objFromFixture('Member', 'Admin') on line 116 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...
122
        $this->assertTrue($tag->canDelete($editor), 'Editor should be able to delete 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...
Bug introduced by
It seems like $editor defined by $this->objFromFixture('Member', 'Editor') on line 117 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...
123
124
        $tag = $this->objFromFixture('BlogTag', 'SecondTag');
125
126
        $this->assertTrue($tag->canDelete($admin), 'Admin should be able to delete 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...
Bug introduced by
It seems like $admin defined by $this->objFromFixture('Member', 'Admin') on line 116 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...
127
        $this->assertFalse($tag->canDelete($editor), 'Editor should not be able to delete tag.');
0 ignored issues
show
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...
Bug introduced by
It seems like $editor defined by $this->objFromFixture('Member', 'Editor') on line 117 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...
128
129
        $tag = $this->objFromFixture('BlogTag', 'ThirdTag');
130
131
        $this->assertTrue($tag->canDelete($admin), 'Admin should always be able to delete tags.');
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...
Bug introduced by
It seems like $admin defined by $this->objFromFixture('Member', 'Admin') on line 116 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...
132
        $this->assertTrue($tag->canDelete($editor), 'Editor should be able to delete 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...
Bug introduced by
It seems like $editor defined by $this->objFromFixture('Member', 'Editor') on line 117 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...
133
    }
134
135
    public function testDuplicateTagsForURLSegment() {
136
        $blog = new Blog();
137
        $blog->Title = 'Testing for duplicates blog';
138
        $blog->write();
139
        $tag1 = new BlogTag();
140
        $tag1->Title = 'cat-test';
141
        $tag1->BlogID = $blog->ID;
142
        $tag1->write();
143
        $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...
144
145
        $tag2 = new BlogTag();
146
        $tag2->Title = 'cat test';
147
        $tag2->BlogID = $blog->ID;
148
        $tag2->write();
149
        $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...
150
151
    }
152
153 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...
154
        $blog = new Blog();
155
        $blog->Title = 'Testing for duplicate tags';
156
        $blog->write();
157
158
        $tag = new BlogTag();
159
        $tag->Title = 'Test';
160
        $tag->BlogID = $blog->ID;
161
        $tag->write();
162
163
        $tag = new BlogTag();
164
        $tag->Title = 'Test';
165
        $tag->BlogID = $blog->ID;
166
        try {
167
            $tag->write();
168
            $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...
169
        } catch (ValidationException $e) {
170
            $codeList = $e->getResult()->codeList();
171
            $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...
172
            $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...
173
        }
174
    }
175
176
}
177