* @copyright Meritoo * * @internal * @covers \Meritoo\Common\Traits\Test\Base\BaseTestCaseTrait */ class BaseTestCaseTraitTest extends BaseTestCase { public function testProvideEmptyValue(): void { $testCase = new SimpleTestCase(); $values = $testCase->provideEmptyValue(); $expected = [ [''], [' '], [null], [0], [false], [[]], ]; foreach ($values as $index => $value) { static::assertSame($expected[$index], $value); } } public function testProvideEmptyScalarValue(): void { $testCase = new SimpleTestCase(); $values = $testCase->provideEmptyScalarValue(); $expected = [ [''], [' '], [null], [0], [false], ]; foreach ($values as $index => $value) { static::assertSame($expected[$index], $value); } } public function testProvideBooleanValue(): void { $testCase = new SimpleTestCase(); $values = $testCase->provideBooleanValue(); $expected = [ [false], [true], ]; foreach ($values as $index => $value) { static::assertSame($expected[$index], $value); } } public function testProvideDateTimeInstance(): void { $testCase = new SimpleTestCase(); $instances = $testCase->provideDateTimeInstance(); $expected = [ [new DateTime()], [new DateTime('yesterday')], [new DateTime('now')], [new DateTime('tomorrow')], ]; foreach ($instances as $index => $instance) { /** @var DateTime $expectedInstance */ $expectedInstance = $expected[$index][0]; /** @var DateTime $instance */ $instance = $instance[0]; static::assertInstanceOf(DateTime::class, $instance); static::assertEquals($expectedInstance->getTimestamp(), $instance->getTimestamp()); } } public function testProvideDateTimeRelativeFormatInstance(): void { $testCase = new SimpleTestCase(); $formats = $testCase->provideDateTimeRelativeFormat(); $expected = [ ['now'], ['yesterday'], ['tomorrow'], ['back of 10'], ['front of 10'], ['last day of February'], ['first day of next month'], ['last day of previous month'], ['last day of next month'], ['Y-m-d'], ['Y-m-d 10:00'], ]; foreach ($formats as $index => $format) { static::assertSame($expected[$index], $format); } } public function testProvideNotExistingFilePath(): void { $testCase = new SimpleTestCase(); $paths = $testCase->provideNotExistingFilePath(); $expected = [ ['lets-test.doc'], ['lorem/ipsum.jpg'], ['surprise/me/one/more/time.txt'], ]; foreach ($paths as $index => $path) { static::assertSame($expected[$index], $path); } } public function testProvideNonScalarValue(): void { $testCase = new SimpleTestCase(); $values = $testCase->provideNonScalarValue(); $expected = [ [[]], [null], [new stdClass()], ]; foreach ($values as $index => $value) { static::assertEquals($expected[$index], $value); } } }