These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * Finance module for HiPanel |
||
4 | * |
||
5 | * @link https://github.com/hiqdev/hipanel-module-finance |
||
6 | * @package hipanel-module-finance |
||
7 | * @license BSD-3-Clause |
||
8 | * @copyright Copyright (c) 2015-2019, HiQDev (http://hiqdev.com/) |
||
9 | */ |
||
10 | |||
11 | namespace hipanel\modules\finance\tests\acceptance\seller; |
||
12 | |||
13 | use hipanel\helpers\Url; |
||
14 | use hipanel\tests\_support\Page\IndexPage; |
||
15 | use hipanel\tests\_support\Page\Widget\Input\Dropdown; |
||
16 | use hipanel\tests\_support\Page\Widget\Input\Select2; |
||
17 | use hipanel\tests\_support\Step\Acceptance\Seller; |
||
18 | |||
19 | class HeldPaymentsCest |
||
20 | { |
||
21 | /** |
||
22 | * @var IndexPage |
||
23 | */ |
||
24 | private $index; |
||
25 | |||
26 | public function _before(Seller $I) |
||
27 | { |
||
28 | $this->index = new IndexPage($I); |
||
29 | } |
||
30 | |||
31 | View Code Duplication | public function ensureIndexPageWorks(Seller $I) |
|
32 | { |
||
33 | $I->login(); |
||
34 | $I->needPage(Url::to('@finance/held-payments')); |
||
35 | $I->see('Pending confirmation payments', 'h1'); |
||
36 | $this->ensureICanSeeAdvancedSearchBox($I); |
||
37 | $this->ensureICanSeeBulkBillSearchBox(); |
||
38 | } |
||
39 | |||
40 | private function ensureICanSeeAdvancedSearchBox(Seller $I) |
||
41 | { |
||
42 | $this->index->containsFilters([ |
||
43 | Select2::asAdvancedSearch($I,'Client'), |
||
44 | (Dropdown::asAdvancedSearch($I,'State'))->withItems([ |
||
0 ignored issues
–
show
|
|||
45 | 'New', |
||
46 | 'Approved', |
||
47 | 'Rejected', |
||
48 | ]), |
||
49 | ]); |
||
50 | } |
||
51 | |||
52 | View Code Duplication | private function ensureICanSeeBulkBillSearchBox() |
|
53 | { |
||
54 | $this->index->containsBulkButtons([ |
||
55 | 'Approve', |
||
56 | 'Reject', |
||
57 | ]); |
||
58 | $this->index->containsColumns([ |
||
59 | 'Client', |
||
60 | 'User comment', |
||
61 | 'TXN', |
||
62 | 'Description', |
||
63 | 'Amount', |
||
64 | 'Time', |
||
65 | ]); |
||
66 | } |
||
67 | } |
||
68 |
Let’s take a look at an example:
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.
Available Fixes
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the parent class: