Next major version 2 with PHP 8.1, Symfony 6, Tabler UI, 2FA ... (#2902)
This commit is contained in:
@@ -78,6 +78,7 @@ class ActivityEditFormTest extends TypeTestCase
|
||||
{
|
||||
$model = $this->createMock(Activity::class);
|
||||
$model->expects($this->once())->method('getId')->willReturn(1);
|
||||
$model->expects($this->atLeast(1))->method('isGlobal')->willReturn(true);
|
||||
$form = $this->factory->createBuilder(ActivityEditForm::class, $model, [
|
||||
'include_budget' => true,
|
||||
]);
|
||||
@@ -89,7 +90,7 @@ class ActivityEditFormTest extends TypeTestCase
|
||||
public function testWithNonGlobalExistingActivityAndOptions()
|
||||
{
|
||||
$project = new Project();
|
||||
$customer = new Customer();
|
||||
$customer = new Customer('foo');
|
||||
$project->setCustomer($customer);
|
||||
$model = $this->createMock(Activity::class);
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ class CustomerEditFormTest extends TypeTestCase
|
||||
{
|
||||
public function testWithNewProject()
|
||||
{
|
||||
$model = new Customer();
|
||||
$model = new Customer('foo');
|
||||
$form = $this->factory->createBuilder(CustomerEditForm::class, $model);
|
||||
|
||||
$attr = $form->getFormConfig()->getOption('attr');
|
||||
@@ -39,7 +39,7 @@ class CustomerEditFormTest extends TypeTestCase
|
||||
|
||||
public function testWithBudget()
|
||||
{
|
||||
$model = new Customer();
|
||||
$model = new Customer('foo');
|
||||
$form = $this->factory->createBuilder(CustomerEditForm::class, $model, [
|
||||
'include_budget' => true,
|
||||
]);
|
||||
@@ -50,7 +50,7 @@ class CustomerEditFormTest extends TypeTestCase
|
||||
|
||||
public function testWithTimeBudget()
|
||||
{
|
||||
$model = new Customer();
|
||||
$model = new Customer('foo');
|
||||
$form = $this->factory->createBuilder(CustomerEditForm::class, $model, [
|
||||
'include_time' => true,
|
||||
]);
|
||||
@@ -61,7 +61,7 @@ class CustomerEditFormTest extends TypeTestCase
|
||||
|
||||
public function testWithBudgetAndTimeBudget()
|
||||
{
|
||||
$model = new Customer();
|
||||
$model = new Customer('foo');
|
||||
$form = $this->factory->createBuilder(CustomerEditForm::class, $model, [
|
||||
'include_budget' => true,
|
||||
'include_time' => true,
|
||||
|
||||
@@ -31,9 +31,9 @@ class DurationStringToSecondsTransformerTest extends TestCase
|
||||
public function getValidTestDataTransform()
|
||||
{
|
||||
return [
|
||||
['00:00', '0'],
|
||||
['00:00', 0],
|
||||
['02:00', 7213], // by default no seconds are returned
|
||||
['0:00', '0'],
|
||||
['0:00', 0],
|
||||
['2:00', 7213], // by default no seconds are returned
|
||||
[null, null],
|
||||
];
|
||||
}
|
||||
@@ -68,7 +68,7 @@ class DurationStringToSecondsTransformerTest extends TestCase
|
||||
{
|
||||
return [
|
||||
['2h3s', 7203],
|
||||
['00:00', 0],
|
||||
['0:00', 0],
|
||||
['0', null],
|
||||
[null, null],
|
||||
['87600000000:00:00', 315360000000000],
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
<?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;
|
||||
|
||||
use App\Form\FormTrait;
|
||||
use App\Tests\Form\Type\TypeTestModel;
|
||||
use Symfony\Component\Form\Extension\Core\Type\FormType;
|
||||
use Symfony\Component\Form\Test\TypeTestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Form\FormTrait
|
||||
*/
|
||||
class FormTraitTest extends TypeTestCase
|
||||
{
|
||||
use FormTrait;
|
||||
|
||||
/**
|
||||
* @expectedDeprecation FormTrait::addDescription() is deprecated and will be removed with 2.0, use DescriptionType instead
|
||||
* @group legacy
|
||||
*/
|
||||
public function testAddDescription()
|
||||
{
|
||||
$data = ['description' => 'foo'];
|
||||
$model = new TypeTestModel(['description' => 'bar']);
|
||||
|
||||
$form = $this->factory->createBuilder(FormType::class, $model);
|
||||
$this->addDescription($form);
|
||||
|
||||
$desc = $form->get('description');
|
||||
self::assertArrayHasKey('autofocus', $desc->getOption('attr'));
|
||||
self::assertEquals('autofocus', $desc->getOption('attr')['autofocus']);
|
||||
|
||||
$form = $form->getForm();
|
||||
|
||||
$desc = $form->get('description');
|
||||
self::assertFalse($desc->isRequired());
|
||||
|
||||
$expected = new TypeTestModel([
|
||||
'description' => 'foo'
|
||||
]);
|
||||
|
||||
$form->submit($data);
|
||||
|
||||
$this->assertTrue($form->isSynchronized());
|
||||
$this->assertEquals($expected, $model);
|
||||
}
|
||||
}
|
||||
@@ -28,15 +28,14 @@ class SystemConfigurationTest extends TestCase
|
||||
|
||||
public function testSetterAndGetter()
|
||||
{
|
||||
$sut = new SystemConfiguration();
|
||||
$sut = new SystemConfiguration('foo');
|
||||
|
||||
self::assertInstanceOf(SystemConfiguration::class, $sut->setSection('foo'));
|
||||
self::assertEquals('foo', $sut->getSection());
|
||||
|
||||
self::assertInstanceOf(SystemConfiguration::class, $sut->setConfiguration([]));
|
||||
self::assertEquals([], $sut->getConfiguration());
|
||||
|
||||
$config = new Configuration();
|
||||
$config = new Configuration('1');
|
||||
self::assertInstanceOf(SystemConfiguration::class, $sut->setConfiguration([$config]));
|
||||
self::assertEquals([$config], $sut->getConfiguration());
|
||||
|
||||
@@ -46,12 +45,10 @@ class SystemConfigurationTest extends TestCase
|
||||
self::assertInstanceOf(SystemConfiguration::class, $sut->addConfiguration($config));
|
||||
self::assertEquals([$config, $config, $config], $sut->getConfiguration());
|
||||
|
||||
$config = new Configuration();
|
||||
$config->setName('foo');
|
||||
$config = new Configuration('foo');
|
||||
$sut->addConfiguration($config);
|
||||
|
||||
$config2 = new Configuration();
|
||||
$config2->setName('bar');
|
||||
$config2 = new Configuration('bar');
|
||||
$sut->addConfiguration($config2);
|
||||
|
||||
self::assertSame($config, $sut->getConfigurationByName('foo'));
|
||||
|
||||
@@ -43,7 +43,7 @@ class MultiUpdateTableDTOTest extends TestCase
|
||||
[
|
||||
'' => '',
|
||||
'action.edit' => 'foo',
|
||||
'action.delete' => 'bar',
|
||||
'delete' => 'bar',
|
||||
'test' => 'hello/world'
|
||||
],
|
||||
$sut->getActions()
|
||||
@@ -54,7 +54,7 @@ class MultiUpdateTableDTOTest extends TestCase
|
||||
|
||||
$activity = new Activity();
|
||||
$project = new Project();
|
||||
$customer = new Customer();
|
||||
$customer = new Customer('foo');
|
||||
$timesheet = new Timesheet();
|
||||
$tag = new Tag();
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ class TimesheetMultiUpdateDTOTest extends TestCase
|
||||
[
|
||||
'' => '',
|
||||
'action.edit' => 'foo',
|
||||
'action.delete' => 'bar',
|
||||
'delete' => 'bar',
|
||||
'test' => 'hello/world'
|
||||
],
|
||||
$sut->getActions()
|
||||
@@ -89,7 +89,8 @@ class TimesheetMultiUpdateDTOTest extends TestCase
|
||||
$sut->setReplaceTags(true);
|
||||
self::assertTrue($sut->isReplaceTags());
|
||||
|
||||
$user = (new User())->setUsername('sdfsdfsd');
|
||||
$user = new User();
|
||||
$user->setUserIdentifier('sdfsdfsd');
|
||||
$sut->setUser($user);
|
||||
self::assertSame($user, $sut->getUser());
|
||||
|
||||
@@ -101,7 +102,7 @@ class TimesheetMultiUpdateDTOTest extends TestCase
|
||||
$sut->setProject($project);
|
||||
self::assertSame($project, $sut->getProject());
|
||||
|
||||
$customer = (new Customer())->setName('sdfsdfsd');
|
||||
$customer = new Customer('sdfsdfsd');
|
||||
$sut->setCustomer($customer);
|
||||
self::assertSame($customer, $sut->getCustomer());
|
||||
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
<?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\Type;
|
||||
|
||||
use App\Form\Type\APIDateTimeType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\FormType;
|
||||
use Symfony\Component\Form\Test\TypeTestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Form\Type\APIDateTimeType
|
||||
*/
|
||||
class APIDateTimeTypeTest extends TypeTestCase
|
||||
{
|
||||
public function testSubmitValidData()
|
||||
{
|
||||
$data = ['date' => '2020-09-17T13:24:56'];
|
||||
$model = new TypeTestModel(['date' => new \DateTime()]);
|
||||
|
||||
$form = $this->factory->createBuilder(FormType::class, $model);
|
||||
$form->add('date', APIDateTimeType::class);
|
||||
$form = $form->getForm();
|
||||
|
||||
$expected = new TypeTestModel([
|
||||
'date' => new \DateTime('2020-09-17T13:24:56')
|
||||
]);
|
||||
|
||||
$form->submit($data);
|
||||
|
||||
$this->assertTrue($form->isSynchronized());
|
||||
$this->assertEquals($expected, $model);
|
||||
}
|
||||
|
||||
public function testAttributes()
|
||||
{
|
||||
$data = ['date' => '2020-09-17T13:24:56'];
|
||||
$model = new TypeTestModel(['date' => new \DateTime()]);
|
||||
|
||||
$form = $this->factory->createBuilder(FormType::class, $model);
|
||||
$form->add('date', APIDateTimeType::class, [
|
||||
'model_timezone' => 'Pacific/Tongatapu',
|
||||
'view_timezone' => 'Pacific/Tongatapu',
|
||||
]);
|
||||
$form = $form->getForm();
|
||||
|
||||
$expected = new TypeTestModel([
|
||||
'date' => new \DateTime('2020-09-17T13:24:56', new \DateTimeZone('Pacific/Tongatapu'))
|
||||
]);
|
||||
|
||||
$form->submit($data);
|
||||
|
||||
$this->assertTrue($form->isSynchronized());
|
||||
$this->assertEquals($expected, $model);
|
||||
}
|
||||
}
|
||||
@@ -28,26 +28,7 @@ class MinuteIncrementTypeTest extends TypeTestCase
|
||||
$form = $form->getForm();
|
||||
|
||||
$expected = new TypeTestModel([
|
||||
'increment' => '3'
|
||||
]);
|
||||
|
||||
$form->submit($data);
|
||||
|
||||
$this->assertTrue($form->isSynchronized());
|
||||
$this->assertEquals($expected, $model);
|
||||
}
|
||||
|
||||
public function testSubmitValidDataWithoutDeactivate()
|
||||
{
|
||||
$data = ['increment' => 4];
|
||||
$model = new TypeTestModel(['increment' => 5]);
|
||||
|
||||
$form = $this->factory->createBuilder(FormType::class, $model);
|
||||
$form->add('increment', MinuteIncrementType::class, ['deactivate' => false]);
|
||||
$form = $form->getForm();
|
||||
|
||||
$expected = new TypeTestModel([
|
||||
'increment' => '4'
|
||||
'increment' => 5
|
||||
]);
|
||||
|
||||
$form->submit($data);
|
||||
@@ -60,19 +41,8 @@ class MinuteIncrementTypeTest extends TypeTestCase
|
||||
{
|
||||
$view = $this->factory->create(MinuteIncrementType::class, 3600, [])->createView();
|
||||
self::assertArrayHasKey('choices', $view->vars);
|
||||
self::assertCount(16, $view->vars['choices']);
|
||||
self::assertEquals(null, $view->vars['choices'][0]->data);
|
||||
self::assertEquals(0, $view->vars['choices'][1]->data);
|
||||
self::assertEquals(1, $view->vars['choices'][2]->data);
|
||||
}
|
||||
|
||||
public function testPresetPopulatesViewWithoutDeactivate()
|
||||
{
|
||||
$view = $this->factory->create(MinuteIncrementType::class, 3600, ['deactivate' => false])->createView();
|
||||
self::assertArrayHasKey('choices', $view->vars);
|
||||
self::assertCount(15, $view->vars['choices']);
|
||||
self::assertEquals(null, $view->vars['choices'][0]->data);
|
||||
self::assertEquals(1, $view->vars['choices'][1]->data);
|
||||
self::assertEquals(2, $view->vars['choices'][2]->data);
|
||||
self::assertCount(13, $view->vars['choices']);
|
||||
self::assertEquals(0, $view->vars['choices'][0]->data);
|
||||
self::assertEquals(20, $view->vars['choices'][8]->data);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user