User, People tests iinit
This commit is contained in:
parent
d77e15c50d
commit
46f0328d9b
|
@ -3,7 +3,7 @@
|
|||
{% endif %}
|
||||
|
||||
{% if list|length %}
|
||||
<div class="section users-columns">
|
||||
<div class="section users users-columns">
|
||||
<ul>
|
||||
{% for subject in list %}
|
||||
<li>
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
<div id="content">
|
||||
<h2>{{ 'people_local'|trans }}</h2>
|
||||
<div class="users-cards section section--no-bg">
|
||||
<div class="users users-cards section section--no-bg">
|
||||
{% for user in local %}
|
||||
<div class="section">
|
||||
{{ component('user_box', {user: user}) }}
|
||||
|
@ -49,7 +49,7 @@
|
|||
{% endif %}
|
||||
|
||||
<h2>{{ 'people_federated'|trans }}</h2>
|
||||
<div class="users-cards section section--no-bg">
|
||||
<div class="users users-cards section section--no-bg">
|
||||
{% for user in federated %}
|
||||
<div class="section">
|
||||
{{ component('user_box', {user: user}) }}
|
||||
|
|
|
@ -28,11 +28,11 @@ trait FactoryTrait
|
|||
{
|
||||
public function createVote(int $choice, VoteInterface $subject, User $user): Vote
|
||||
{
|
||||
$manager = static::getContainer()->get(EntityManagerInterface::class);
|
||||
$manager = $this->getContainer()->get(EntityManagerInterface::class);
|
||||
/**
|
||||
* @var $voteManager VoteManager
|
||||
*/
|
||||
$voteManager = static::getContainer()->get(VoteManager::class);
|
||||
$voteManager = $this->getContainer()->get(VoteManager::class);
|
||||
|
||||
$vote = $voteManager->vote($choice, $subject, $user);
|
||||
|
||||
|
@ -75,7 +75,7 @@ trait FactoryTrait
|
|||
|
||||
private function createUser(string $username, string $email = null, string $password = null, $active = true): User
|
||||
{
|
||||
$manager = static::getContainer()->get(EntityManagerInterface::class);
|
||||
$manager = $this->getContainer()->get(EntityManagerInterface::class);
|
||||
|
||||
$user = new User($email ?: $username.'@example.com', $username, $password ?: 'secret');
|
||||
|
||||
|
@ -124,7 +124,7 @@ trait FactoryTrait
|
|||
|
||||
if ($isAdmin) {
|
||||
$user->roles = ['ROLE_ADMIN'];
|
||||
$manager = static::getContainer()->get(EntityManagerInterface::class);
|
||||
$manager = $this->getContainer()->get(EntityManagerInterface::class);
|
||||
|
||||
$manager->persist($user);
|
||||
$manager->flush();
|
||||
|
@ -138,7 +138,7 @@ trait FactoryTrait
|
|||
/**
|
||||
* @var $manager MagazineManager
|
||||
*/
|
||||
$manager = static::getContainer()->get(MagazineManager::class);
|
||||
$manager = $this->getContainer()->get(MagazineManager::class);
|
||||
|
||||
$dto = new MagazineDto();
|
||||
$dto->name = $name;
|
||||
|
@ -161,15 +161,15 @@ trait FactoryTrait
|
|||
|
||||
$entry = $this->getEntryByTitle('test', null, 'test', $magazine, $actor);
|
||||
$comment = $this->createEntryComment('test', $entry, $regular);
|
||||
static::getContainer()->get(EntryCommentManager::class)->delete($owner, $comment);
|
||||
static::getContainer()->get(EntryManager::class)->delete($owner, $entry);
|
||||
$this->getContainer()->get(EntryCommentManager::class)->delete($owner, $comment);
|
||||
$this->getContainer()->get(EntryManager::class)->delete($owner, $entry);
|
||||
|
||||
$post = $this->createPost('test', $magazine, $actor);
|
||||
$comment = $this->createPostComment('test', $post, $regular);
|
||||
static::getContainer()->get(PostCommentManager::class)->delete($owner, $comment);
|
||||
static::getContainer()->get(PostManager::class)->delete($owner, $post);
|
||||
$this->getContainer()->get(PostCommentManager::class)->delete($owner, $comment);
|
||||
$this->getContainer()->get(PostManager::class)->delete($owner, $post);
|
||||
|
||||
static::getContainer()->get(MagazineManager::class)->ban(
|
||||
$this->getContainer()->get(MagazineManager::class)->ban(
|
||||
$magazine,
|
||||
$actor,
|
||||
$owner,
|
||||
|
@ -220,7 +220,7 @@ trait FactoryTrait
|
|||
/**
|
||||
* @var $manager EntryManager
|
||||
*/
|
||||
$manager = static::getContainer()->get(EntryManager::class);
|
||||
$manager = $this->getContainer()->get(EntryManager::class);
|
||||
|
||||
$dto = new EntryDto();
|
||||
$dto->magazine = $magazine;
|
||||
|
@ -241,7 +241,7 @@ trait FactoryTrait
|
|||
/**
|
||||
* @var $manager EntryCommentManager
|
||||
*/
|
||||
$manager = static::getContainer()->get(EntryCommentManager::class);
|
||||
$manager = $this->getContainer()->get(EntryCommentManager::class);
|
||||
|
||||
if ($parent) {
|
||||
$dto = (new EntryCommentDto())->createWithParent(
|
||||
|
@ -264,7 +264,7 @@ trait FactoryTrait
|
|||
/**
|
||||
* @var $manager PostManager
|
||||
*/
|
||||
$manager = static::getContainer()->get(PostManager::class);
|
||||
$manager = $this->getContainer()->get(PostManager::class);
|
||||
|
||||
$dto = new PostDto();
|
||||
$dto->magazine = $magazine ?: $this->getMagazineByName('acme');
|
||||
|
@ -278,7 +278,7 @@ trait FactoryTrait
|
|||
/**
|
||||
* @var $manager PostCommentManager
|
||||
*/
|
||||
$manager = static::getContainer()->get(PostCommentManager::class);
|
||||
$manager = $this->getContainer()->get(PostCommentManager::class);
|
||||
|
||||
$dto = new PostCommentDto();
|
||||
$dto->post = $post ?? $this->createPost('test post content');
|
||||
|
|
|
@ -22,7 +22,7 @@ class AdminCommandTest extends KernelTestCase
|
|||
$dto = (new UserDto())->create('actor', 'contact@example.com');
|
||||
$dto->plainPassword = 'secret';
|
||||
|
||||
static::getContainer()->get(UserManager::class)
|
||||
$this->getContainer()->get(UserManager::class)
|
||||
->create($dto, false);
|
||||
|
||||
$this->assertFalse($this->repository->findOneByUsername('actor')->isAdmin());
|
||||
|
@ -39,6 +39,6 @@ class AdminCommandTest extends KernelTestCase
|
|||
$application = new Application(self::bootKernel());
|
||||
|
||||
$this->command = $application->find('kbin:user:admin');
|
||||
$this->repository = static::getContainer()->get(UserRepository::class);
|
||||
$this->repository = $this->getContainer()->get(UserRepository::class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,6 @@ class UserCommandTest extends KernelTestCase
|
|||
$application = new Application(self::bootKernel());
|
||||
|
||||
$this->command = $application->find('kbin:user:create');
|
||||
$this->repository = static::getContainer()->get(UserRepository::class);
|
||||
$this->repository = $this->getContainer()->get(UserRepository::class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Functional\Controller\Magazine;
|
||||
|
||||
use App\Tests\WebTestCase;
|
||||
|
||||
class MagazinePeopleControllerTest extends WebTestCase
|
||||
{
|
||||
public function testMagazinePeoplePage(): void
|
||||
{
|
||||
$client = $this->createClient();
|
||||
|
||||
$user = $this->getUserByUsername('JohnDoe');
|
||||
$this->createPost('test post content');
|
||||
|
||||
$user->about = 'Loerm ipsum';
|
||||
$this->getContainer()->get('doctrine')->getManager()->flush();
|
||||
|
||||
$crawler = $client->request('GET', '/m/acme/people');
|
||||
|
||||
$this->assertEquals(1, $crawler->filter('#main .user-box')->count());
|
||||
$this->assertSelectorTextContains('#main .users .user-box', 'Loerm ipsum');
|
||||
}
|
||||
}
|
25
tests/Functional/Controller/People/FrontControllerTest.php
Normal file
25
tests/Functional/Controller/People/FrontControllerTest.php
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Functional\Controller\People;
|
||||
|
||||
use App\Tests\WebTestCase;
|
||||
|
||||
class FrontControllerTest extends WebTestCase
|
||||
{
|
||||
public function testFrontPeoplePage(): void
|
||||
{
|
||||
$client = $this->createClient();
|
||||
|
||||
$user = $this->getUserByUsername('JohnDoe');
|
||||
|
||||
$user->about = 'Loerm ipsum';
|
||||
$this->getContainer()->get('doctrine')->getManager()->flush();
|
||||
|
||||
$crawler = $client->request('GET', '/people');
|
||||
|
||||
$this->assertEquals(1, $crawler->filter('#main .user-box')->count());
|
||||
$this->assertSelectorTextContains('#main .users .user-box', 'Loerm ipsum');
|
||||
}
|
||||
}
|
|
@ -4,6 +4,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Tests\Functional\Controller\User;
|
||||
|
||||
use App\Service\MagazineManager;
|
||||
use App\Service\UserManager;
|
||||
use App\Tests\WebTestCase;
|
||||
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
|
||||
|
||||
|
@ -13,14 +15,116 @@ class UserFrontControllerTest extends WebTestCase
|
|||
{
|
||||
$client = $this->prepareEntries();
|
||||
|
||||
$cralwer = $client->request('GET', '/u/JohnDoe');
|
||||
$crawler = $client->request('GET', '/u/JohnDoe');
|
||||
|
||||
$this->assertSelectorTextContains('.options.options--top', 'overview');
|
||||
$this->assertSelectorTextContains('.options.options--top .active', 'overview');
|
||||
$this->assertEquals(2, $crawler->filter('#main .entry')->count());
|
||||
$this->assertEquals(2, $crawler->filter('#main .entry-comment')->count());
|
||||
$this->assertEquals(2, $crawler->filter('#main .post')->count());
|
||||
$this->assertEquals(2, $crawler->filter('#main .post-comment')->count());
|
||||
}
|
||||
|
||||
$this->assertEquals(2, $cralwer->filter('#main .entry'));
|
||||
$this->assertEquals(2, $cralwer->filter('#main .entry-comment'));
|
||||
$this->assertEquals(2, $cralwer->filter('#main .post'));
|
||||
$this->assertEquals(2, $cralwer->filter('#main .post-comment'));
|
||||
public function testThreadsPage(): void
|
||||
{
|
||||
$client = $this->prepareEntries();
|
||||
|
||||
$crawler = $client->request('GET', '/u/JohnDoe');
|
||||
$crawler = $client->click($crawler->filter('#main .options')->selectLink('threads')->link());
|
||||
|
||||
$this->assertSelectorTextContains('.options.options--top .active', 'threads (1)');
|
||||
$this->assertEquals(1, $crawler->filter('#main .entry')->count());
|
||||
}
|
||||
|
||||
public function testCommentsPage(): void
|
||||
{
|
||||
$client = $this->prepareEntries();
|
||||
|
||||
$crawler = $client->request('GET', '/u/JohnDoe');
|
||||
$client->click($crawler->filter('#main .options')->selectLink('comments')->link());
|
||||
|
||||
$this->assertSelectorTextContains('.options.options--top .active', 'comments (2)');
|
||||
$this->assertEquals(2, $crawler->filter('#main .entry-comment')->count());
|
||||
}
|
||||
|
||||
public function testPostsPage(): void
|
||||
{
|
||||
$client = $this->prepareEntries();
|
||||
|
||||
$crawler = $client->request('GET', '/u/JohnDoe');
|
||||
$crawler = $client->click($crawler->filter('#main .options')->selectLink('posts')->link());
|
||||
|
||||
$this->assertSelectorTextContains('.options.options--top .active', 'posts (1)');
|
||||
$this->assertEquals(1, $crawler->filter('#main .post')->count());
|
||||
}
|
||||
|
||||
public function testRepliesPage(): void
|
||||
{
|
||||
$client = $this->prepareEntries();
|
||||
|
||||
$crawler = $client->request('GET', '/u/JohnDoe');
|
||||
$crawler = $client->click($crawler->filter('#main .options')->selectLink('replies')->link());
|
||||
|
||||
$this->assertSelectorTextContains('.options.options--top .active', 'replies (2)');
|
||||
$this->assertEquals(2, $crawler->filter('#main .post-comment')->count());
|
||||
$this->assertEquals(2, $crawler->filter('#main .post')->count());
|
||||
}
|
||||
|
||||
public function createSubscriptionsPage()
|
||||
{
|
||||
$client = $this->createClient();
|
||||
|
||||
$user = $this->getUserByUsername('JohnDoe');
|
||||
$this->getMagazineByName('kbin');
|
||||
$this->getMagazineByName('mag', $this->getUserByUsername('JaneDoe'));
|
||||
|
||||
$manager = $this->getContainer()->get(MagazineManager::class);
|
||||
$manager->subscribe($this->getMagazineByName('mag'), $user);
|
||||
|
||||
$client->loginUser($user);
|
||||
|
||||
$crawler = $client->request('GET', '/u/JohnDoe');
|
||||
$crawler = $client->click($crawler->filter('#main .options')->selectLink('subscriptions')->link());
|
||||
|
||||
$this->assertSelectorTextContains('.options.options--top .active', 'subscriptions (2)');
|
||||
$this->assertEquals(2, $crawler->filter('#main .magazines ul li')->count());
|
||||
}
|
||||
|
||||
public function testFollowersPage():void
|
||||
{
|
||||
$client = $this->createClient();
|
||||
|
||||
$user1 = $this->getUserByUsername('JohnDoe');
|
||||
$user2 = $this->getUserByUsername('JaneDoe');
|
||||
|
||||
$manager = $this->getContainer()->get(UserManager::class);
|
||||
$manager->follow($user2, $user1);
|
||||
|
||||
$client->loginUser($user1);
|
||||
|
||||
$crawler = $client->request('GET', '/u/JohnDoe');
|
||||
$crawler = $client->click($crawler->filter('#main .options')->selectLink('followers')->link());
|
||||
|
||||
$this->assertSelectorTextContains('.options.options--top .active', 'followers (1)');
|
||||
$this->assertEquals(1, $crawler->filter('#main .users ul li')->count());
|
||||
}
|
||||
|
||||
public function testFollowingPage():void
|
||||
{
|
||||
$client = $this->createClient();
|
||||
|
||||
$user1 = $this->getUserByUsername('JohnDoe');
|
||||
$user2 = $this->getUserByUsername('JaneDoe');
|
||||
|
||||
$manager = $this->getContainer()->get(UserManager::class);
|
||||
$manager->follow($user1, $user2);
|
||||
|
||||
$client->loginUser($user1);
|
||||
|
||||
$crawler = $client->request('GET', '/u/JohnDoe');
|
||||
$crawler = $client->click($crawler->filter('#main .options')->selectLink('following')->link());
|
||||
|
||||
$this->assertSelectorTextContains('.options.options--top .active', 'following (1)');
|
||||
$this->assertEquals(1, $crawler->filter('#main .users ul li')->count());
|
||||
}
|
||||
|
||||
private function prepareEntries(): KernelBrowser
|
||||
|
@ -65,5 +169,4 @@ class UserFrontControllerTest extends WebTestCase
|
|||
|
||||
return $client;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ class MentionManagerTest extends WebTestCase
|
|||
{
|
||||
$this->createClient();
|
||||
|
||||
$manager = static::getContainer()->get(MentionManager::class);
|
||||
$manager = $this->getContainer()->get(MentionManager::class);
|
||||
$this->assertEquals($output, $manager->extract($input));
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ class TagManagerTest extends WebTestCase
|
|||
{
|
||||
$this->createClient();
|
||||
|
||||
$manager = static::getContainer()->get(TagManager::class);
|
||||
$manager = $this->getContainer()->get(TagManager::class);
|
||||
$this->assertEquals($output, $manager->extract($input, 'kbin'));
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ class SluggerTest extends WebTestCase
|
|||
public function testCamelCase(string $input, string $output): void
|
||||
{
|
||||
$this->createClient();
|
||||
$slugger = static::getContainer()->get(Slugger::class);
|
||||
$slugger = $this->getContainer()->get(Slugger::class);
|
||||
$this->assertEquals($output, $slugger->camelCase($input));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue