Created
February 26, 2012 22:39
-
-
Save beberlei/1919413 to your computer and use it in GitHub Desktop.
REST Workflows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Beberlei\WorkflowBundle\Tests\EndToEnd; | |
use Beberlei\WorkflowBundle\Tests\ControllerTestCase; | |
class WorkflowActivityExecutionTest extends ControllerTestCase | |
{ | |
public function testScenario() | |
{ | |
$activity = <<<XML | |
<activity name="PingWhitewashing"> | |
<method>GET</method> | |
<uri>http://www.whitewashing.de/{foo}</uri> | |
<results> | |
<result name="code" path="response.statusCode" /> | |
</results> | |
</activity> | |
XML; | |
$this->client->request('PUT', '/activity/PingWhitewashing', array('payload' => $activity)); | |
$this->assertEquals(201, $this->client->getResponse()->getStatusCode()); | |
$xml = <<<XML | |
<workflow name="test"> | |
<node id="1" type="Start"> | |
<outNode id="3" /> | |
</node> | |
<node id="2" type="End" /> | |
<node id="3" type="Activity" activity="PingWhitewashing"> | |
<outNode id="2" /> | |
</node> | |
</workflow> | |
XML; | |
$this->client->request('PUT', '/workflow/test', array('payload' => $xml)); | |
$this->assertEquals(201, $this->client->getResponse()->getStatusCode()); | |
$this->client->request('POST', '/workflow/test/start', array('foo' => '')); | |
$this->assertEquals(201, $this->client->getResponse()->getStatusCode()); | |
$location = $this->client->getResponse()->headers->get('Location'); | |
$this->client->request('GET', $location); | |
$this->assertEquals(200, $this->client->getResponse()->getStatusCode()); | |
$content = $this->client->getResponse()->getcontent(); | |
$this->assertXpathMatchString($content, "200", 'string(/execution/variables/variable[@name="code"]/@value)'); | |
$this->assertXpathMatchString($content, 'end', 'string(/execution/status)'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment