start() public method

public start ( callable $callback = null )
$callback callable
 private function startHttpMock()
 {
     echo "Starting http mock server on {$this->config['host']}:{$this->config['port']}" . PHP_EOL;
     $this->server = new Server($this->config['port'], $this->config['host']);
     $this->server->start();
     $this->setUpDependencyInjection();
 }
 public function setUp()
 {
     $this->matches = new MatcherFactory();
     $this->builder = new MockBuilder($this->matches, new ExtractorFactory());
     $this->server = new Server(HTTP_MOCK_PORT, HTTP_MOCK_HOST);
     $this->server->start();
     $this->server->clean();
 }
 /**
  * Gets the mocked HTTP server.
  *
  * Initializes the server if it was not used before.
  * By default it responds to any POST requests to /invalidate with 200 OK,
  * additional behavior can be added in further steps.
  *
  * @return Server
  *   The mocked HTTP server.
  */
 protected function getServer()
 {
     if (!$this->server) {
         $this->server = new Server($this->mockServerPort, 'localhost');
         $this->server->start();
         // Accept any POSTS.
         $mock = new MockBuilder(new MatcherFactory(), new ExtractorFactory());
         $mock->when()->pathIs('/invalidate')->methodIs('POST')->then()->statusCode(200);
         $this->server->setUp($mock->flushExpectations());
     }
     return $this->server;
 }
示例#4
0
 public function __construct($port, $host, $basePath)
 {
     $server = new Server($port, $host);
     $server->start();
     $this->services['server'] = $server;
     $this->basePath = $basePath;
 }
 public static function setUpBeforeClass()
 {
     static::$server1 = new Server(HTTP_MOCK_PORT, HTTP_MOCK_HOST);
     static::$server1->start();
 }