added hourly and money budgets to activity, project and customer (#843)
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
<?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\Form\DataTransformer;
|
||||
|
||||
use App\Form\DataTransformer\DurationStringToSecondsTransformer;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Form\DataTransformer\DurationStringToSecondsTransformer
|
||||
*/
|
||||
class DurationStringToSecondsTransformerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var DurationStringToSecondsTransformer
|
||||
*/
|
||||
private $sut;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->sut = new DurationStringToSecondsTransformer();
|
||||
}
|
||||
|
||||
public function getValidTestDataTransform()
|
||||
{
|
||||
return [
|
||||
['00:00', '0'],
|
||||
['00:00', 0],
|
||||
['02:00', 7213], // by default no seconds are returned
|
||||
[null, null],
|
||||
];
|
||||
}
|
||||
|
||||
public function getInvalidTestDataTransform()
|
||||
{
|
||||
return [
|
||||
[''],
|
||||
['xxx'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidTestDataTransform
|
||||
*/
|
||||
public function testTransform($expected, $transform)
|
||||
{
|
||||
$this->assertEquals($expected, $this->sut->transform($transform));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidTestDataTransform
|
||||
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
|
||||
*/
|
||||
public function testInvalidTransformThrowsException($transform)
|
||||
{
|
||||
$this->sut->transform($transform);
|
||||
}
|
||||
|
||||
public function getValidTestDataReverseTransform()
|
||||
{
|
||||
return [
|
||||
['2h3s', 7203],
|
||||
['00:00', 0],
|
||||
['0', null],
|
||||
[null, null],
|
||||
];
|
||||
}
|
||||
|
||||
public function getInvalidTestDataReverseTransform()
|
||||
{
|
||||
return [
|
||||
['xxx'],
|
||||
[':::'],
|
||||
['0::0'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidTestDataReverseTransform
|
||||
*/
|
||||
public function testReverseTransform($transform, $expected)
|
||||
{
|
||||
$this->assertEquals($expected, $this->sut->reverseTransform($transform));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidTestDataReverseTransform
|
||||
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
|
||||
*/
|
||||
public function testInvalidReverseTransformThrowsException($transform)
|
||||
{
|
||||
$this->sut->reverseTransform($transform);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user