mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-18 01:45:07 +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 StructuralDBElementTest extends TestCase
|
|||
protected $child1_1;
|
||||
protected $child1_2;
|
||||
|
||||
public function setUp(): void
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp(); // TODO: Change the autogenerated stub
|
||||
|
||||
|
@ -58,14 +61,14 @@ class StructuralDBElementTest extends TestCase
|
|||
$this->child1_2->setName('child1_2')->setParent($this->child1);
|
||||
}
|
||||
|
||||
public function testIsRoot()
|
||||
public function testIsRoot(): void
|
||||
{
|
||||
$this->assertTrue($this->root->isRoot());
|
||||
$this->assertFalse($this->child1->isRoot());
|
||||
$this->assertFalse($this->child1_2->isRoot());
|
||||
}
|
||||
|
||||
public function testIsChildOf()
|
||||
public function testIsChildOf(): void
|
||||
{
|
||||
//Root must not be the child of any other node
|
||||
$this->assertFalse($this->root->isChildOf($this->child1));
|
||||
|
@ -79,14 +82,14 @@ class StructuralDBElementTest extends TestCase
|
|||
$this->assertTrue($this->child1_2->isChildOf($this->root));
|
||||
}
|
||||
|
||||
public function testChildOfDifferentClasses()
|
||||
public function testChildOfDifferentClasses(): void
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$category = new Category();
|
||||
$this->root->isChildOf($category);
|
||||
}
|
||||
|
||||
public function testChildOfExtendedClass()
|
||||
public function testChildOfExtendedClass(): void
|
||||
{
|
||||
//Doctrine extends the entities for proxy classes so the isChildOf mus also work for inheritance types
|
||||
$inheritance = new class() extends AttachmentType {
|
||||
|
@ -96,25 +99,25 @@ class StructuralDBElementTest extends TestCase
|
|||
$this->assertFalse($this->root->isChildOf($inheritance));
|
||||
}
|
||||
|
||||
public function testGetLevel()
|
||||
public function testGetLevel(): void
|
||||
{
|
||||
$this->assertEquals(0, $this->root->getLevel());
|
||||
$this->assertEquals(1, $this->child1->getLevel());
|
||||
$this->assertSame(0, $this->root->getLevel());
|
||||
$this->assertSame(1, $this->child1->getLevel());
|
||||
$this->assertSame(1, $this->child2->getLevel());
|
||||
$this->assertSame(2, $this->child1_2->getLevel());
|
||||
$this->assertSame(2, $this->child1_1->getLevel());
|
||||
}
|
||||
|
||||
public function testGetFullPath()
|
||||
public function testGetFullPath(): void
|
||||
{
|
||||
$this->assertSame('root/child1/child1_1', $this->child1_1->getFullPath('/'));
|
||||
$this->assertSame('root#child2', $this->child2->getFullPath('#'));
|
||||
}
|
||||
|
||||
public function testGetPathArray()
|
||||
public function testGetPathArray(): void
|
||||
{
|
||||
$this->assertEquals([$this->root, $this->child1, $this->child1_1], $this->child1_1->getPathArray());
|
||||
$this->assertEquals([$this->root, $this->child1], $this->child1->getPathArray());
|
||||
$this->assertEquals([$this->root], $this->root->getPathArray());
|
||||
$this->assertSame([$this->root, $this->child1, $this->child1_1], $this->child1_1->getPathArray());
|
||||
$this->assertSame([$this->root, $this->child1], $this->child1->getPathArray());
|
||||
$this->assertSame([$this->root], $this->root->getPathArray());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue