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) |
|
0 ignored issues
–
show
|
|||
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
It seems like you code against a specific sub-type and not the parent class
hipanel\tests\_support\P...get\Input\TestableInput as the method withItems() does only exist in the following sub-classes of hipanel\tests\_support\P...get\Input\TestableInput : hipanel\tests\_support\Page\Widget\Input\Dropdown . Maybe you want to instanceof check for one of these explicitly?
Let’s take a look at an example: abstract class User
{
/** @return string */
abstract public function getPassword();
}
class MyUser extends User
{
public function getPassword()
{
// return something
}
public function getDisplayName()
{
// return some name.
}
}
class AuthSystem
{
public function authenticate(User $user)
{
$this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
// do something.
}
}
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
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types
inside the if block in such a case.
Loading history...
|
|||
45 | 'New', |
||
46 | 'Approved', |
||
47 | 'Rejected', |
||
48 | ]), |
||
49 | ]); |
||
50 | } |
||
51 | |||
52 | View Code Duplication | private function ensureICanSeeBulkBillSearchBox() |
|
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...
|
|||
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 |
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.