[TESTS] Change relevant tests to use GNUsocialTestCase, so they can access all the needed features
This commit is contained in:
parent
b9fbed2e3d
commit
d49541629d
@ -34,15 +34,13 @@
|
|||||||
namespace App\Tests\Twig;
|
namespace App\Tests\Twig;
|
||||||
|
|
||||||
use App\Core\DB\DB;
|
use App\Core\DB\DB;
|
||||||
use App\Core\Event;
|
|
||||||
use App\Twig\Extension;
|
use App\Twig\Extension;
|
||||||
use App\Twig\Runtime;
|
use App\Twig\Runtime;
|
||||||
|
use App\Util\GNUsocialTestCase;
|
||||||
use DirectoryIterator;
|
use DirectoryIterator;
|
||||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
class ExtensionTest extends KernelTestCase
|
class ExtensionTest extends GNUsocialTestCase
|
||||||
{
|
{
|
||||||
public function testIconsExtension()
|
public function testIconsExtension()
|
||||||
{
|
{
|
||||||
@ -96,12 +94,7 @@ class ExtensionTest extends KernelTestCase
|
|||||||
public function testGetNoteActions()
|
public function testGetNoteActions()
|
||||||
{
|
{
|
||||||
static::bootKernel();
|
static::bootKernel();
|
||||||
DB::setManager(self::$kernel->getContainer()->get('doctrine.orm.entity_manager'));
|
|
||||||
DB::initTableMap();
|
|
||||||
|
|
||||||
$container = self::$kernel->getContainer()->get('test.service_container');
|
|
||||||
$edi = $container->get(EventDispatcherInterface::class);
|
|
||||||
Event::setDispatcher($edi);
|
|
||||||
$req = $this->createMock(Request::class);
|
$req = $this->createMock(Request::class);
|
||||||
$runtime = new Runtime;
|
$runtime = new Runtime;
|
||||||
$runtime->setRequest($req);
|
$runtime->setRequest($req);
|
||||||
|
@ -20,24 +20,20 @@
|
|||||||
namespace App\Tests\Util;
|
namespace App\Tests\Util;
|
||||||
|
|
||||||
use App\Core\DB\DB;
|
use App\Core\DB\DB;
|
||||||
use App\Core\Event;
|
|
||||||
use App\Core\Router\Router;
|
|
||||||
use App\Core\Security;
|
use App\Core\Security;
|
||||||
use App\Entity\GSActor;
|
use App\Entity\GSActor;
|
||||||
use App\Entity\LocalUser;
|
use App\Entity\LocalUser;
|
||||||
use App\Util\Common;
|
use App\Util\Common;
|
||||||
use App\Util\Exception\NoLoggedInUser;
|
use App\Util\Exception\NoLoggedInUser;
|
||||||
|
use App\Util\GNUsocialTestCase;
|
||||||
use Doctrine\ORM\EntityManager;
|
use Doctrine\ORM\EntityManager;
|
||||||
use Doctrine\ORM\Mapping\ClassMetadataFactory;
|
use Doctrine\ORM\Mapping\ClassMetadataFactory;
|
||||||
use Doctrine\ORM\Mapping\ClassMetadataInfo;
|
use Doctrine\ORM\Mapping\ClassMetadataInfo;
|
||||||
use Jchook\AssertThrows\AssertThrows;
|
use Jchook\AssertThrows\AssertThrows;
|
||||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
|
||||||
use Symfony\Component\DependencyInjection\ParameterBag\ContainerBagInterface;
|
use Symfony\Component\DependencyInjection\ParameterBag\ContainerBagInterface;
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
|
||||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
|
||||||
use Symfony\Component\Security\Core\Security as SSecurity;
|
use Symfony\Component\Security\Core\Security as SSecurity;
|
||||||
|
|
||||||
class CommonTest extends WebTestCase
|
class CommonTest extends GNUsocialTestCase
|
||||||
{
|
{
|
||||||
use AssertThrows;
|
use AssertThrows;
|
||||||
|
|
||||||
@ -73,8 +69,6 @@ class CommonTest extends WebTestCase
|
|||||||
public function testUserAndActorGetters()
|
public function testUserAndActorGetters()
|
||||||
{
|
{
|
||||||
$client = static::createClient();
|
$client = static::createClient();
|
||||||
$sec = $this->getMockBuilder(SSecurity::class)->setConstructorArgs([self::$kernel->getContainer()])->getMock();
|
|
||||||
Security::setHelper($sec, null);
|
|
||||||
static::assertNull(Common::user());
|
static::assertNull(Common::user());
|
||||||
static::assertThrows(NoLoggedInUser::class, fn () => Common::ensureLoggedIn());
|
static::assertThrows(NoLoggedInUser::class, fn () => Common::ensureLoggedIn());
|
||||||
static::assertFalse(Common::isLoggedIn());
|
static::assertFalse(Common::isLoggedIn());
|
||||||
@ -112,12 +106,6 @@ class CommonTest extends WebTestCase
|
|||||||
{
|
{
|
||||||
static::bootKernel();
|
static::bootKernel();
|
||||||
|
|
||||||
$router = static::$container->get('router');
|
|
||||||
$url_gen = static::$container->get(UrlGeneratorInterface::class);
|
|
||||||
$event_dispatcher = static::$container->get(EventDispatcherInterface::class);
|
|
||||||
Router::setRouter($router, $url_gen);
|
|
||||||
Event::setDispatcher($event_dispatcher);
|
|
||||||
|
|
||||||
static::assertTrue(Common::isSystemPath('login'));
|
static::assertTrue(Common::isSystemPath('login'));
|
||||||
static::assertFalse(Common::isSystemPath('non-existent-path'));
|
static::assertFalse(Common::isSystemPath('non-existent-path'));
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
namespace App\Tests\Util;
|
namespace App\Tests\Util;
|
||||||
|
|
||||||
use App\Core\DB\DB;
|
|
||||||
use App\Entity\GSActor;
|
use App\Entity\GSActor;
|
||||||
use App\Util\Common;
|
use App\Util\Common;
|
||||||
use App\Util\Exception\NicknameEmptyException;
|
use App\Util\Exception\NicknameEmptyException;
|
||||||
@ -28,12 +27,12 @@ use App\Util\Exception\NicknameReservedException;
|
|||||||
use App\Util\Exception\NicknameTakenException;
|
use App\Util\Exception\NicknameTakenException;
|
||||||
use App\Util\Exception\NicknameTooLongException;
|
use App\Util\Exception\NicknameTooLongException;
|
||||||
use App\Util\Exception\NicknameTooShortException;
|
use App\Util\Exception\NicknameTooShortException;
|
||||||
|
use App\Util\GNUsocialTestCase;
|
||||||
use App\Util\Nickname;
|
use App\Util\Nickname;
|
||||||
use Jchook\AssertThrows\AssertThrows;
|
use Jchook\AssertThrows\AssertThrows;
|
||||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
|
||||||
use Symfony\Component\DependencyInjection\ParameterBag\ContainerBagInterface;
|
use Symfony\Component\DependencyInjection\ParameterBag\ContainerBagInterface;
|
||||||
|
|
||||||
class NicknameTest extends WebTestCase
|
class NicknameTest extends GNUsocialTestCase
|
||||||
{
|
{
|
||||||
use AssertThrows;
|
use AssertThrows;
|
||||||
|
|
||||||
@ -57,8 +56,6 @@ class NicknameTest extends WebTestCase
|
|||||||
static::assertThrows(NicknameReservedException::class, fn () => Nickname::normalize('this_nickname_is_reserved', check_already_used: false));
|
static::assertThrows(NicknameReservedException::class, fn () => Nickname::normalize('this_nickname_is_reserved', check_already_used: false));
|
||||||
|
|
||||||
static::bootKernel();
|
static::bootKernel();
|
||||||
DB::setManager(self::$kernel->getContainer()->get('doctrine.orm.entity_manager'));
|
|
||||||
DB::initTableMap();
|
|
||||||
static::assertSame('foobar', Nickname::normalize('foobar', check_already_used: true));
|
static::assertSame('foobar', Nickname::normalize('foobar', check_already_used: true));
|
||||||
static::assertThrows(NicknameTakenException::class, fn () => Nickname::normalize('taken_user', check_already_used: true));
|
static::assertThrows(NicknameTakenException::class, fn () => Nickname::normalize('taken_user', check_already_used: true));
|
||||||
}
|
}
|
||||||
@ -95,8 +92,6 @@ class NicknameTest extends WebTestCase
|
|||||||
public function testCheckTaken()
|
public function testCheckTaken()
|
||||||
{
|
{
|
||||||
static::bootKernel();
|
static::bootKernel();
|
||||||
DB::setManager(self::$kernel->getContainer()->get('doctrine.orm.entity_manager'));
|
|
||||||
DB::initTableMap();
|
|
||||||
|
|
||||||
static::assertNull(Nickname::checkTaken('not_taken_user'));
|
static::assertNull(Nickname::checkTaken('not_taken_user'));
|
||||||
static::assertTrue(Nickname::checkTaken('taken_user') instanceof GSActor);
|
static::assertTrue(Nickname::checkTaken('taken_user') instanceof GSActor);
|
||||||
|
Loading…
Reference in New Issue
Block a user