fwolf /
fwlib
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | namespace FwlibTest\Html\ListView; |
||
| 3 | |||
| 4 | use Fwlib\Html\ListView\ListDto; |
||
| 5 | use Fwlib\Html\ListView\Renderer; |
||
| 6 | use Fwlib\Html\ListView\Request; |
||
| 7 | use Fwlib\Html\ListView\RequestInterface; |
||
| 8 | use Fwolf\Wrapper\PHPUnit\PHPUnitTestCase; |
||
| 9 | use PHPUnit_Framework_MockObject_MockObject as MockObject; |
||
| 10 | |||
| 11 | /** |
||
| 12 | * @SuppressWarnings(PHPMD.TooManyMethods) |
||
| 13 | * |
||
| 14 | * @copyright Copyright 2015 Fwolf |
||
| 15 | * @license http://www.gnu.org/licenses/lgpl.html LGPL-3.0+ |
||
| 16 | */ |
||
| 17 | class RendererTest extends PHPUnitTestCase |
||
| 18 | { |
||
| 19 | /** |
||
| 20 | * @param string[] $methods |
||
| 21 | * @return MockObject | Renderer |
||
| 22 | */ |
||
| 23 | protected function buildMock(array $methods = null) |
||
| 24 | { |
||
| 25 | $mock = $this->getMock( |
||
| 26 | Renderer::class, |
||
| 27 | $methods |
||
| 28 | ); |
||
| 29 | |||
| 30 | /** @var Renderer $mock */ |
||
| 31 | $mock->setClass('listTable') |
||
| 32 | ->setId(1); |
||
| 33 | |||
| 34 | return $mock; |
||
| 35 | } |
||
| 36 | |||
| 37 | |||
| 38 | View Code Duplication | public function testAddOrderByLink() |
|
|
0 ignored issues
–
show
|
|||
| 39 | { |
||
| 40 | $renderer = $this->buildMock(); |
||
| 41 | |||
| 42 | /** @var MockObject|Request $request */ |
||
| 43 | $request = $this->getMock(Request::class, ['getBaseUrl']); |
||
| 44 | $request->expects($this->any()) |
||
|
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Fwlib\Html\ListView\Request.
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
| 45 | ->method('getBaseUrl') |
||
| 46 | ->willReturn('http://domain.tld/'); |
||
| 47 | $request->setOrderByParameter('ob') |
||
|
0 ignored issues
–
show
The method
setOrderByParameter does only exist in Fwlib\Html\ListView\Request, but not in PHPUnit_Framework_MockObject_MockObject.
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
| 48 | ->setOrderByDirectionParameter('od'); |
||
| 49 | $renderer->setRequest($request); |
||
| 50 | |||
| 51 | $this->assertEquals( |
||
| 52 | "<a href='http://domain.tld/?ob=foo&od=DESC'>head(asc)</a>", |
||
| 53 | $this->reflectionCall( |
||
| 54 | $renderer, |
||
| 55 | 'addOrderByLink', |
||
| 56 | ['foo', 'head(asc)', 'ASC'] |
||
| 57 | ) |
||
| 58 | ); |
||
| 59 | } |
||
| 60 | |||
| 61 | |||
| 62 | public function testAddOrderByText() |
||
| 63 | { |
||
| 64 | $renderer = $this->buildMock(); |
||
| 65 | $renderer->setConfig('orderByTextAsc', '[Ascending]'); |
||
| 66 | |||
| 67 | $this->assertEquals( |
||
| 68 | 'head[Ascending]', |
||
| 69 | $this->reflectionCall($renderer, 'addOrderByText', ['head', 'ASC']) |
||
| 70 | ); |
||
| 71 | } |
||
| 72 | |||
| 73 | |||
| 74 | public function testGetHtml() |
||
| 75 | { |
||
| 76 | /** @var MockObject|Renderer $renderer */ |
||
| 77 | $renderer = $this->getMock( |
||
| 78 | Renderer::class, |
||
| 79 | ['getListTable', 'getPager', 'getJs'] |
||
| 80 | ); |
||
| 81 | |||
| 82 | $renderer->expects($this->any()) |
||
|
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Fwlib\Html\ListView\Renderer.
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
| 83 | ->method('getListTable') |
||
| 84 | ->willReturn('<!-- table -->'); |
||
| 85 | |||
| 86 | $renderer->expects($this->any()) |
||
| 87 | ->method('getPager') |
||
| 88 | ->willReturnOnConsecutiveCalls( |
||
| 89 | '<!-- top pager -->', |
||
| 90 | '<!-- bottom pager -->' |
||
| 91 | ); |
||
| 92 | |||
| 93 | $renderer->expects($this->any()) |
||
| 94 | ->method('getJs') |
||
| 95 | ->willReturn('<!-- js -->'); |
||
| 96 | |||
| 97 | $renderer->setClass('listTable')->setId(1); |
||
|
0 ignored issues
–
show
The method
setClass does only exist in Fwlib\Html\ListView\Renderer, but not in PHPUnit_Framework_MockObject_MockObject.
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
| 98 | |||
| 99 | $renderer->setPreContent('<!-- pre content -->'); |
||
|
0 ignored issues
–
show
The method
setPreContent does only exist in Fwlib\Html\ListView\Renderer, but not in PHPUnit_Framework_MockObject_MockObject.
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
| 100 | $renderer->setPostContent('<!-- post content -->'); |
||
|
0 ignored issues
–
show
The method
setPostContent does only exist in Fwlib\Html\ListView\Renderer, but not in PHPUnit_Framework_MockObject_MockObject.
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
| 101 | $renderer->setConfig('showTopPager', true); |
||
|
0 ignored issues
–
show
The method
setConfig does only exist in Fwlib\Html\ListView\Renderer, but not in PHPUnit_Framework_MockObject_MockObject.
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
| 102 | $renderer->setConfig('showBottomPager', true); |
||
| 103 | |||
| 104 | $html = "<!-- pre content --> |
||
| 105 | |||
| 106 | <div class='listTable' id='listTable-1'> |
||
| 107 | |||
| 108 | <!-- top pager --> |
||
| 109 | |||
| 110 | <!-- table --> |
||
| 111 | |||
| 112 | <!-- bottom pager --> |
||
| 113 | |||
| 114 | </div> |
||
| 115 | |||
| 116 | <!-- js --> |
||
| 117 | |||
| 118 | <!-- post content -->"; |
||
| 119 | $this->assertEquals($html, $renderer->getHtml()); |
||
|
0 ignored issues
–
show
The method
getHtml does only exist in Fwlib\Html\ListView\Renderer, but not in PHPUnit_Framework_MockObject_MockObject.
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
| 120 | } |
||
| 121 | |||
| 122 | |||
| 123 | public function testGetJs() |
||
| 124 | { |
||
| 125 | $renderer = $this->buildMock(); |
||
| 126 | $renderer->setClass('list-view') |
||
| 127 | ->setId(42) |
||
| 128 | ->setConfig('pageNumberInputFocusSelect', true); |
||
| 129 | |||
| 130 | /** @var MockObject|RequestInterface $request */ |
||
| 131 | $request = $this->getMock(Request::class, ['getPageParameter']); |
||
| 132 | $request->expects($this->any()) |
||
|
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Fwlib\Html\ListView\RequestInterface.
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
| 133 | ->method('getPageParameter') |
||
| 134 | ->willReturn('pageNumber'); |
||
| 135 | $renderer->setRequest($request); |
||
| 136 | |||
| 137 | $html = " |
||
| 138 | <script type='text/javascript'> |
||
| 139 | (function() { |
||
| 140 | |||
| 141 | $('#list-view-42').find('input[name=pageNumber]').on('mouseover', function() { |
||
| 142 | this.select(); |
||
| 143 | }); |
||
| 144 | |||
| 145 | }) (); |
||
| 146 | </script> |
||
| 147 | "; |
||
| 148 | $this->assertEquals($html, $this->reflectionCall($renderer, 'getJs')); |
||
| 149 | } |
||
| 150 | |||
| 151 | |||
| 152 | public function testGetListBody() |
||
| 153 | { |
||
| 154 | $renderer = $this->buildMock(); |
||
| 155 | |||
| 156 | $renderer->setConfig('trAppend', [1 => "dir='ltr'"]); |
||
| 157 | $renderer->setConfig('tdAppend', ['foo' => 'nowrap']); |
||
| 158 | |||
| 159 | $listDto = (new ListDto())->setBody([ |
||
|
0 ignored issues
–
show
array(array('dummy' => '...oo3', 'bar' => 'Bar3')) is of type array<integer,array<stri...\"bar\":\"string\"}>"}>, but the function expects a array<integer,object<array>>.
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
| 160 | [ |
||
| 161 | 'dummy' => 'Dummy1', |
||
| 162 | 'foo' => 'Foo1', |
||
| 163 | 'bar' => 'Bar1', |
||
| 164 | ], |
||
| 165 | [ |
||
| 166 | 'dummy' => 'Dummy2', |
||
| 167 | 'foo' => 'Foo2', |
||
| 168 | 'bar' => 'Bar2', |
||
| 169 | ], |
||
| 170 | [ |
||
| 171 | 'dummy' => 'Dummy3', |
||
| 172 | 'foo' => 'Foo3', |
||
| 173 | 'bar' => 'Bar3', |
||
| 174 | ], |
||
| 175 | ]); |
||
| 176 | $renderer->setListDto($listDto); |
||
| 177 | |||
| 178 | $html = "<tbody> |
||
| 179 | <tr class='listTable__body__tr'> |
||
| 180 | <td class='listTable__td__dummy' id='listTable-1__td__dummy--0'> |
||
| 181 | Dummy1 |
||
| 182 | </td> |
||
| 183 | <td class='listTable__td__foo' id='listTable-1__td__foo--0' nowrap> |
||
| 184 | Foo1 |
||
| 185 | </td> |
||
| 186 | <td class='listTable__td__bar' id='listTable-1__td__bar--0'> |
||
| 187 | Bar1 |
||
| 188 | </td> |
||
| 189 | </tr> |
||
| 190 | <tr class='listTable__body__tr' dir='ltr'> |
||
| 191 | <td class='listTable__td__dummy' id='listTable-1__td__dummy--1'> |
||
| 192 | Dummy2 |
||
| 193 | </td> |
||
| 194 | <td class='listTable__td__foo' id='listTable-1__td__foo--1' nowrap> |
||
| 195 | Foo2 |
||
| 196 | </td> |
||
| 197 | <td class='listTable__td__bar' id='listTable-1__td__bar--1'> |
||
| 198 | Bar2 |
||
| 199 | </td> |
||
| 200 | </tr> |
||
| 201 | <tr class='listTable__body__tr'> |
||
| 202 | <td class='listTable__td__dummy' id='listTable-1__td__dummy--2'> |
||
| 203 | Dummy3 |
||
| 204 | </td> |
||
| 205 | <td class='listTable__td__foo' id='listTable-1__td__foo--2' nowrap> |
||
| 206 | Foo3 |
||
| 207 | </td> |
||
| 208 | <td class='listTable__td__bar' id='listTable-1__td__bar--2'> |
||
| 209 | Bar3 |
||
| 210 | </td> |
||
| 211 | </tr> |
||
| 212 | </tbody>"; |
||
| 213 | $this->assertEquals( |
||
| 214 | $html, |
||
| 215 | $this->reflectionCall($renderer, 'getListBody') |
||
| 216 | ); |
||
| 217 | } |
||
| 218 | |||
| 219 | |||
| 220 | public function testGetListHead() |
||
| 221 | { |
||
| 222 | $renderer = $this->buildMock(); |
||
| 223 | $renderer->setConfig('thAppend', ['foo' => 'nowrap']); |
||
| 224 | |||
| 225 | /** @var MockObject|Request $request */ |
||
| 226 | $request = $this->getMock(Request::class, []); |
||
| 227 | $renderer->setRequest($request); |
||
| 228 | |||
| 229 | $listDto = (new ListDto())->setHead([ |
||
| 230 | 'dummy' => 'Dummy', |
||
| 231 | 'foo' => 'Foo', |
||
| 232 | 'bar' => 'Bar', |
||
| 233 | ]); |
||
| 234 | $renderer->setListDto($listDto); |
||
| 235 | |||
| 236 | $html = "<thead> |
||
| 237 | <tr class='listTable__head__tr'> |
||
| 238 | <th id='listTable-1__th__dummy'>Dummy</th> |
||
| 239 | <th id='listTable-1__th__foo' nowrap>Foo</th> |
||
| 240 | <th id='listTable-1__th__bar'>Bar</th> |
||
| 241 | </tr> |
||
| 242 | </thead>"; |
||
| 243 | $this->assertEquals( |
||
| 244 | $html, |
||
| 245 | $this->reflectionCall($renderer, 'getListHead') |
||
| 246 | ); |
||
| 247 | } |
||
| 248 | |||
| 249 | |||
| 250 | public function testGetListHeadText() |
||
| 251 | { |
||
| 252 | $renderer = $this->buildMock(); |
||
| 253 | $renderer->setConfig('orderByTextAsc', '[Asc]'); |
||
| 254 | |||
| 255 | /** @var MockObject|Request $request */ |
||
| 256 | $request = $this->getMock(Request::class, ['getBaseUrl', 'getOrderBy']); |
||
| 257 | |||
| 258 | $request->expects($this->any()) |
||
|
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Fwlib\Html\ListView\Request.
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
| 259 | ->method('getBaseUrl') |
||
| 260 | ->willReturn('http://domain.tld/'); |
||
| 261 | |||
| 262 | $request->expects($this->any()) |
||
| 263 | ->method('getOrderBy') |
||
| 264 | ->willReturnOnConsecutiveCalls(null, ['foo' => 'asc']); |
||
| 265 | |||
| 266 | $request->setOrderByParameter('ob') |
||
|
0 ignored issues
–
show
The method
setOrderByParameter does only exist in Fwlib\Html\ListView\Request, but not in PHPUnit_Framework_MockObject_MockObject.
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
| 267 | ->setOrderByDirectionParameter('od'); |
||
| 268 | $renderer->setRequest($request); |
||
| 269 | |||
| 270 | |||
| 271 | // Empty order by |
||
| 272 | $this->assertEquals( |
||
| 273 | "head", |
||
| 274 | $this->reflectionCall($renderer, 'getListHeadText', ['foo', 'head']) |
||
| 275 | ); |
||
| 276 | |||
| 277 | $this->assertEquals( |
||
| 278 | "<a href='http://domain.tld/?ob=foo&od=DESC'>head[Asc]</a>", |
||
| 279 | $this->reflectionCall($renderer, 'getListHeadText', ['foo', 'head']) |
||
| 280 | ); |
||
| 281 | } |
||
| 282 | |||
| 283 | |||
| 284 | View Code Duplication | public function testGetListTable() |
|
|
0 ignored issues
–
show
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...
|
|||
| 285 | { |
||
| 286 | /** @var MockObject|Renderer $renderer */ |
||
| 287 | $renderer = $this->getMock( |
||
| 288 | Renderer::class, |
||
| 289 | ['getListHead', 'getListBody'] |
||
| 290 | ); |
||
| 291 | |||
| 292 | $renderer->expects($this->any()) |
||
|
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Fwlib\Html\ListView\Renderer.
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
| 293 | ->method('getListHead') |
||
| 294 | ->willReturn("<thead>\n</thead>"); |
||
| 295 | |||
| 296 | $renderer->expects($this->any()) |
||
| 297 | ->method('getListBody') |
||
| 298 | ->willReturn("<tbody>\n</tbody>"); |
||
| 299 | |||
| 300 | $renderer->setClass('listTable')->setId(1); |
||
|
0 ignored issues
–
show
The method
setClass does only exist in Fwlib\Html\ListView\Renderer, but not in PHPUnit_Framework_MockObject_MockObject.
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
| 301 | |||
| 302 | $html = "<table class='listTable__table' id='listTable-1__table'> |
||
| 303 | <thead> |
||
| 304 | </thead> |
||
| 305 | |||
| 306 | <tbody> |
||
| 307 | </tbody> |
||
| 308 | </table>"; |
||
| 309 | $this->assertEquals( |
||
| 310 | $html, |
||
| 311 | $this->reflectionCall($renderer, 'getListTable') |
||
| 312 | ); |
||
| 313 | } |
||
| 314 | |||
| 315 | |||
| 316 | public function testGetPager() |
||
| 317 | { |
||
| 318 | /** @var MockObject|Renderer $renderer */ |
||
| 319 | $renderer = $this->getMock( |
||
| 320 | Renderer::class, |
||
| 321 | ['getSafePage', 'getSafePageSize'] |
||
| 322 | ); |
||
| 323 | $renderer->expects($this->any()) |
||
|
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Fwlib\Html\ListView\Renderer.
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
| 324 | ->method('getSafePage') |
||
| 325 | ->willReturn(2); |
||
| 326 | $renderer->expects($this->any()) |
||
| 327 | ->method('getSafePageSize') |
||
| 328 | ->willReturn(10); |
||
| 329 | |||
| 330 | $renderer->setClass('listTable')->setId(1); |
||
|
0 ignored issues
–
show
The method
setClass does only exist in Fwlib\Html\ListView\Renderer, but not in PHPUnit_Framework_MockObject_MockObject.
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
| 331 | |||
| 332 | /** @var MockObject|RequestInterface $request */ |
||
| 333 | $request = $this->getMock(Request::class, ['getBaseUrl']); |
||
| 334 | $request->expects($this->once()) |
||
|
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Fwlib\Html\ListView\RequestInterface.
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
| 335 | ->method('getBaseUrl') |
||
| 336 | ->willReturn('http://domain.tld/?foo=1&Bar=2'); |
||
| 337 | $renderer->setRequest($request); |
||
|
0 ignored issues
–
show
The method
setRequest does only exist in Fwlib\Html\ListView\Renderer, but not in PHPUnit_Framework_MockObject_MockObject.
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
| 338 | |||
| 339 | $listDto = new ListDto; |
||
| 340 | $listDto->setRowCount(42); |
||
| 341 | $renderer->setListDto($listDto); |
||
|
0 ignored issues
–
show
The method
setListDto does only exist in Fwlib\Html\ListView\Renderer, but not in PHPUnit_Framework_MockObject_MockObject.
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
| 342 | |||
| 343 | $html = "<div class='listTable__pager' id='listTable-1__pager--top'> |
||
| 344 | <a href='http://domain.tld/?foo=1&Bar=2&p=1'>首页</a> | " . " |
||
| 345 | <a href='http://domain.tld/?foo=1&Bar=2&p=1'>上一页</a> | " . " |
||
| 346 | <a href='http://domain.tld/?foo=1&Bar=2&p=3'>下一页</a> | " . " |
||
| 347 | <a href='http://domain.tld/?foo=1&Bar=2&p=5'>尾页</a> | " . " |
||
| 348 | 共42条信息,每页显示10条,当前为第2/5页 | " . " |
||
| 349 | 转到第 |
||
| 350 | <form method='get' action='http://domain.tld/'> |
||
| 351 | <input type='hidden' name='foo' value='1' /> |
||
| 352 | <input type='hidden' name='Bar' value='2' /> |
||
| 353 | <input type='text' name='p' value='2' size='1' /> |
||
| 354 | 页 |
||
| 355 | <input type='submit' value='转' /> |
||
| 356 | </form> |
||
| 357 | </div>"; |
||
| 358 | $this->assertEquals( |
||
| 359 | $html, |
||
| 360 | $this->reflectionCall($renderer, 'getPager', ['top']) |
||
| 361 | ); |
||
| 362 | } |
||
| 363 | |||
| 364 | |||
| 365 | public function testGetPagerJumpFormWithEmptyUrl() |
||
| 366 | { |
||
| 367 | $renderer = $this->buildMock(); |
||
| 368 | |||
| 369 | $html = "转到第 |
||
| 370 | <form method='get' action=''> |
||
| 371 | <input type='text' name='p' value='1' size='1' /> |
||
| 372 | 页 |
||
| 373 | <input type='submit' value='转' /> |
||
| 374 | </form>"; |
||
| 375 | $this->assertEquals( |
||
| 376 | $html, |
||
| 377 | $this->reflectionCall( |
||
| 378 | $renderer, |
||
| 379 | 'getPagerJumpForm', |
||
| 380 | ['', 1, 5, 'p'] |
||
| 381 | ) |
||
| 382 | ); |
||
| 383 | } |
||
| 384 | |||
| 385 | |||
| 386 | View Code Duplication | public function testGetSafePage() |
|
|
0 ignored issues
–
show
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...
|
|||
| 387 | { |
||
| 388 | $renderer = $this->buildMock(); |
||
| 389 | |||
| 390 | /** @var MockObject|RequestInterface $request */ |
||
| 391 | $request = $this->getMock(Request::class, ['getPage']); |
||
| 392 | $request->expects($this->any()) |
||
|
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Fwlib\Html\ListView\RequestInterface.
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
| 393 | ->method('getPage') |
||
| 394 | ->willReturn(3); |
||
| 395 | $renderer->setRequest($request); |
||
| 396 | |||
| 397 | // In max page |
||
| 398 | $this->assertEquals( |
||
| 399 | 3, |
||
| 400 | $this->reflectionCall($renderer, 'getSafePage', ['3']) |
||
| 401 | ); |
||
| 402 | |||
| 403 | // Exceed max page |
||
| 404 | $this->assertEquals( |
||
| 405 | 2, |
||
| 406 | $this->reflectionCall($renderer, 'getSafePage', ['2']) |
||
| 407 | ); |
||
| 408 | } |
||
| 409 | } |
||
| 410 |
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.