|
@@ -2,23 +2,27 @@
|
|
|
|
|
|
namespace Tests;
|
|
namespace Tests;
|
|
|
|
|
|
|
|
+use App\Database\DB;
|
|
use PHPUnit\Framework\TestCase as BaseTestCase;
|
|
use PHPUnit\Framework\TestCase as BaseTestCase;
|
|
use Symfony\Component\BrowserKit\Response;
|
|
use Symfony\Component\BrowserKit\Response;
|
|
|
|
|
|
abstract class TestCase extends BaseTestCase
|
|
abstract class TestCase extends BaseTestCase
|
|
{
|
|
{
|
|
|
|
+ use BootApplication;
|
|
|
|
+
|
|
/** @var Client */
|
|
/** @var Client */
|
|
protected $client;
|
|
protected $client;
|
|
|
|
|
|
protected function setUp()
|
|
protected function setUp()
|
|
{
|
|
{
|
|
- $this->client = new Client();
|
|
|
|
|
|
+ $this->client = new Client($this->createApplication());
|
|
|
|
+ $this->client->followRedirects(false);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* @param string $uri
|
|
* @param string $uri
|
|
* @param array $parameters
|
|
* @param array $parameters
|
|
- * @return Response|object
|
|
|
|
|
|
+ * @return object|Response
|
|
*/
|
|
*/
|
|
public function get(string $uri, array $parameters = [])
|
|
public function get(string $uri, array $parameters = [])
|
|
{
|
|
{
|
|
@@ -29,11 +33,19 @@ abstract class TestCase extends BaseTestCase
|
|
/**
|
|
/**
|
|
* @param string $uri
|
|
* @param string $uri
|
|
* @param array $parameters
|
|
* @param array $parameters
|
|
- * @return Response|object
|
|
|
|
|
|
+ * @return object|Response
|
|
*/
|
|
*/
|
|
public function post(string $uri, array $parameters = [])
|
|
public function post(string $uri, array $parameters = [])
|
|
{
|
|
{
|
|
$this->client->request('POST', $uri, $parameters);
|
|
$this->client->request('POST', $uri, $parameters);
|
|
return $this->client->getResponse();
|
|
return $this->client->getResponse();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @return DB
|
|
|
|
+ */
|
|
|
|
+ public function database()
|
|
|
|
+ {
|
|
|
|
+ return $this->app->getContainer()->get('database');
|
|
|
|
+ }
|
|
}
|
|
}
|