From ec025c5fbb24097738b137ecaeabcdf25ae211e5 Mon Sep 17 00:00:00 2001 From: peter279k Date: Tue, 28 Jul 2020 22:39:05 +0800 Subject: [PATCH] Test enhancement about some PHPUnit stuffs --- .travis.yml | 3 ++- composer.json | 5 +---- tests/DataTypeValidatorAssertTest.php | 2 +- tests/DataTypeValidatorTest.php | 2 +- tests/DataTypeValidatorTypesTest.php | 22 +++++++++++----------- tests/IsAFuzzyDataTypeTest.php | 2 +- tests/IsAStrictDataTypeTest.php | 2 +- 7 files changed, 18 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index e156f68..f244d6f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ php: - '7.1' - '7.2' - '7.3' + - '7.4' before_script: - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter @@ -12,7 +13,7 @@ before_script: - travis_retry composer self-update - travis_retry composer install --no-interaction --prefer-source -script: +script: - mkdir -p build/logs - php vendor/bin/phpstan analyze --level max src - vendor/bin/phpunit --coverage-text --coverage-clover build/logs/clover.xml diff --git a/composer.json b/composer.json index fcc00be..1dec5e5 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ "phpunit/phpunit": "7.*|8.*", "symfony/var-dumper": "^4.2", "phpstan/phpstan": "^0.11.6", - "carbondate/carbon": "^1.33", + "nesbot/carbon": "^2.37", "phpbench/phpbench": "^0.16.9" }, "autoload": { @@ -41,8 +41,5 @@ "psr-4": { "PHPExperts\\DataTypeValidator\\Tests\\": "tests/" } - }, - "config": { - "classmap-authoritative": true } } diff --git a/tests/DataTypeValidatorAssertTest.php b/tests/DataTypeValidatorAssertTest.php index 850d3e6..88fddf9 100644 --- a/tests/DataTypeValidatorAssertTest.php +++ b/tests/DataTypeValidatorAssertTest.php @@ -29,7 +29,7 @@ class DataTypeValidatorAssertTest extends TestCase /** @var DataTypeValidator */ private $fuzzy; - public function setUp(): void + protected function setUp(): void { $this->strict = new DataTypeValidator(new IsAStrictDataType()); $this->fuzzy = new DataTypeValidator(new IsAFuzzyDataType()); diff --git a/tests/DataTypeValidatorTest.php b/tests/DataTypeValidatorTest.php index b5856b7..a547f5b 100644 --- a/tests/DataTypeValidatorTest.php +++ b/tests/DataTypeValidatorTest.php @@ -30,7 +30,7 @@ class DataTypeValidatorTest extends TestCase /** @var DataTypeValidator */ private $fuzzy; - public function setUp(): void + protected function setUp(): void { $this->strict = new DataTypeValidator(new IsAStrictDataType()); $this->fuzzy = new DataTypeValidator(new IsAFuzzyDataType()); diff --git a/tests/DataTypeValidatorTypesTest.php b/tests/DataTypeValidatorTypesTest.php index 81abc11..2feacd2 100644 --- a/tests/DataTypeValidatorTypesTest.php +++ b/tests/DataTypeValidatorTypesTest.php @@ -28,7 +28,7 @@ class DataTypeValidatorTypesTest extends TestCase /** @var DataTypeValidator */ private $fuzzy; - public function setUp(): void + protected function setUp(): void { $this->strict = new DataTypeValidator(new IsAStrictDataType()); $this->fuzzy = new DataTypeValidator(new IsAFuzzyDataType()); @@ -177,21 +177,21 @@ public function testWillValidateResources() public function testWillValidateObjectsByTheirShortName() { - $this->assertTrue($this->strict->isFuzzyObject($this->strict, 'DataTypeValidator')); - $this->assertTrue($this->fuzzy->isFuzzyObject($this->fuzzy, 'DataTypeValidator')); - $this->assertFalse($this->strict->isFuzzyObject($this->strict, 'doesntexist')); - $this->assertFalse($this->fuzzy->isFuzzyObject($this->fuzzy, 'doesntexist')); + self::assertTrue($this->strict->isFuzzyObject($this->strict, 'DataTypeValidator')); + self::assertTrue($this->fuzzy->isFuzzyObject($this->fuzzy, 'DataTypeValidator')); + self::assertFalse($this->strict->isFuzzyObject($this->strict, 'doesntexist')); + self::assertFalse($this->fuzzy->isFuzzyObject($this->fuzzy, 'doesntexist')); } public function testWillValidateObjectsByTheirFullName() { - $this->assertTrue($this->strict->isSpecificObject($this->strict, DataTypeValidator::class)); - $this->assertTrue($this->fuzzy->isSpecificObject($this->fuzzy, DataTypeValidator::class)); + self::assertTrue($this->strict->isSpecificObject($this->strict, DataTypeValidator::class)); + self::assertTrue($this->fuzzy->isSpecificObject($this->fuzzy, DataTypeValidator::class)); - $this->assertFalse($this->strict->isSpecificObject($this->strict, 'DataTypeValidator')); - $this->assertFalse($this->fuzzy->isSpecificObject($this->fuzzy, 'DataTypeValidator')); - $this->assertFalse($this->strict->isSpecificObject($this->strict, 'doesntexist')); - $this->assertFalse($this->fuzzy->isSpecificObject($this->fuzzy, 'doesntexist')); + self::assertFalse($this->strict->isSpecificObject($this->strict, 'DataTypeValidator')); + self::assertFalse($this->fuzzy->isSpecificObject($this->fuzzy, 'DataTypeValidator')); + self::assertFalse($this->strict->isSpecificObject($this->strict, 'doesntexist')); + self::assertFalse($this->fuzzy->isSpecificObject($this->fuzzy, 'doesntexist')); } public function testCanValidateBoolsLoosely() diff --git a/tests/IsAFuzzyDataTypeTest.php b/tests/IsAFuzzyDataTypeTest.php index 5c1dd74..c7e8eb2 100644 --- a/tests/IsAFuzzyDataTypeTest.php +++ b/tests/IsAFuzzyDataTypeTest.php @@ -23,7 +23,7 @@ class IsAFuzzyDataTypeTest extends TestCase /** @var IsAFuzzyDataType */ private $isA; - public function setUp(): void + protected function setUp(): void { $this->isA = new IsAFuzzyDataType(); diff --git a/tests/IsAStrictDataTypeTest.php b/tests/IsAStrictDataTypeTest.php index 1efcf2a..224a434 100644 --- a/tests/IsAStrictDataTypeTest.php +++ b/tests/IsAStrictDataTypeTest.php @@ -23,7 +23,7 @@ class IsAStrictDataTypeTest extends TestCase /** @var IsAStrictDataType */ private $isA; - public function setUp(): void + protected function setUp(): void { $this->isA = new IsAStrictDataType();