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\Input; |
||
17 | use hipanel\tests\_support\Page\Widget\Input\Select2; |
||
18 | use hipanel\tests\_support\Step\Acceptance\Seller; |
||
19 | |||
20 | class SalesCest |
||
21 | { |
||
22 | /** |
||
23 | * @var IndexPage |
||
24 | */ |
||
25 | private $index; |
||
26 | |||
27 | public function _before(Seller $I) |
||
28 | { |
||
29 | $this->index = new IndexPage($I); |
||
30 | } |
||
31 | |||
32 | View Code Duplication | public function ensureIndexPageWorks(Seller $I) |
|
33 | { |
||
34 | $I->login(); |
||
35 | $I->needPage(Url::to('@sale')); |
||
36 | $I->see('Sales', 'h1'); |
||
37 | $this->ensureICanSeeAdvancedSearchBox($I); |
||
38 | $this->ensureICanSeeBulkBillSearchBox(); |
||
39 | } |
||
40 | |||
41 | private function ensureICanSeeAdvancedSearchBox(Seller $I) |
||
42 | { |
||
43 | $this->index->containsFilters([ |
||
44 | Select2::asAdvancedSearch($I, 'Seller'), |
||
45 | Select2::asAdvancedSearch($I, 'Buyer'), |
||
46 | (Dropdown::asAdvancedSearch($I,'Object type'))->withItems([ |
||
0 ignored issues
–
show
|
|||
47 | 'Servers', |
||
48 | 'IP', |
||
49 | 'Accounts', |
||
50 | 'Clients', |
||
51 | 'Parts', |
||
52 | ]), |
||
53 | Select2::asAdvancedSearch($I, 'Tariff'), |
||
54 | Input::asAdvancedSearch($I, 'Object'), |
||
55 | ]); |
||
56 | } |
||
57 | |||
58 | private function ensureICanSeeBulkBillSearchBox() |
||
59 | { |
||
60 | $this->index->containsBulkButtons([ |
||
61 | 'Delete', |
||
62 | ]); |
||
63 | $this->index->containsColumns([ |
||
64 | 'Object', |
||
65 | 'Seller', |
||
66 | 'Buyer', |
||
67 | 'Tariff', |
||
68 | 'Time', |
||
69 | ]); |
||
70 | } |
||
71 | } |
||
72 |
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: