Apply fixes from StyleCI

This commit is contained in:
Marcel Pociot
2020-06-17 10:35:07 +00:00
committed by StyleCI Bot
parent 0e33bc7d99
commit 83676deddb
56 changed files with 189 additions and 316 deletions

View File

@@ -9,14 +9,11 @@ use App\Logger\RequestLogger;
use Clue\React\Buzz\Browser;
use Clue\React\Buzz\Message\ResponseException;
use GuzzleHttp\Psr7\Request;
use function GuzzleHttp\Psr7\str;
use Mockery as m;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use React\EventLoop\LoopInterface;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Output\ConsoleOutputInterface;
use Tests\Feature\TestCase;
use function GuzzleHttp\Psr7\str;
class DashboardTest extends TestCase
{
@@ -59,7 +56,7 @@ class DashboardTest extends TestCase
public function it_can_replay_requests()
{
$request = new Request('GET', '/example', [
'X-Expose-Request-ID' => 'request-one'
'X-Expose-Request-ID' => 'request-one',
]);
$httpClient = m::mock(HttpClient::class);
@@ -74,7 +71,7 @@ class DashboardTest extends TestCase
$this->logRequest($request);
$this->assertSame(200,
$this->await($this->browser->get("http://127.0.0.1:4040/api/replay/request-one"))
$this->await($this->browser->get('http://127.0.0.1:4040/api/replay/request-one'))
->getStatusCode()
);
}
@@ -87,7 +84,7 @@ class DashboardTest extends TestCase
$this->expectException(ResponseException::class);
$this->expectExceptionMessage(404);
$this->await($this->browser->get("http://127.0.0.1:4040/api/replay/invalid-request"));
$this->await($this->browser->get('http://127.0.0.1:4040/api/replay/invalid-request'));
}
/** @test */
@@ -101,7 +98,7 @@ class DashboardTest extends TestCase
$this->assertCount(3, $this->requestLogger->getData());
$this->await($this->browser->get("http://127.0.0.1:4040/api/logs/clear"));
$this->await($this->browser->get('http://127.0.0.1:4040/api/logs/clear'));
$this->assertCount(0, $this->requestLogger->getData());
}
@@ -113,15 +110,15 @@ class DashboardTest extends TestCase
$loggedRequest = $this->logRequest(new Request('GET', '/foo'));
$this->await($this->browser->post("http://127.0.0.1:4040/api/logs/{$loggedRequest->id()}/data", [
'Content-Type' => 'application/json'
'Content-Type' => 'application/json',
], json_encode([
'data' => [
'foo' => 'bar',
]
],
])));
$this->assertSame([
'foo' => 'bar'
'foo' => 'bar',
], $this->requestLogger->findLoggedRequest($loggedRequest->id())->getAdditionalData());
}

View File

@@ -3,7 +3,6 @@
namespace Tests\Feature\Server;
use App\Contracts\ConnectionManager;
use App\Http\Server;
use App\Server\Factory;
use Clue\React\Buzz\Browser;
use Clue\React\Buzz\Message\ResponseException;
@@ -11,7 +10,6 @@ use GuzzleHttp\Psr7\Response;
use Illuminate\Support\Str;
use Psr\Http\Message\ResponseInterface;
use Ratchet\Server\IoConnection;
use React\Socket\Connector;
use Tests\Feature\TestCase;
class AdminTest extends TestCase
@@ -19,7 +17,7 @@ class AdminTest extends TestCase
/** @var Browser */
protected $browser;
/** @var Factory */
/** @var Factory */
protected $serverFactory;
public function setUp(): void
@@ -49,7 +47,7 @@ class AdminTest extends TestCase
/** @var ResponseInterface $response */
$this->await($this->browser->get('http://127.0.0.1:8080', [
'Host' => 'expose.localhost'
'Host' => 'expose.localhost',
]));
}
@@ -59,7 +57,7 @@ class AdminTest extends TestCase
/** @var ResponseInterface $response */
$response = $this->await($this->browser->get('http://127.0.0.1:8080/', [
'Host' => 'expose.localhost',
'Authorization' => base64_encode("username:secret"),
'Authorization' => base64_encode('username:secret'),
]));
$this->assertSame(301, $response->getStatusCode());
}
@@ -72,8 +70,8 @@ class AdminTest extends TestCase
/** @var ResponseInterface $response */
$this->await($this->browser->post('http://127.0.0.1:8080/api/settings', [
'Host' => 'expose.localhost',
'Authorization' => base64_encode("username:secret"),
'Content-Type' => 'application/json'
'Authorization' => base64_encode('username:secret'),
'Content-Type' => 'application/json',
], json_encode([
'validate_auth_tokens' => true,
])));
@@ -87,8 +85,8 @@ class AdminTest extends TestCase
/** @var Response $response */
$response = $this->await($this->browser->post('http://127.0.0.1:8080/api/users', [
'Host' => 'expose.localhost',
'Authorization' => base64_encode("username:secret"),
'Content-Type' => 'application/json'
'Authorization' => base64_encode('username:secret'),
'Content-Type' => 'application/json',
], json_encode([
'name' => 'Marcel',
])));
@@ -105,17 +103,16 @@ class AdminTest extends TestCase
/** @var Response $response */
$this->await($this->browser->post('http://127.0.0.1:8080/api/users', [
'Host' => 'expose.localhost',
'Authorization' => base64_encode("username:secret"),
'Content-Type' => 'application/json'
'Authorization' => base64_encode('username:secret'),
'Content-Type' => 'application/json',
], json_encode([
'name' => 'Marcel',
])));
$this->await($this->browser->delete('http://127.0.0.1:8080/api/users/1', [
'Host' => 'expose.localhost',
'Authorization' => base64_encode("username:secret"),
'Content-Type' => 'application/json'
'Authorization' => base64_encode('username:secret'),
'Content-Type' => 'application/json',
]));
$this->assertDatabaseHasNoResults('SELECT * FROM users WHERE name = "Marcel"');
@@ -127,8 +124,8 @@ class AdminTest extends TestCase
/** @var Response $response */
$this->await($this->browser->post('http://127.0.0.1:8080/api/users', [
'Host' => 'expose.localhost',
'Authorization' => base64_encode("username:secret"),
'Content-Type' => 'application/json'
'Authorization' => base64_encode('username:secret'),
'Content-Type' => 'application/json',
], json_encode([
'name' => 'Marcel',
])));
@@ -136,8 +133,8 @@ class AdminTest extends TestCase
/** @var Response $response */
$response = $this->await($this->browser->get('http://127.0.0.1:8080/users', [
'Host' => 'expose.localhost',
'Authorization' => base64_encode("username:secret"),
'Content-Type' => 'application/json'
'Authorization' => base64_encode('username:secret'),
'Content-Type' => 'application/json',
]));
$body = $response->getBody()->getContents();
@@ -157,8 +154,8 @@ class AdminTest extends TestCase
/** @var Response $response */
$response = $this->await($this->browser->get('http://127.0.0.1:8080/sites', [
'Host' => 'expose.localhost',
'Authorization' => base64_encode("username:secret"),
'Content-Type' => 'application/json'
'Authorization' => base64_encode('username:secret'),
'Content-Type' => 'application/json',
]));
$body = $response->getBody()->getContents();

View File

@@ -3,18 +3,13 @@
namespace Tests\Feature\Server;
use App\Client\Client;
use App\Contracts\ConnectionManager;
use App\Server\Factory;
use Clue\React\Buzz\Browser;
use Clue\React\Buzz\Message\ResponseException;
use GuzzleHttp\Psr7\Response;
use Psr\Http\Message\ServerRequestInterface;
use Ratchet\Client\WebSocket;
use Ratchet\ConnectionInterface;
use React\EventLoop\LoopInterface;
use React\Http\Server;
use Tests\Feature\TestCase;
use function Ratchet\Client\connect;
class TunnelTest extends TestCase
{
@@ -54,7 +49,7 @@ class TunnelTest extends TestCase
$this->expectExceptionMessage(404);
$response = $this->await($this->browser->get('http://127.0.0.1:8080/', [
'Host' => 'tunnel.localhost'
'Host' => 'tunnel.localhost',
]));
}
@@ -65,7 +60,7 @@ class TunnelTest extends TestCase
/**
* We create an expose client that connects to our server and shares
* the created test HTTP server
* the created test HTTP server.
*/
$client = $this->createClient();
$this->await($client->connectToServer('127.0.0.1:8085', 'tunnel'));
@@ -75,7 +70,7 @@ class TunnelTest extends TestCase
* created tunnel.
*/
$response = $this->await($this->browser->get('http://127.0.0.1:8080/', [
'Host' => 'tunnel.localhost'
'Host' => 'tunnel.localhost',
]));
$this->assertSame('Hello World!', $response->getBody()->getContents());
@@ -92,7 +87,7 @@ class TunnelTest extends TestCase
/**
* We create an expose client that connects to our server and shares
* the created test HTTP server
* the created test HTTP server.
*/
$client = $this->createClient();
$result = $this->await($client->connectToServer('127.0.0.1:8085', 'tunnel'));
@@ -109,7 +104,7 @@ class TunnelTest extends TestCase
/**
* We create an expose client that connects to our server and shares
* the created test HTTP server
* the created test HTTP server.
*/
$client = $this->createClient();
$this->await($client->connectToServer('127.0.0.1:8085', 'tunnel'));
@@ -141,7 +136,7 @@ class TunnelTest extends TestCase
protected function createTestHttpServer()
{
$server = new Server(function (ServerRequestInterface $request) {
return new Response(200, ['Content-Type' => 'text/plain'], "Hello World!");
return new Response(200, ['Content-Type' => 'text/plain'], 'Hello World!');
});
$this->testHttpServer = new \React\Socket\Server(8085, $this->loop);

View File

@@ -2,17 +2,12 @@
namespace Tests\Feature;
use function Clue\React\Block\await;
use Clue\React\SQLite\DatabaseInterface;
use GuzzleHttp\Psr7\Response;
use Illuminate\Support\Str;
use Psr\Http\Message\ResponseInterface;
use React\EventLoop\Factory;
use React\EventLoop\LoopInterface;
use React\EventLoop\StreamSelectLoop;
use React\Promise\PromiseInterface;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Output\ConsoleOutputInterface;
use function Clue\React\Block\await;
abstract class TestCase extends \Tests\TestCase
{
@@ -25,7 +20,7 @@ abstract class TestCase extends \Tests\TestCase
{
parent::setUp();
$this->app->bind(ConsoleOutputInterface::class, function() {
$this->app->bind(ConsoleOutputInterface::class, function () {
return new ConsoleOutput();
});