function testPerformOk() { $response =& new MockHttpResponse($this); $toolkit =& new MockLimbToolkit($this); $toolkit->setReturnReference('getResponse', $response); Limb :: registerToolkit($toolkit); $command = new RedirectCommand($path = '/somewhere'); $response->expectOnce('redirect', array($path)); $this->assertEqual($command->perform(), LIMB_STATUS_OK); $response->tally(); Limb :: restoreToolkit(); }
function perform() { if (!is_a($this->service_node, 'ServiceNode')) { return LIMB_STATUS_ERROR; } $toolkit =& Limb::toolkit(); $uow =& $toolkit->getUOW(); $node =& $this->service_node->getNodePart(); $path2id_translator =& $toolkit->getPath2IdTranslator(); if ($uow->isDeleted($this->service_node)) { $path = $path2id_translator->getPathToNode($node->get('parent_id')); } elseif ($id = $node->get('id')) { $path = $path2id_translator->getPathToNode($node->get('id')); } else { $path = $path2id_translator->getPathToNode($node->get('parent_id')); } $redirect_command = new RedirectCommand($path); return $redirect_command->perform(); }