public function testPushOnline() { $data = [['instance' => $this->getControllerMock(), 'action' => 'test1'], ['instance' => $this->getControllerMock(), 'action' => 'test2']]; $newItem = ['instance' => $this->getControllerMock(), 'action' => 'newAction']; $chain = new Chain($data); foreach ($chain as $key => $controller) { if ($key == 0) { $chain->pushAfterCurrent($newItem['instance'], $newItem['action']); } elseif ($key == 1) { $this->assertEquals($newItem['instance'], $controller['instance']); $this->assertEquals($newItem['action'], $controller['action']); } } }