mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-09 18:04:33 +02:00
Use new cached treeview nodes for twig inline generator (admin pages)
This commit is contained in:
parent
ad69c32832
commit
d9b15ddbb9
20 changed files with 277 additions and 214 deletions
|
@ -1,76 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
namespace App\Tests\Services\Trees;
|
||||
|
||||
use App\Entity\Attachments\AttachmentType;
|
||||
use App\Helpers\TreeViewNode;
|
||||
use App\Services\AmountFormatter;
|
||||
use App\Services\Trees\TreeViewGenerator;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
/**
|
||||
* @group DB
|
||||
*/
|
||||
class TreeGeneratorTest extends WebTestCase
|
||||
{
|
||||
/**
|
||||
* @var TreeViewGenerator
|
||||
*/
|
||||
protected $service;
|
||||
|
||||
public function setUp() : void
|
||||
{
|
||||
parent::setUp(); // TODO: Change the autogenerated stub
|
||||
|
||||
//Get an service instance.
|
||||
self::bootKernel();
|
||||
$this->service = self::$container->get(TreeViewGenerator::class);
|
||||
}
|
||||
|
||||
public function testGetGenericTree()
|
||||
{
|
||||
$tree = $this->service->getGenericTree(AttachmentType::class, null);
|
||||
|
||||
$this->assertIsArray($tree);
|
||||
$this->assertContainsOnlyInstancesOf(TreeViewNode::class, $tree);
|
||||
|
||||
$this->assertCount(3, $tree);
|
||||
$this->assertCount(2, $tree[0]->getNodes());
|
||||
$this->assertCount(1, $tree[0]->getNodes()[0]->getNodes());
|
||||
$this->assertEmpty($tree[2]->getNodes());
|
||||
$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());
|
||||
|
||||
//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());
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue