Conditions | 1 |
Paths | 1 |
Total Lines | 66 |
Code Lines | 46 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
40 | public function testGetMostRecentActionForUser() |
||
41 | { |
||
42 | // Single, AssignUsersToWorkflowAction in "History" |
||
43 | $history01 = $this->objFromFixture(WorkflowInstance::class, 'WorkflowInstance01'); |
||
44 | $mostRecentActionForUser01 = $history01->getMostRecentActionForUser($this->currentMember); |
||
45 | $this->assertInstanceOf( |
||
46 | WorkflowActionInstance::class, |
||
47 | $mostRecentActionForUser01, |
||
48 | 'Asserts the correct ClassName is retured #1' |
||
49 | ); |
||
50 | $this->assertEquals( |
||
51 | 'Assign', |
||
52 | $mostRecentActionForUser01->BaseAction()->Title, |
||
53 | 'Asserts the correct BaseAction is retured #1' |
||
54 | ); |
||
55 | |||
56 | // No AssignUsersToWorkflowAction found with Member's related Group in "History" |
||
57 | $history02 = $this->objFromFixture(WorkflowInstance::class, 'WorkflowInstance02'); |
||
58 | $mostRecentActionForUser02 = $history02->getMostRecentActionForUser($this->currentMember); |
||
59 | $this->assertFalse( |
||
60 | $mostRecentActionForUser02, |
||
61 | 'Asserts false is returned because no WorkflowActionInstance was found' |
||
62 | ); |
||
63 | |||
64 | // Multiple AssignUsersToWorkflowAction in "History", only one with Group relations |
||
65 | $history03 = $this->objFromFixture(WorkflowInstance::class, 'WorkflowInstance03'); |
||
66 | $mostRecentActionForUser03 = $history03->getMostRecentActionForUser($this->currentMember); |
||
67 | $this->assertInstanceOf( |
||
68 | WorkflowActionInstance::class, |
||
69 | $mostRecentActionForUser03, |
||
70 | 'Asserts the correct ClassName is retured #2' |
||
71 | ); |
||
72 | $this->assertEquals( |
||
73 | 'Assign', |
||
74 | $mostRecentActionForUser03->BaseAction()->Title, |
||
75 | 'Asserts the correct BaseAction is retured #2' |
||
76 | ); |
||
77 | |||
78 | // Multiple AssignUsersToWorkflowAction in "History", both with Group relations |
||
79 | $history04 = $this->objFromFixture(WorkflowInstance::class, 'WorkflowInstance04'); |
||
80 | $mostRecentActionForUser04 = $history04->getMostRecentActionForUser($this->currentMember); |
||
81 | $this->assertInstanceOf( |
||
82 | WorkflowActionInstance::class, |
||
83 | $mostRecentActionForUser04, |
||
84 | 'Asserts the correct ClassName is retured #3' |
||
85 | ); |
||
86 | $this->assertEquals( |
||
87 | 'Assigned Again', |
||
88 | $mostRecentActionForUser04->BaseAction()->Title, |
||
89 | 'Asserts the correct BaseAction is retured #3' |
||
90 | ); |
||
91 | |||
92 | // Multiple AssignUsersToWorkflowAction in "History", one with Group relations |
||
93 | $history05 = $this->objFromFixture(WorkflowInstance::class, 'WorkflowInstance05'); |
||
94 | $mostRecentActionForUser05 = $history05->getMostRecentActionForUser($this->currentMember); |
||
95 | $this->assertInstanceOf( |
||
96 | WorkflowActionInstance::class, |
||
97 | $mostRecentActionForUser05, |
||
98 | 'Asserts the correct ClassName is retured #4' |
||
99 | ); |
||
100 | $this->assertEquals( |
||
101 | 'Assigned Me', |
||
102 | $mostRecentActionForUser05->BaseAction()->Title, |
||
103 | 'Asserts the correct BaseAction is retured #4' |
||
104 | ); |
||
105 | } |
||
106 | |||
160 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.