Skip to content

Commit

Permalink
Test enhancement about some PHPUnit stuffs
Browse files Browse the repository at this point in the history
  • Loading branch information
peter279k committed Aug 5, 2020
1 parent fbde45e commit ec025c5
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 20 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 1 addition & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -41,8 +41,5 @@
"psr-4": {
"PHPExperts\\DataTypeValidator\\Tests\\": "tests/"
}
},
"config": {
"classmap-authoritative": true
}
}
2 changes: 1 addition & 1 deletion tests/DataTypeValidatorAssertTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion tests/DataTypeValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
22 changes: 11 additions & 11 deletions tests/DataTypeValidatorTypesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion tests/IsAFuzzyDataTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class IsAFuzzyDataTypeTest extends TestCase
/** @var IsAFuzzyDataType */
private $isA;

public function setUp(): void
protected function setUp(): void
{
$this->isA = new IsAFuzzyDataType();

Expand Down
2 changes: 1 addition & 1 deletion tests/IsAStrictDataTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class IsAStrictDataTypeTest extends TestCase
/** @var IsAStrictDataType */
private $isA;

public function setUp(): void
protected function setUp(): void
{
$this->isA = new IsAStrictDataType();

Expand Down

0 comments on commit ec025c5

Please sign in to comment.