added tags for timesheets (#604)

This commit is contained in:
Mathias
2019-05-12 01:40:04 +02:00
committed by Kevin Papst
parent f31118292c
commit e29e183e84
84 changed files with 2132 additions and 158 deletions

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\Export\Renderer;
use App\Entity\Tag;
use App\Form\DataTransformer\TagArrayToStringTransformer;
use App\Repository\TagRepository;
/**
* @covers \App\Form\DataTransformer\TagArrayToStringTransformer
*/
class TagArrayToStringTransformerTest extends AbstractRendererTest
{
public function testTransform()
{
$results = [
(new Tag())->setName('foo'),
(new Tag())->setName('bar'),
];
$repository = $this->getMockBuilder(TagRepository::class)->disableOriginalConstructor()->getMock();
$sut = new TagArrayToStringTransformer($repository);
$this->assertEquals('', $sut->transform([]));
$this->assertEquals('', $sut->transform(null));
$actual = $sut->transform($results);
$this->assertEquals('foo, bar', $actual);
}
public function testReverseTransform()
{
$results = [
(new Tag())->setName('foo'),
(new Tag())->setName('bar'),
];
$repository = $this->getMockBuilder(TagRepository::class)->setMethods(['findBy'])->disableOriginalConstructor()->getMock();
$repository->expects($this->once())->method('findBy')->willReturn($results);
$sut = new TagArrayToStringTransformer($repository);
$this->assertEquals([], $sut->reverseTransform(''));
$this->assertEquals([], $sut->reverseTransform(null));
$actual = $sut->reverseTransform('foo, bar');
$this->assertEquals($results, $actual);
}
}