Completed
Pull Request — master (#20)
by
unknown
05:10
created

Create::createTicket()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 9.6666
c 0
b 0
f 0
cc 1
nc 1
nop 3
1
<?php
2
3
namespace hipanel\modules\ticket\tests\_support\Page\ticket;
4
5
use hipanel\tests\_support\Page\Authenticated;
6
use hipanel\tests\_support\Page\Widget\Input\Input;
7
use hipanel\tests\_support\Page\Widget\Input\Select2;
8
use yii\helpers\Url;
9
10
/**
11
 * Class Create
12
 *
13
 * @author Dmytro Naumenko <[email protected]>
14
 */
15
class Create extends Authenticated
16
{
17
    public function createTicket($subject, $message, $topic)
18
    {
19
        $I = $this->tester;
20
21
        $I->amOnPage(Url::to(['@ticket/create']));
22
23
        (new Select2($I, '#thread-topics'))->setValue($topic);
0 ignored issues
show
Documentation introduced by
$I is of type object<hipanel\tests\_support\AcceptanceTester>, but the function expects a string.

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...
Unused Code introduced by
The call to Select2::__construct() has too many arguments starting with '#thread-topics'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
Bug introduced by
The method setValue() does not seem to exist on object<hipanel\tests\_su...e\Widget\Input\Select2>.

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...
24
25
        (new Input($I, '#thread-subject'))->setValue($subject);
0 ignored issues
show
Documentation introduced by
$I is of type object<hipanel\tests\_support\AcceptanceTester>, but the function expects a string.

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...
Unused Code introduced by
The call to Input::__construct() has too many arguments starting with '#thread-subject'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
Bug introduced by
The method setValue() does not seem to exist on object<hipanel\tests\_su...age\Widget\Input\Input>.

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...
26
        (new Input($I, '#thread-message'))->setValue($message);
0 ignored issues
show
Documentation introduced by
$I is of type object<hipanel\tests\_support\AcceptanceTester>, but the function expects a string.

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...
Unused Code introduced by
The call to Input::__construct() has too many arguments starting with '#thread-message'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
Bug introduced by
The method setValue() does not seem to exist on object<hipanel\tests\_su...age\Widget\Input\Input>.

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...
27
28
        $this->seePreviewWorks($message);
29
30
        $I->click('Create ticket', '#create-thread-form');
31
        $this->seeTicketWasCreated($message, $topic);
32
33
        return $I->grabValueFrom(View::THREAD_ID_SELECTOR);
34
    }
35
36
    protected function seePreviewWorks($message)
37
    {
38
        $I = $this->tester;
39
40
        $I->click('a[href="#preview-create-thread-form"]');
41
        $I->waitForText($message, 30, '#preview-create-thread-form');
42
    }
43
44
    protected function seeTicketWasCreated($message, $topic)
45
    {
46
        $I = $this->tester;
47
48
        $I->waitForText('Ticket posted', 30);
49
        $I->seeInCurrentUrl('/ticket/view?id=');
50
        $I->see($topic);
51
        $I->see('Close ticket', 'a');
52
        $I->see($message);
53
    }
54
}
55