mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-24 04:44:35 +02:00
Applied code style to tests/
This commit is contained in:
parent
f861de791f
commit
fe0f69f762
44 changed files with 427 additions and 306 deletions
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -39,7 +42,7 @@ class TreeViewGeneratorTest extends WebTestCase
|
|||
protected $service;
|
||||
protected $em;
|
||||
|
||||
public function setUp(): void
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp(); // TODO: Change the autogenerated stub
|
||||
|
||||
|
@ -49,7 +52,7 @@ class TreeViewGeneratorTest extends WebTestCase
|
|||
$this->em = self::$container->get(EntityManagerInterface::class);
|
||||
}
|
||||
|
||||
public function testGetGenericTree()
|
||||
public function testGetGenericTree(): void
|
||||
{
|
||||
$tree = $this->service->getGenericTree(AttachmentType::class, null);
|
||||
|
||||
|
@ -63,19 +66,19 @@ class TreeViewGeneratorTest extends WebTestCase
|
|||
$this->assertEmpty($tree[1]->getNodes()[0]->getNodes());
|
||||
|
||||
//Check text
|
||||
$this->assertEquals('Node 1', $tree[0]->getText());
|
||||
$this->assertEquals('Node 2', $tree[1]->getText());
|
||||
$this->assertEquals('Node 3', $tree[2]->getText());
|
||||
$this->assertEquals('Node 1.1', $tree[0]->getNodes()[0]->getText());
|
||||
$this->assertEquals('Node 1.1.1', $tree[0]->getNodes()[0]->getNodes()[0]->getText());
|
||||
$this->assertSame('Node 1', $tree[0]->getText());
|
||||
$this->assertSame('Node 2', $tree[1]->getText());
|
||||
$this->assertSame('Node 3', $tree[2]->getText());
|
||||
$this->assertSame('Node 1.1', $tree[0]->getNodes()[0]->getText());
|
||||
$this->assertSame('Node 1.1.1', $tree[0]->getNodes()[0]->getNodes()[0]->getText());
|
||||
|
||||
//Check that IDs were set correctly
|
||||
$this->assertEquals(1, $tree[0]->getId());
|
||||
$this->assertEquals(2, $tree[1]->getId());
|
||||
$this->assertEquals(7, $tree[0]->getNodes()[0]->getNodes()[0]->getId());
|
||||
$this->assertSame(1, $tree[0]->getId());
|
||||
$this->assertSame(2, $tree[1]->getId());
|
||||
$this->assertSame(7, $tree[0]->getNodes()[0]->getNodes()[0]->getId());
|
||||
}
|
||||
|
||||
public function testGetTreeViewBasic()
|
||||
public function testGetTreeViewBasic(): void
|
||||
{
|
||||
$tree = $this->service->getTreeView(Category::class);
|
||||
$this->assertIsArray($tree);
|
||||
|
@ -86,30 +89,30 @@ class TreeViewGeneratorTest extends WebTestCase
|
|||
$this->assertCount(1, $tree[0]->getNodes()[0]->getNodes());
|
||||
|
||||
//Assert that the nodes contain the correct links
|
||||
$this->assertEquals('/en/category/1/parts', $tree[0]->getHref());
|
||||
$this->assertEquals('/en/category/2/parts', $tree[1]->getHref());
|
||||
$this->assertEquals('/en/category/7/parts', $tree[0]->getNodes()[0]->getNodes()[0]->getHref());
|
||||
$this->assertSame('/en/category/1/parts', $tree[0]->getHref());
|
||||
$this->assertSame('/en/category/2/parts', $tree[1]->getHref());
|
||||
$this->assertSame('/en/category/7/parts', $tree[0]->getNodes()[0]->getNodes()[0]->getHref());
|
||||
}
|
||||
|
||||
public function testGetTreeViewNewEdit()
|
||||
public function testGetTreeViewNewEdit(): void
|
||||
{
|
||||
$tree = $this->service->getTreeView(Category::class, null, 'newEdit');
|
||||
|
||||
//First element should link to new category
|
||||
$this->assertStringContainsStringIgnoringCase('New', $tree[0]->getText());
|
||||
$this->assertEquals('/en/category/new', $tree[0]->getHref());
|
||||
$this->assertSame('/en/category/new', $tree[0]->getHref());
|
||||
//By default the new element node is selected
|
||||
$this->assertTrue($tree[0]->getState()->getSelected());
|
||||
|
||||
//Next element is spacing
|
||||
$this->assertEquals('', $tree[1]->getText());
|
||||
$this->assertSame('', $tree[1]->getText());
|
||||
$this->assertTrue($tree[1]->getState()->getDisabled());
|
||||
|
||||
//All other elements should be normal
|
||||
$this->assertCount(5, $tree);
|
||||
}
|
||||
|
||||
public function testGetTreeViewSelectedNode()
|
||||
public function testGetTreeViewSelectedNode(): void
|
||||
{
|
||||
$selected = $this->em->find(Category::class, 2);
|
||||
$tree = $this->service->getTreeView(Category::class, null, 'edit', $selected);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue