1 | <?php |
||
21 | trait ComponentTestHelperTrait |
||
22 | { |
||
23 | /** |
||
24 | * @var array |
||
25 | */ |
||
26 | private $outPortSockets; |
||
27 | |||
28 | /** |
||
29 | * Fake-connect socket to port. |
||
30 | * |
||
31 | * @param ComponentInterface $component |
||
32 | * @return ComponentInterface |
||
33 | */ |
||
34 | protected function connectInPorts(ComponentInterface $component) |
||
42 | |||
43 | /** |
||
44 | * Fake-connect socket to port and add a storage for later value checks. |
||
45 | * |
||
46 | * @param ComponentInterface $component |
||
47 | * @return ComponentInterface |
||
48 | */ |
||
49 | protected function connectOutPorts(ComponentInterface $component) |
||
77 | |||
78 | /** |
||
79 | * @param string $port |
||
80 | * @return array|mixed |
||
81 | */ |
||
82 | protected function getOutPortData($port = '') |
||
92 | |||
93 | /** |
||
94 | * @param string $port |
||
95 | * @return bool |
||
96 | */ |
||
97 | protected function wasCalled($port) |
||
101 | } |
||
102 |
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.