mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-02-16 14:39:37 +00:00
Ran rector and made tests final
This commit is contained in:
parent
43d72faf48
commit
b21d294cf8
162 changed files with 407 additions and 393 deletions
|
|
@ -28,7 +28,7 @@ use Doctrine\ORM\EntityManagerInterface;
|
|||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
|
||||
class AttachmentContainingDBElementRepositoryTest extends KernelTestCase
|
||||
final class AttachmentContainingDBElementRepositoryTest extends KernelTestCase
|
||||
{
|
||||
|
||||
private EntityManagerInterface $entityManager;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ use Doctrine\ORM\EntityManagerInterface;
|
|||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
|
||||
class DBElementRepositoryTest extends KernelTestCase
|
||||
final class DBElementRepositoryTest extends KernelTestCase
|
||||
{
|
||||
|
||||
private EntityManagerInterface $entityManager;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ use Doctrine\ORM\EntityManagerInterface;
|
|||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
|
||||
class LogEntryRepositoryTest extends KernelTestCase
|
||||
final class LogEntryRepositoryTest extends KernelTestCase
|
||||
{
|
||||
|
||||
private EntityManagerInterface $entityManager;
|
||||
|
|
@ -75,6 +75,7 @@ class LogEntryRepositoryTest extends KernelTestCase
|
|||
//We have a edit log entry for the category with ID 1
|
||||
$category = $this->entityManager->find(Category::class, 1);
|
||||
$adminUser = $this->entityManager->getRepository(User::class)->findOneBy(['name' => 'admin']);
|
||||
$this->assertInstanceOf(Category::class, $category);
|
||||
|
||||
$user = $this->repo->getLastEditingUser($category);
|
||||
|
||||
|
|
@ -83,6 +84,7 @@ class LogEntryRepositoryTest extends KernelTestCase
|
|||
|
||||
//For the category 2, the user must be null
|
||||
$category = $this->entityManager->find(Category::class, 2);
|
||||
$this->assertInstanceOf(Category::class, $category);
|
||||
$user = $this->repo->getLastEditingUser($category);
|
||||
$this->assertNull($user);
|
||||
}
|
||||
|
|
@ -92,6 +94,7 @@ class LogEntryRepositoryTest extends KernelTestCase
|
|||
//We have a edit log entry for the category with ID 1
|
||||
$category = $this->entityManager->find(Category::class, 1);
|
||||
$adminUser = $this->entityManager->getRepository(User::class)->findOneBy(['name' => 'admin']);
|
||||
$this->assertInstanceOf(Category::class, $category);
|
||||
|
||||
$user = $this->repo->getCreatingUser($category);
|
||||
|
||||
|
|
@ -100,6 +103,7 @@ class LogEntryRepositoryTest extends KernelTestCase
|
|||
|
||||
//For the category 2, the user must be null
|
||||
$category = $this->entityManager->find(Category::class, 2);
|
||||
$this->assertInstanceOf(Category::class, $category);
|
||||
$user = $this->repo->getCreatingUser($category);
|
||||
$this->assertNull($user);
|
||||
}
|
||||
|
|
@ -119,6 +123,7 @@ class LogEntryRepositoryTest extends KernelTestCase
|
|||
public function testGetElementExistedAtTimestamp(): void
|
||||
{
|
||||
$part = $this->entityManager->find(Part::class, 3);
|
||||
$this->assertInstanceOf(Part::class, $part);
|
||||
|
||||
//Assume that the part is existing now
|
||||
$this->assertTrue($this->repo->getElementExistedAtTimestamp($part, new \DateTimeImmutable()));
|
||||
|
|
@ -130,6 +135,7 @@ class LogEntryRepositoryTest extends KernelTestCase
|
|||
public function testGetElementHistory(): void
|
||||
{
|
||||
$category = $this->entityManager->find(Category::class, 1);
|
||||
$this->assertInstanceOf(Category::class, $category);
|
||||
|
||||
$history = $this->repo->getElementHistory($category);
|
||||
|
||||
|
|
@ -141,6 +147,7 @@ class LogEntryRepositoryTest extends KernelTestCase
|
|||
public function testGetTimetravelDataForElement(): void
|
||||
{
|
||||
$category = $this->entityManager->find(Category::class, 1);
|
||||
$this->assertInstanceOf(Category::class, $category);
|
||||
$data = $this->repo->getTimetravelDataForElement($category, new \DateTimeImmutable('2020-01-01'));
|
||||
|
||||
//The data must contain only ElementChangedLogEntry
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
|||
/**
|
||||
* @Group DB
|
||||
*/
|
||||
class NamedDBElementRepositoryTest extends WebTestCase
|
||||
final class NamedDBElementRepositoryTest extends WebTestCase
|
||||
{
|
||||
/**
|
||||
* @var StructuralDBElementRepository
|
||||
|
|
|
|||
|
|
@ -60,8 +60,8 @@ final class PartRepositoryTest extends TestCase
|
|||
$classMetadata = new ClassMetadata(Part::class);
|
||||
$emMock->method('getClassMetadata')->with(Part::class)->willReturn($classMetadata);
|
||||
|
||||
$translatorMock = $this->createMock(TranslatorInterface::class);
|
||||
$ipnSuggestSettings = $this->createMock(IpnSuggestSettings::class);
|
||||
$translatorMock = $this->createStub(TranslatorInterface::class);
|
||||
$ipnSuggestSettings = $this->createStub(IpnSuggestSettings::class);
|
||||
|
||||
$repo = $this->getMockBuilder(PartRepository::class)
|
||||
->setConstructorArgs([$emMock, $translatorMock, $ipnSuggestSettings])
|
||||
|
|
@ -120,7 +120,7 @@ final class PartRepositoryTest extends TestCase
|
|||
return $id;
|
||||
});
|
||||
|
||||
$ipnSuggestSettings = $this->createMock(IpnSuggestSettings::class);
|
||||
$ipnSuggestSettings = $this->createStub(IpnSuggestSettings::class);
|
||||
|
||||
$ipnSuggestSettings->suggestPartDigits = 4;
|
||||
$ipnSuggestSettings->useDuplicateDescription = false;
|
||||
|
|
@ -204,7 +204,7 @@ final class PartRepositoryTest extends TestCase
|
|||
return $id;
|
||||
});
|
||||
|
||||
$ipnSuggestSettings = $this->createMock(IpnSuggestSettings::class);
|
||||
$ipnSuggestSettings = $this->createStub(IpnSuggestSettings::class);
|
||||
|
||||
$ipnSuggestSettings->suggestPartDigits = 4;
|
||||
$ipnSuggestSettings->useDuplicateDescription = false;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Tests\Repository;
|
||||
|
||||
use App\Entity\Base\AbstractStructuralDBElement;
|
||||
use App\Entity\Attachments\AttachmentType;
|
||||
use App\Helpers\Trees\TreeViewNode;
|
||||
use App\Repository\StructuralDBElementRepository;
|
||||
|
|
@ -30,7 +31,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
|||
/**
|
||||
* @Group DB
|
||||
*/
|
||||
class StructuralDBElementRepositoryTest extends WebTestCase
|
||||
final class StructuralDBElementRepositoryTest extends WebTestCase
|
||||
{
|
||||
/**
|
||||
* @var StructuralDBElementRepository
|
||||
|
|
@ -108,6 +109,7 @@ class StructuralDBElementRepositoryTest extends WebTestCase
|
|||
{
|
||||
//List all nodes that are children to Node 1
|
||||
$node1 = $this->repo->find(1);
|
||||
$this->assertInstanceOf(AbstractStructuralDBElement::class, $node1);
|
||||
$nodes = $this->repo->getFlatList($node1);
|
||||
|
||||
$this->assertCount(3, $nodes);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ use App\Repository\UserRepository;
|
|||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
class UserRepositoryTest extends WebTestCase
|
||||
final class UserRepositoryTest extends WebTestCase
|
||||
{
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue