Completed
Pull Request — master (#171)
by Corey
02:56
created

ControllerTest::testBeforeAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 2
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace common\tests\unit\components;
4
5
use Yii;
6
use common\components\Controller;
7
8
/**
9
 * Controller test
10
 */
11
12
class ControllerTest extends \Codeception\Test\Unit {
13
    use \Codeception\Specify;
14
15
    public function testActions() {
16
      $controller = new Controller('test', 'common');
0 ignored issues
show
Bug introduced by
'common' of type string is incompatible with the type yii\base\Module expected by parameter $module of common\components\Controller::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

16
      $controller = new Controller('test', /** @scrutinizer ignore-type */ 'common');
Loading history...
17
      expect('actions should return an array of action settings', $this->assertEquals([
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertEquals(arra...$controller->actions()) targeting PHPUnit\Framework\Assert::assertEquals() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
18
        'error' => [
19
          'class' => 'yii\web\ErrorAction',
20
        ],
21
        'captcha' => [
22
          'class' => 'yii\captcha\CaptchaAction',
23
        ],
24
      ], $controller->actions()));
25
    }
26
27
    public function testBeforeAction() {
28
      $controller = new Controller('test', 'common');
0 ignored issues
show
Bug introduced by
'common' of type string is incompatible with the type yii\base\Module expected by parameter $module of common\components\Controller::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

28
      $controller = new Controller('test', /** @scrutinizer ignore-type */ 'common');
Loading history...
Unused Code introduced by
The assignment to $controller is dead and can be removed.
Loading history...
29
      //$controller->getRequest()->csrfToken = $controller->getRequest()->generateCsrfToken();
30
      //expect("If CSRF token is valid and parent's beforeAction() returns true, return true", $this->assertTrue($controller->beforeAction('test')));
31
32
    }
33
}
34