shlinkio /
shlink
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Shlinkio\Shlink\TestUtils; |
||
| 6 | |||
| 7 | use Doctrine\ORM\EntityManager; |
||
| 8 | use Psr\Container\ContainerInterface; |
||
| 9 | |||
| 10 | use function register_shutdown_function; |
||
| 11 | use function sprintf; |
||
| 12 | |||
| 13 | use const ShlinkioTest\Shlink\SWOOLE_TESTING_HOST; |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 14 | use const ShlinkioTest\Shlink\SWOOLE_TESTING_PORT; |
||
|
0 ignored issues
–
show
|
|||
| 15 | |||
| 16 | /** @var ContainerInterface $container */ |
||
| 17 | $container = require __DIR__ . '/../container.php'; |
||
| 18 | $testHelper = $container->get(Helper\TestHelper::class); |
||
| 19 | $config = $container->get('config'); |
||
| 20 | $em = $container->get(EntityManager::class); |
||
| 21 | $httpClient = $container->get('shlink_test_api_client'); |
||
| 22 | |||
| 23 | // Start code coverage collecting on swoole process, and stop it when process shuts down |
||
| 24 | $httpClient->request('GET', sprintf('http://%s:%s/api-tests/start-coverage', SWOOLE_TESTING_HOST, SWOOLE_TESTING_PORT)); |
||
| 25 | register_shutdown_function(function () use ($httpClient): void { |
||
| 26 | $httpClient->request( |
||
| 27 | 'GET', |
||
| 28 | sprintf('http://%s:%s/api-tests/stop-coverage', SWOOLE_TESTING_HOST, SWOOLE_TESTING_PORT), |
||
| 29 | ); |
||
| 30 | }); |
||
| 31 | |||
| 32 | $testHelper->createTestDb(); |
||
| 33 | ApiTest\ApiTestCase::setApiClient($httpClient); |
||
| 34 | ApiTest\ApiTestCase::setSeedFixturesCallback(fn () => $testHelper->seedFixtures($em, $config['data_fixtures'] ?? [])); |
||
| 35 |