示例#1
0
 /**
  * @param \Illuminate\Foundation\Application  $app
  */
 protected function getEnvironmentSetUp($app)
 {
     $this->server = new Server();
     $this->server->start();
     // Setup default database to use sqlite :memory:
     $app['config']->set('database.default', 'testbench');
     $app['config']->set('database.connections.testbench', ['driver' => 'sqlite', 'database' => ':memory:', 'prefix' => '']);
     $app['config']->set('hellodialog', ['url' => $this->server->getUrl(), 'token' => 'abcdef0123456789', 'sender' => ['email' => '*****@*****.**', 'name' => 'Test'], 'default_template' => 'transactional', 'templates' => ['transactional' => ['id' => 1]], 'queue' => false]);
 }
 public function testCanHandleStaleIfError()
 {
     $server = new Server(8000);
     $server->start();
     $server->flush();
     $lm = gmdate('c', time() - 60);
     $server->enqueue(array("HTTP/1.1 200 OK\r\n" . "Date: Mon, 12 Nov 2012 03:06:37 GMT\r\n" . "Cache-Control: max-age=120, stale-if-error=1200\r\n" . "Last-Modified: {$lm}\r\n" . "Content-Length: 2\r\n\r\nhi"));
     $cache = new CachePlugin();
     $client = new Client($server->getUrl());
     $client->addSubscriber($cache);
     $this->assertEquals(200, $client->get()->send()->getStatusCode());
     $this->assertEquals(1, count($server->getReceivedRequests()));
     $this->assertEquals(200, $client->get()->send()->getStatusCode());
 }
 public function testCanHandleStaleIfErrorWhenRevalidating()
 {
     $server = new Server(8000);
     $server->start();
     $server->flush();
     $lm = gmdate('c', time() - 60);
     $server->enqueue(array("HTTP/1.1 200 OK\r\n" . "Date: {$lm}\r\n" . "Cache-Control: must-revalidate, max-age=0, stale-if-error=1200\r\n" . "Last-Modified: {$lm}\r\n" . "Content-Length: 2\r\n\r\nhi"));
     $cache = new CachePlugin();
     $client = new Client($server->getUrl());
     $client->addSubscriber($cache);
     $this->assertEquals(200, $client->get()->send()->getStatusCode());
     $this->assertEquals(1, count($server->getReceivedRequests()));
     // wait for the server to actually stop
     $server->stop();
     while ($server->isRunning()) {
         sleep(1);
     }
     $this->assertEquals(200, $client->get()->send()->getStatusCode());
 }
 protected function setUp()
 {
     $this->server = new Server();
     $this->server->start();
 }