added new report: project view (#1738)

This commit is contained in:
Willian Gustavo Veiga
2021-03-09 19:19:11 -03:00
committed by GitHub
parent 0b7d551048
commit c34e9f576d
28 changed files with 892 additions and 83 deletions

View File

@@ -12,7 +12,6 @@ namespace App\Tests\Command;
use App\Command\InstallCommand;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Console\Command\Command;
/**
* @covers \App\Command\InstallCommand
@@ -25,7 +24,7 @@ class InstallCommandTest extends KernelTestCase
*/
protected $application;
protected function getCommand(): Command
protected function setUp(): void
{
$kernel = self::bootKernel();
$this->application = new Application($kernel);
@@ -35,7 +34,11 @@ class InstallCommandTest extends KernelTestCase
$container->getParameter('kernel.project_dir'),
$container->get('doctrine')->getConnection()
));
}
return $this->application->find('kimai:install');
public function testCommandName()
{
$command = $this->application->find('kimai:install');
self::assertInstanceOf(InstallCommand::class, $command);
}
}

View File

@@ -0,0 +1,60 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Tests\Controller\Reporting;
use App\Entity\User;
use App\Tests\Controller\ControllerBaseTest;
use App\Tests\DataFixtures\ActivityFixtures;
use App\Tests\DataFixtures\CustomerFixtures;
use App\Tests\DataFixtures\ProjectFixtures;
use App\Tests\DataFixtures\TimesheetFixtures;
/**
* @group integration
*/
class ProjectViewControllerTest extends ControllerBaseTest
{
public function testProjectViewIsSecure()
{
$this->assertUrlIsSecured('/reporting/project_view');
}
public function testProjectViewReport()
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
$customers = new CustomerFixtures();
$customers->setIsVisible(true);
$customers->setAmount(1);
$customers = $this->importFixture($customers);
$projects = new ProjectFixtures();
$projects->setCustomers($customers);
$projects->setAmount(2);
$projects->setIsVisible(true);
$projects = $this->importFixture($projects);
$activities = new ActivityFixtures();
$activities->setAmount(5);
$activities->setIsGlobal(true);
$activities = $this->importFixture($activities);
$timesheets = new TimesheetFixtures();
$timesheets->setAmount(50);
$timesheets->setActivities($activities);
$timesheets->setUser($this->getUserByRole(User::ROLE_TEAMLEAD));
$this->importFixture($timesheets);
$this->assertAccessIsGranted($client, '/reporting/project_view');
self::assertStringContainsString('<div class="box-body project-view-reporting-box', $client->getResponse()->getContent());
$rows = $client->getCrawler()->filterXPath("//table[@id='dt_project_view_reporting']/tbody/tr");
self::assertGreaterThan(0, $rows->count());
}
}

View File

@@ -0,0 +1,59 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Tests\Reporting\ProjectView;
use App\Entity\Project;
use App\Reporting\ProjectView\ProjectViewModel;
use PHPUnit\Framework\TestCase;
/**
* @covers \App\Reporting\ProjectView\ProjectViewModel
*/
class ProjectViewModelTest extends TestCase
{
public function testDefaults()
{
$sut = new ProjectViewModel();
self::assertNull($sut->getProject());
self::assertEquals(0, $sut->getDurationDay());
self::assertEquals(0, $sut->getDurationMonth());
self::assertEquals(0, $sut->getDurationTotal());
self::assertEquals(0, $sut->getDurationWeek());
self::assertEquals(0, $sut->getNotExportedDuration());
self::assertEquals(0, $sut->getNotExportedRate());
self::assertEquals(0, $sut->getRateTotal());
}
public function testSetterGetter()
{
$sut = new ProjectViewModel();
$project = new Project();
$sut->setProject($project);
self::assertSame($project, $sut->getProject());
$sut->setDurationDay(123456789);
$sut->setDurationMonth(23456789);
$sut->setDurationTotal(3456789);
$sut->setDurationWeek(456789);
$sut->setNotExportedDuration(56789);
$sut->setNotExportedRate(6789);
$sut->setRateTotal(789);
self::assertEquals(123456789, $sut->getDurationDay());
self::assertEquals(23456789, $sut->getDurationMonth());
self::assertEquals(3456789, $sut->getDurationTotal());
self::assertEquals(456789, $sut->getDurationWeek());
self::assertEquals(56789, $sut->getNotExportedDuration());
self::assertEquals(6789, $sut->getNotExportedRate());
self::assertEquals(789, $sut->getRateTotal());
}
}

View File

@@ -0,0 +1,51 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Tests\Reporting\ProjectView;
use App\Entity\Customer;
use App\Entity\User;
use App\Reporting\ProjectView\ProjectViewQuery;
use PHPUnit\Framework\TestCase;
/**
* @covers \App\Reporting\ProjectView\ProjectViewQuery
*/
class ProjectViewQueryTest extends TestCase
{
public function testDefaults()
{
$user = new User();
$date = new \DateTime();
$sut = new ProjectViewQuery($date, $user);
self::assertSame($date, $sut->getToday());
self::assertSame($user, $sut->getUser());
self::assertNull($sut->getCustomer());
self::assertFalse($sut->isIncludeNoBudget());
self::assertFalse($sut->isIncludeNoWork());
}
public function testSetterGetter()
{
$user = new User();
$date = new \DateTime();
$sut = new ProjectViewQuery($date, $user);
$customer = new Customer();
$sut->setCustomer($customer);
$sut->setIncludeNoBudget(true);
$sut->setIncludeNoWork(true);
self::assertSame($customer, $sut->getCustomer());
self::assertTrue($sut->isIncludeNoBudget());
self::assertTrue($sut->isIncludeNoWork());
}
}

View File

@@ -47,6 +47,6 @@ class ReportingServiceTest extends TestCase
$sut = $this->getSut(true);
$reports = $sut->getAvailableReports(new User());
self::assertIsArray($reports);
self::assertCount(3, $reports);
self::assertCount(4, $reports);
}
}

View File

@@ -38,6 +38,6 @@ class ReportingExtensionTest extends TestCase
$sut = $this->getSut(true);
$reports = $sut->getAvailableReports(new User());
$this->assertCount(3, $reports);
$this->assertCount(4, $reports);
}
}