diff --git a/composer.json b/composer.json index 2f7b201b..f35b2afb 100644 --- a/composer.json +++ b/composer.json @@ -54,7 +54,6 @@ }, "require-dev": { "devster/ubench": "^2.0", - "doctrine/data-fixtures": "^1.3", "eaglewu/swoole-ide-helper": "dev-master", "filp/whoops": "^2.4", "infection/infection": "^0.12.2", @@ -63,6 +62,7 @@ "phpunit/phpunit": "^8.3", "roave/security-advisories": "dev-master", "shlinkio/php-coding-standard": "~1.2.2", + "shlinkio/shlink-test-utils": "^1.0", "symfony/dotenv": "^4.3", "symfony/var-dumper": "^4.3", "zendframework/zend-component-installer": "^2.1", @@ -95,8 +95,7 @@ "ShlinkioTest\\Shlink\\Common\\": "module/Common/test", "ShlinkioTest\\Shlink\\EventDispatcher\\": "module/EventDispatcher/test", "ShlinkioTest\\Shlink\\IpGeolocation\\": "module/IpGeolocation/test", - "ShlinkioTest\\Shlink\\PreviewGenerator\\": "module/PreviewGenerator/test", - "Shlinkio\\Shlink\\TestUtils\\": "module/TestUtils/src" + "ShlinkioTest\\Shlink\\PreviewGenerator\\": "module/PreviewGenerator/test" } }, "scripts": { diff --git a/module/TestUtils/LICENSE b/module/TestUtils/LICENSE deleted file mode 100644 index 31778387..00000000 --- a/module/TestUtils/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2019 Alejandro Celaya - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/module/TestUtils/README.md b/module/TestUtils/README.md deleted file mode 100644 index d2520ec1..00000000 --- a/module/TestUtils/README.md +++ /dev/null @@ -1,10 +0,0 @@ -# Shlink test utils - -Helpers and utilities to run different types of tests in Shlink. - -Provided base test classes: - -* `ApiTestCase` for API e2e tests. -* `DbTestCase` for database integration tests. - -Both classes extends [phpunit]'s `TestCase` class. diff --git a/module/TestUtils/src/ApiTest/ApiTestCase.php b/module/TestUtils/src/ApiTest/ApiTestCase.php deleted file mode 100644 index 7cc70396..00000000 --- a/module/TestUtils/src/ApiTest/ApiTestCase.php +++ /dev/null @@ -1,67 +0,0 @@ -request($method, sprintf('%s%s', self::REST_PATH_PREFIX, $uri), $options); - } - - protected function callApiWithKey(string $method, string $uri, array $options = []): ResponseInterface - { - $headers = $options[RequestOptions::HEADERS] ?? []; - $headers['X-Api-Key'] = 'valid_api_key'; - $options[RequestOptions::HEADERS] = $headers; - - return $this->callApi($method, $uri, $options); - } - - protected function getJsonResponsePayload(ResponseInterface $resp): array - { - return json_decode((string) $resp->getBody()); - } - - protected function callShortUrl(string $shortCode): ResponseInterface - { - return self::$client->request(self::METHOD_GET, sprintf('/%s', $shortCode), [ - RequestOptions::ALLOW_REDIRECTS => false, - ]); - } -} diff --git a/module/TestUtils/src/DbTest/DatabaseTestCase.php b/module/TestUtils/src/DbTest/DatabaseTestCase.php deleted file mode 100644 index 987dfa1f..00000000 --- a/module/TestUtils/src/DbTest/DatabaseTestCase.php +++ /dev/null @@ -1,36 +0,0 @@ -getEntityManager()->createQueryBuilder(); - $qb->delete($entityClass, 'x'); - $qb->getQuery()->execute(); - } - - $this->getEntityManager()->clear(); - } -} diff --git a/module/TestUtils/src/Helper/TestHelper.php b/module/TestUtils/src/Helper/TestHelper.php deleted file mode 100644 index c8b67d6c..00000000 --- a/module/TestUtils/src/Helper/TestHelper.php +++ /dev/null @@ -1,40 +0,0 @@ -inheritEnvironmentVariables() - ->mustRun(); - - $process = new Process(['vendor/bin/doctrine', 'orm:schema-tool:create', '--no-interaction', '-q']); - $process->inheritEnvironmentVariables() - ->mustRun(); - } - - public function seedFixtures(EntityManagerInterface $em, array $config): void - { - $paths = $config['paths'] ?? []; - if (empty($paths)) { - return; - } - - $loader = new Loader(); - foreach ($paths as $path) { - $loader->loadFromDirectory($path); - } - - $executor = new ORMExecutor($em, new ORMPurger()); - $executor->execute($loader->getFixtures()); - } -} diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 1f0636f5..03e97254 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -35,7 +35,6 @@ ./module/Core/src/Repository - ./module/TestUtils