public function __construct($port, $host, $basePath) { $server = new Server($port, $host); $server->start(); $this->services['server'] = $server; $this->basePath = $basePath; }
public function testCreateTwoExpectationsAfterEachOther() { $this->builder->when()->pathIs('/post-resource-1')->methodIs('POST')->then()->statusCode(200)->body('POST 1')->end(); $this->server->setUp($this->builder->flushExpectations()); $this->builder->when()->pathIs('/post-resource-2')->methodIs($this->matches->regex('/POST/'))->then()->statusCode(200)->body('POST 2')->end(); $this->server->setUp($this->builder->flushExpectations()); $this->assertSame('POST 1', (string) $this->server->getClient()->post('/post-resource-1')->send()->getBody()); $this->assertSame('POST 2', (string) $this->server->getClient()->post('/post-resource-2')->send()->getBody()); $this->assertSame('POST 1', (string) $this->server->getClient()->post('/post-resource-1')->send()->getBody()); $this->assertSame('POST 2', (string) $this->server->getClient()->post('/post-resource-2')->send()->getBody()); }
/** * Reverts configuration done by the context. * * @AfterScenario */ public function revertConfiguration() { // Remove configuration entities. foreach ($this->configurationEntities as $configuration) { if ($configuration->entityType() == 'integration_consumer') { /** @var AbstractConsumer $consumer */ $consumer = ConsumerFactory::getInstance($configuration->getMachineName()); $consumer->processRollback(); // Remove consumer & its corresponding migration. Migration::deregisterMigration('test_consumer'); } $configuration->delete(); } if ($this->backendWasConfigured) { entity_delete('integration_backend', 'http_mock'); } if ($this->server && $this->server->isStarted()) { $this->server->stop(); } }
/** * Stops the mock HTTP server if it was started. * * @AfterScenario */ public function stopMockServer() { if ($this->server && $this->server->isStarted()) { $this->server->stop(); } }
public function setUp() { static::$server1->clean(); $this->client = static::$server1->getClient(); }
private function stopHttpMock() { echo 'Stoping http mock server' . PHP_EOL; $this->server->stop(); }