Conditions | 3 |
Paths | 3 |
Total Lines | 25 |
Code Lines | 16 |
Lines | 7 |
Ratio | 28 % |
Changes | 0 |
1 | <?php |
||
7 | public function testUpdate() |
||
8 | { |
||
9 | $flushedMockArray = $this->getRepositoryTest()->getFlushedMockArray(); |
||
|
|||
10 | $mockArray = $this->getRepositoryTest()->getMockArray(); |
||
11 | |||
12 | View Code Duplication | foreach ($this->getService()->getMainRepository()->createEntity()->getOnlyUpdate() as $key) { |
|
13 | if (is_bool($flushedMockArray[$key])) { |
||
14 | $flushedMockArray[$key] = !$flushedMockArray[$key]; |
||
15 | } else { |
||
16 | $flushedMockArray[$key] = $mockArray[$key]; |
||
17 | } |
||
18 | } |
||
19 | |||
20 | $entity = $this->getService() |
||
21 | ->update($flushedMockArray['id'], $flushedMockArray) |
||
22 | ->flush(); |
||
23 | |||
24 | $repository = $this->getService()->getMainRepository(); |
||
25 | |||
26 | $find = $repository->find($entity->getId()); |
||
27 | |||
28 | $this->assertInstanceOf($repository->getEntityName(), $entity); |
||
29 | $this->assertInstanceOf('\DateTime', $entity->getUpdatedAt()); |
||
30 | $this->assertEquals($entity->getId(), $find->getId()); |
||
31 | } |
||
32 | } |
||
33 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.