mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-09 14:07:25 +01:00
Optimized tests
This commit is contained in:
parent
5dea4e8982
commit
fcfe1ce9d7
@ -12,7 +12,7 @@ use App\Controller\DefaultController;
|
|||||||
class DefaultControllerTest extends WebTestCase
|
class DefaultControllerTest extends WebTestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var DefaultControllerInterface
|
* @var DefaultController
|
||||||
*/
|
*/
|
||||||
protected $defaultController;
|
protected $defaultController;
|
||||||
|
|
||||||
|
@ -1,44 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Tests\Unit\Controller;
|
|
||||||
|
|
||||||
use App\Controller\UserController;
|
|
||||||
use App\Controller\UserControllerInterface;
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author kevinfrantz
|
|
||||||
*/
|
|
||||||
class UserControllerTest extends WebTestCase
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var UserControllerInterface
|
|
||||||
*/
|
|
||||||
protected $userController;
|
|
||||||
|
|
||||||
public function setUp(): void
|
|
||||||
{
|
|
||||||
$this->userController = new UserController();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testLogout(): void
|
|
||||||
{
|
|
||||||
$client = static::createClient();
|
|
||||||
$client->request('GET', '/user/logout');
|
|
||||||
$this->assertEquals(200, $client->getResponse()->getStatusCode());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testLogin(): void
|
|
||||||
{
|
|
||||||
$client = static::createClient();
|
|
||||||
$client->request('GET', '/login');
|
|
||||||
$this->assertEquals(200, $client->getResponse()->getStatusCode());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testRegister(): void
|
|
||||||
{
|
|
||||||
$client = static::createClient();
|
|
||||||
$client->request('GET', '/user/register');
|
|
||||||
$this->assertEquals(200, $client->getResponse()->getStatusCode());
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,20 +1,25 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace tests\unit\Entity;
|
namespace tests\unit\Entity;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
|
use App\Entity\Law;
|
||||||
|
use App\Entity\UserSource;
|
||||||
|
use App\Entity\Node;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*/
|
*/
|
||||||
class UserTest extends TestCase
|
class UserTest extends TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
const PASSWORD = '12345678';
|
const PASSWORD = '12345678';
|
||||||
|
|
||||||
const USERNAME = 'tester';
|
const USERNAME = 'tester';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @var User
|
* @var User
|
||||||
*/
|
*/
|
||||||
protected $user;
|
protected $user;
|
||||||
@ -22,17 +27,32 @@ class UserTest extends TestCase
|
|||||||
public function setUp(): void
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
$this->user = new User();
|
$this->user = new User();
|
||||||
$this->user->setPassword(self::PASSWORD);
|
|
||||||
$this->user->setUsername(' '.self::USERNAME.' ');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUsername(): void
|
public function testUsername(): void
|
||||||
{
|
{
|
||||||
|
$this->user->setUsername(self::USERNAME);
|
||||||
$this->assertEquals(self::USERNAME, $this->user->getUsername());
|
$this->assertEquals(self::USERNAME, $this->user->getUsername());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPassword(): void
|
public function testPassword(): void
|
||||||
{
|
{
|
||||||
|
$this->user->setPassword(self::PASSWORD);
|
||||||
$this->assertEquals(self::PASSWORD, $this->user->getPassword());
|
$this->assertEquals(self::PASSWORD, $this->user->getPassword());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testSource(): void
|
||||||
|
{
|
||||||
|
$this->assertInstanceOf(UserSource::class,$this->user->getSource());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testNode(): void
|
||||||
|
{
|
||||||
|
$this->assertInstanceOf(Node::class,$this->user->getSource()->getNode());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testLaw(): void
|
||||||
|
{
|
||||||
|
$this->assertInstanceOf(Law::class,$this->user->getSource()->getNode()->getLaw());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user