feat(command): add command for refresh database
This commit is contained in:
44
tests/Integration/Command/RefreshDatabaseCommandTest.php
Normal file
44
tests/Integration/Command/RefreshDatabaseCommandTest.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Integration\Command;
|
||||
|
||||
use App\Entity\Database\Comments\Comment;
|
||||
use App\Entity\Database\Posts\Post;
|
||||
use App\Entity\Database\Users\Address;
|
||||
use App\Entity\Database\Users\Company;
|
||||
use App\Entity\Database\Users\User;
|
||||
use App\Tests\Common\DatabaseTestTrait;
|
||||
use Nubium\Exception\ThisShouldNeverHappenException;
|
||||
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
|
||||
class RefreshDatabaseCommandTest extends KernelTestCase
|
||||
{
|
||||
use DatabaseTestTrait;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::bootKernel();
|
||||
$this->bootDatabase();
|
||||
}
|
||||
|
||||
public function testCommandIsSuccessful(): void
|
||||
{
|
||||
$app = new Application(self::$kernel ?? throw new ThisShouldNeverHappenException("Kernel not booted yet"));
|
||||
$command = $app->find('brilo:refresh-database');
|
||||
$commandTester = new CommandTester($command);
|
||||
|
||||
$commandTester->execute([]);
|
||||
|
||||
$this->assertSame(0, $commandTester->getStatusCode());
|
||||
// Tady bych otestoval ze jsou tam nejake data ktere tam vzdy maji byt ... nicmene o zadnych takovych datech nevim
|
||||
$this->assertGreaterThan(0, $this->getEntityCount(User::class));
|
||||
$this->assertGreaterThan(0, $this->getEntityCount(Company::class));
|
||||
$this->assertGreaterThan(0, $this->getEntityCount(Address::class));
|
||||
$this->assertGreaterThan(0, $this->getEntityCount(Post::class));
|
||||
$this->assertGreaterThan(0, $this->getEntityCount(Comment::class));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user