assertEquals() in phpunit 9.5 no longer takes a delta parameter and has assertEqualsWithDelta() as a replacement. This means float get compared without a delta atm, and a recent phpunit release (9.5.25) has made float comparisons stricter resulting in test suite errors such as: 1) SubtaskTimeTrackingModelTest::testCalculateSubtaskTime Total spent Failed asserting that 3.3000000000000003 matches expected 3.3. tests/units/Model/SubtaskTimeTrackingModelTest.php:186 This replaces all assertEquals() calls that pass a delta value with assertEqualsWithDelta().
65 lines
2.1 KiB
PHP
65 lines
2.1 KiB
PHP
<?php
|
|
|
|
require_once __DIR__.'/../Base.php';
|
|
|
|
use Kanboard\Event\TaskEvent;
|
|
use Kanboard\Model\TaskCreationModel;
|
|
use Kanboard\Model\TaskFinderModel;
|
|
use Kanboard\Model\ProjectModel;
|
|
use Kanboard\Model\TaskModel;
|
|
use Kanboard\Action\TaskUpdateStartDate;
|
|
|
|
class TaskUpdateStartDateTest extends Base
|
|
{
|
|
public function testAction()
|
|
{
|
|
$projectModel = new ProjectModel($this->container);
|
|
$taskCreationModel = new TaskCreationModel($this->container);
|
|
$taskFinderModel = new TaskFinderModel($this->container);
|
|
|
|
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
|
|
$this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test')));
|
|
|
|
$event = new TaskEvent(array(
|
|
'task_id' => 1,
|
|
'task' => array(
|
|
'project_id' => 1,
|
|
'column_id' => 2,
|
|
)
|
|
));
|
|
|
|
$action = new TaskUpdateStartDate($this->container);
|
|
$action->setProjectId(1);
|
|
$action->setParam('column_id', 2);
|
|
|
|
$this->assertTrue($action->execute($event, TaskModel::EVENT_MOVE_COLUMN));
|
|
|
|
$task = $taskFinderModel->getById(1);
|
|
$this->assertNotEmpty($task);
|
|
$this->assertEqualsWithDelta(time(), $task['date_started'], 2, 'Date started delta');
|
|
}
|
|
|
|
public function testWithWrongColumn()
|
|
{
|
|
$projectModel = new ProjectModel($this->container);
|
|
$taskCreationModel = new TaskCreationModel($this->container);
|
|
|
|
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
|
|
$this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test')));
|
|
|
|
$event = new TaskEvent(array(
|
|
'task_id' => 1,
|
|
'task' => array(
|
|
'project_id' => 1,
|
|
'column_id' => 3,
|
|
)
|
|
));
|
|
|
|
$action = new TaskUpdateStartDate($this->container);
|
|
$action->setProjectId(1);
|
|
$action->setParam('column_id', 2);
|
|
|
|
$this->assertFalse($action->execute($event, TaskModel::EVENT_MOVE_COLUMN));
|
|
}
|
|
}
|