mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-10 09:13:11 +08:00
Created TestUtils module
This commit is contained in:
@@ -11,7 +11,7 @@ use Shlinkio\Shlink\Core\Entity\Visit;
|
||||
use Shlinkio\Shlink\Core\Model\ShortUrlMeta;
|
||||
use Shlinkio\Shlink\Core\Model\Visitor;
|
||||
use Shlinkio\Shlink\Core\Repository\ShortUrlRepository;
|
||||
use ShlinkioTest\Shlink\Common\DbTest\DatabaseTestCase;
|
||||
use Shlinkio\Shlink\TestUtils\DbTest\DatabaseTestCase;
|
||||
|
||||
use function count;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace ShlinkioTest\Shlink\Core\Repository;
|
||||
|
||||
use Shlinkio\Shlink\Core\Entity\Tag;
|
||||
use Shlinkio\Shlink\Core\Repository\TagRepository;
|
||||
use ShlinkioTest\Shlink\Common\DbTest\DatabaseTestCase;
|
||||
use Shlinkio\Shlink\TestUtils\DbTest\DatabaseTestCase;
|
||||
|
||||
class TagRepositoryTest extends DatabaseTestCase
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ use Shlinkio\Shlink\Core\Entity\VisitLocation;
|
||||
use Shlinkio\Shlink\Core\Model\Visitor;
|
||||
use Shlinkio\Shlink\Core\Repository\VisitRepository;
|
||||
use Shlinkio\Shlink\IpGeolocation\Model\Location;
|
||||
use ShlinkioTest\Shlink\Common\DbTest\DatabaseTestCase;
|
||||
use Shlinkio\Shlink\TestUtils\DbTest\DatabaseTestCase;
|
||||
|
||||
use function Functional\map;
|
||||
use function range;
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace ShlinkioApiTest\Shlink\Rest\Action;
|
||||
|
||||
use Cake\Chronos\Chronos;
|
||||
use GuzzleHttp\RequestOptions;
|
||||
use ShlinkioTest\Shlink\Common\ApiTest\ApiTestCase;
|
||||
use Shlinkio\Shlink\TestUtils\ApiTest\ApiTestCase;
|
||||
|
||||
use function Functional\map;
|
||||
use function range;
|
||||
|
||||
@@ -3,7 +3,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace ShlinkioApiTest\Shlink\Rest\Action;
|
||||
|
||||
use ShlinkioTest\Shlink\Common\ApiTest\ApiTestCase;
|
||||
use Shlinkio\Shlink\TestUtils\ApiTest\ApiTestCase;
|
||||
|
||||
class ListShortUrlsTest extends ApiTestCase
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace ShlinkioApiTest\Shlink\Rest\Middleware;
|
||||
use Shlinkio\Shlink\Rest\Authentication\Plugin\ApiKeyHeaderPlugin;
|
||||
use Shlinkio\Shlink\Rest\Authentication\RequestToHttpAuthPlugin;
|
||||
use Shlinkio\Shlink\Rest\Util\RestUtils;
|
||||
use ShlinkioTest\Shlink\Common\ApiTest\ApiTestCase;
|
||||
use Shlinkio\Shlink\TestUtils\ApiTest\ApiTestCase;
|
||||
|
||||
use function implode;
|
||||
use function sprintf;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ShlinkioApiTest\Shlink\Rest\Action;
|
||||
namespace ShlinkioApiTest\Shlink\Rest\Middleware;
|
||||
|
||||
use ShlinkioTest\Shlink\Common\ApiTest\ApiTestCase;
|
||||
use Shlinkio\Shlink\TestUtils\ApiTest\ApiTestCase;
|
||||
|
||||
use function explode;
|
||||
|
||||
class OptionsRequestTest extends ApiTestCase
|
||||
class ImplicitOptionsTest extends ApiTestCase
|
||||
{
|
||||
/** @test */
|
||||
public function optionsRequestsReturnEmptyResponse(): void
|
||||
21
module/TestUtils/LICENSE
Normal file
21
module/TestUtils/LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
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.
|
||||
10
module/TestUtils/README.md
Normal file
10
module/TestUtils/README.md
Normal file
@@ -0,0 +1,10 @@
|
||||
# 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.
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ShlinkioTest\Shlink\Common\ApiTest;
|
||||
namespace Shlinkio\Shlink\TestUtils\ApiTest;
|
||||
|
||||
use Fig\Http\Message\RequestMethodInterface;
|
||||
use Fig\Http\Message\StatusCodeInterface;
|
||||
@@ -19,7 +19,7 @@ abstract class ApiTestCase extends TestCase implements StatusCodeInterface, Requ
|
||||
|
||||
/** @var ClientInterface */
|
||||
private static $client;
|
||||
/** @var callable */
|
||||
/** @var callable|null */
|
||||
private static $seedFixtures;
|
||||
|
||||
public static function setApiClient(ClientInterface $client): void
|
||||
@@ -34,7 +34,7 @@ abstract class ApiTestCase extends TestCase implements StatusCodeInterface, Requ
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
if (self::$seedFixtures) {
|
||||
if (self::$seedFixtures !== null) {
|
||||
(self::$seedFixtures)();
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ShlinkioTest\Shlink\Common\DbTest;
|
||||
namespace Shlinkio\Shlink\TestUtils\DbTest;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ShlinkioTest\Shlink\Common;
|
||||
namespace Shlinkio\Shlink\TestUtils\Helper;
|
||||
|
||||
use Doctrine\Common\DataFixtures\Executor\ORMExecutor;
|
||||
use Doctrine\Common\DataFixtures\Loader;
|
||||
Reference in New Issue
Block a user