0
0
Fork 0
mirror of https://github.com/kevinpapst/kimai2.git synced 2025-05-08 11:00:18 +00:00
kevinpapst_kimai2/tests/Utils/SearchTermPartTest.php
2025-05-05 18:18:00 +02:00

43 lines
1.2 KiB
PHP

<?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\Utils;
use App\Utils\SearchTermPart;
use PHPUnit\Framework\TestCase;
/**
* @covers \App\Utils\SearchTermPart
*/
class SearchTermPartTest extends TestCase
{
public static function getTestData(): array
{
return [
['foo bar test 1', 'foo bar test 1', null, false],
['foo:bar test 1', 'bar test 1', 'foo', false],
['foo:!bar test 1', 'bar test 1', 'foo', true],
['!bar', 'bar', null, true],
['bar', 'bar', null, false],
['hello:world', 'world', 'hello', false],
['hello:!world', 'world', 'hello', true],
];
}
/**
* @dataProvider getTestData
*/
public function testSearchTerm(string $term, string $expected, ?string $field, bool $excluded): void
{
$sut = new SearchTermPart($term);
self::assertEquals($expected, $sut->getTerm());
self::assertEquals($field, $sut->getField());
self::assertEquals($excluded, $sut->isExcluded());
}
}