77 * For the full copyright and license information, please view the LICENSE
88 * file that was distributed with this source code.
99 */
10+ declare (strict_types=1 );
1011namespace PhpFlo \Test ;
1112
1213use PhpFlo \Common \ComponentInterface ;
@@ -31,7 +32,7 @@ trait ComponentTestHelperTrait
3132 * @param ComponentInterface $component
3233 * @return ComponentInterface
3334 */
34- protected function connectInPorts (ComponentInterface $ component )
35+ protected function connectInPorts (ComponentInterface $ component ) : ComponentInterface
3536 {
3637 foreach ($ component ->inPorts () as $ alias => $ inPort ) {
3738 $ inPort ->attach ($ this ->stub (InternalSocket::class));
@@ -46,7 +47,7 @@ protected function connectInPorts(ComponentInterface $component)
4647 * @param ComponentInterface $component
4748 * @return ComponentInterface
4849 */
49- protected function connectOutPorts (ComponentInterface $ component )
50+ protected function connectOutPorts (ComponentInterface $ component ) : ComponentInterface
5051 {
5152 $ this ->outPortSockets = [];
5253 foreach ($ component ->outPorts () as $ port ) {
@@ -61,7 +62,7 @@ protected function connectOutPorts(ComponentInterface $component)
6162 ->willReturnCallback (
6263 \Closure::bind (
6364 function ($ data ) {
64- $ this ->data = $ data ;
65+ $ this ->data [] = $ data ;
6566 },
6667 $ socket
6768 )
@@ -75,11 +76,23 @@ function ($data) {
7576 return $ component ;
7677 }
7778
79+ /**
80+ * @param ComponentInterface $component
81+ * @return ComponentInterface
82+ */
83+ public function connectPorts (ComponentInterface $ component ) : ComponentInterface
84+ {
85+ $ this ->connectInPorts ($ component );
86+ $ this ->connectOutPorts ($ component );
87+
88+ return $ component ;
89+ }
90+
7891 /**
7992 * @param string $port
8093 * @return array|mixed
8194 */
82- protected function getOutPortData ($ port = '' )
95+ protected function getOutPortData (string $ port = '' )
8396 {
8497 if ('' !== $ port ) {
8598 if (array_key_exists ($ port , $ this ->outPortSockets )) {
@@ -94,7 +107,7 @@ protected function getOutPortData($port = '')
94107 * @param string $port
95108 * @return bool
96109 */
97- protected function wasCalled ($ port )
110+ protected function wasCalled (string $ port ) : bool
98111 {
99112 return !empty ($ this ->outPortSockets [$ port ]);
100113 }
0 commit comments