set(ApplicationService::SERVICE_ID, $this->createApplicationServiceMock()); ServiceManager::setServiceManager(new ServiceManager($config)); } /** * Data provider for the testTimetoDuration method * * @return array[] the parameters */ public function stringToCleanProvider(): array { return [ ['This is a simple text', '_', -1, 'This_is_a_simple_text'], ['This is a simple text', '-', 10, 'This_is_a_'], ['@à|`', '-', -1, '-à--'], ['@à|`', '-', 2, '-à'], ['This 4s @ \'stronger\' tèxte', '', -1, 'This_4s__stronger_tèxte'], ]; } /** * Test {@link tao_helpers_Display::} * * @dataProvider stringToCleanProvider */ public function testCleaner(string $input, string $joker, int $maxLength, string $expected): void { $this->assertEquals($expected, tao_helpers_Display::textCleaner($input, $joker, $maxLength)); } private function createApplicationServiceMock(): ApplicationService { $applicationServiceMock = $this->createMock(ApplicationService::class); $applicationServiceMock ->method('getDefaultEncoding') ->willReturn($this->defaultEncoding); return $applicationServiceMock; } }