These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | class CommentingTest extends SapphireTest { |
||
4 | |||
5 | public function setUpOnce() { |
||
6 | parent::setUpOnce(); |
||
7 | } |
||
8 | |||
9 | public function testDeprecatedMethods() { |
||
10 | $methods = array('add', 'remove', 'has_commenting'); |
||
11 | foreach ($methods as $methodName) { |
||
12 | try { |
||
13 | Commenting::$methodName('Member'); |
||
14 | } catch (PHPUnit_Framework_Error_Deprecated $e) { |
||
15 | $expected = 'Using Commenting:' . $methodName .' is deprecated.' |
||
16 | . ' Please use the config API instead'; |
||
17 | $this->assertEquals($expected, $e->getMessage()); |
||
18 | } |
||
19 | } |
||
20 | } |
||
21 | |||
22 | |||
23 | public function test_set_config_value() { |
||
24 | // public static function set_config_value($class, $key, $value = false) { |
||
25 | Commenting::set_config_value( |
||
0 ignored issues
–
show
|
|||
26 | 'CommentableItem', |
||
27 | 'comments_holder_id', |
||
28 | 'commentable_item' |
||
29 | ); |
||
30 | |||
31 | $config = Config::inst()->get( |
||
32 | 'CommentableItem', |
||
33 | 'comments' |
||
34 | ); |
||
35 | $actual = $config['comments_holder_id']; |
||
36 | |||
37 | $this->assertEquals( |
||
0 ignored issues
–
show
The method
assertEquals() does not seem to exist on object<CommentingTest> .
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...
|
|||
38 | 'commentable_item', |
||
39 | $actual |
||
40 | ); |
||
41 | Commenting::set_config_value( |
||
0 ignored issues
–
show
The method
Commenting::set_config_value() has been deprecated with message: since version 2.0
This method has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.
Loading history...
|
|||
42 | 'all', |
||
43 | 'comments_holder_id', |
||
44 | 'all_items_actually_commentsextension' |
||
45 | ); |
||
46 | |||
47 | $config = Config::inst()->get( |
||
48 | 'CommentsExtension', |
||
49 | 'comments' |
||
50 | ); |
||
51 | $actual = $config['comments_holder_id']; |
||
52 | $this->assertEquals( |
||
0 ignored issues
–
show
The method
assertEquals() does not seem to exist on object<CommentingTest> .
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 | 'all_items_actually_commentsextension', |
||
54 | $actual |
||
55 | ); |
||
56 | } |
||
57 | |||
58 | public function test_get_config_value() { |
||
59 | Config::inst()->update('CommentableItem', 'comments', |
||
60 | array( |
||
61 | 'comments_holder_id' => 'commentable_item' |
||
62 | ) |
||
63 | ); |
||
64 | $this->assertEquals( |
||
0 ignored issues
–
show
The method
assertEquals() does not seem to exist on object<CommentingTest> .
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...
|
|||
65 | 'commentable_item', |
||
66 | Commenting::get_config_value('CommentableItem', 'comments_holder_id') |
||
67 | ); |
||
68 | |||
69 | Config::inst()->update('CommentsExtension', 'comments', |
||
70 | array( |
||
71 | 'comments_holder_id' => 'comments_extension' |
||
72 | ) |
||
73 | ); |
||
74 | // if class is null, method uses the CommentsExtension property |
||
75 | $this->assertEquals( |
||
0 ignored issues
–
show
The method
assertEquals() does not seem to exist on object<CommentingTest> .
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...
|
|||
76 | 'comments_extension', |
||
77 | Commenting::get_config_value(null, 'comments_holder_id') |
||
78 | ); |
||
79 | |||
80 | $this->setExpectedException( |
||
81 | 'InvalidArgumentException', |
||
82 | 'Member does not have commenting enabled' |
||
83 | ); |
||
84 | Commenting::get_config_value('Member', 'comments_holder_id'); |
||
85 | } |
||
86 | |||
87 | public function test_config_value_equals() { |
||
88 | Config::inst()->update('CommentableItem', 'comments', |
||
89 | array( |
||
90 | 'comments_holder_id' => 'some_value' |
||
91 | ) |
||
92 | ); |
||
93 | |||
94 | $this->assertTrue( |
||
95 | Commenting::config_value_equals( |
||
0 ignored issues
–
show
The method
Commenting::config_value_equals() has been deprecated with message: since version 2.0
This method has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.
Loading history...
|
|||
96 | 'CommentableItem', |
||
97 | 'comments_holder_id', |
||
98 | 'some_value' |
||
99 | ) |
||
100 | ); |
||
101 | |||
102 | $this->assertNull( |
||
103 | Commenting::config_value_equals( |
||
0 ignored issues
–
show
The method
Commenting::config_value_equals() has been deprecated with message: since version 2.0
This method has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.
Loading history...
|
|||
104 | 'CommentableItem', |
||
105 | 'comments_holder_id', |
||
106 | 'not_some_value' |
||
107 | ) |
||
108 | ); |
||
109 | } |
||
110 | |||
111 | public function test_add() { |
||
112 | Commenting::add('Member', array('comments_holder_id' => 'test_add_value')); |
||
113 | |||
114 | $config = Config::inst()->get( |
||
115 | 'Member', |
||
116 | 'comments' |
||
117 | ); |
||
118 | $actual = $config['comments_holder_id']; |
||
119 | $this->assertEquals( |
||
0 ignored issues
–
show
The method
assertEquals() does not seem to exist on object<CommentingTest> .
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...
|
|||
120 | 'test_add_value', |
||
121 | $actual |
||
122 | ); |
||
123 | |||
124 | Commenting::add('Member'); |
||
125 | |||
126 | $config = Config::inst()->get( |
||
127 | 'Member', |
||
128 | 'comments' |
||
129 | ); |
||
130 | $actual = $config['comments_holder_id']; |
||
131 | // no settings updated |
||
132 | $this->assertEquals( |
||
0 ignored issues
–
show
The method
assertEquals() does not seem to exist on object<CommentingTest> .
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...
|
|||
133 | 'test_add_value', |
||
134 | $actual |
||
135 | ); |
||
136 | |||
137 | $this->setExpectedException('InvalidArgumentException', "\$settings needs to be an array or null"); |
||
138 | Commenting::add('Member', 'illegal format, not an array'); |
||
139 | |||
140 | |||
141 | } |
||
142 | |||
143 | public function test_can_member_post() { |
||
144 | // logout |
||
145 | if($member = Member::currentUser()) $member->logOut(); |
||
146 | |||
147 | Config::inst()->update('CommentableItem', 'comments', |
||
148 | array( |
||
149 | 'require_login' => false |
||
150 | ) |
||
151 | ); |
||
152 | $this->assertTrue(Commenting::can_member_post('CommentableItem')); |
||
0 ignored issues
–
show
The method
assertTrue() does not seem to exist on object<CommentingTest> .
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...
The method
Commenting::can_member_post() has been deprecated with message: since version 2.0
This method has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.
Loading history...
|
|||
153 | |||
154 | Config::inst()->update('CommentableItem', 'comments', |
||
155 | array( |
||
156 | 'require_login' => true |
||
157 | ) |
||
158 | ); |
||
159 | $this->assertFalse(Commenting::can_member_post('CommentableItem')); |
||
160 | |||
161 | $this->logInWithPermission('CMS_ACCESS_CommentAdmin'); |
||
162 | $this->assertTrue(Commenting::can_member_post('CommentableItem')); |
||
0 ignored issues
–
show
The method
assertTrue() does not seem to exist on object<CommentingTest> .
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...
The method
Commenting::can_member_post() has been deprecated with message: since version 2.0
This method has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.
Loading history...
|
|||
163 | |||
164 | Config::inst()->update('CommentableItem', 'comments', |
||
165 | array( |
||
166 | 'require_login' => false |
||
167 | ) |
||
168 | ); |
||
169 | |||
170 | $this->assertTrue(Commenting::can_member_post('CommentableItem')); |
||
171 | } |
||
172 | |||
173 | } |
||
174 |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.