Skip to content

Commit f9631b6

Browse files
ISSUE-192: Upgraded to PHPunit 8.5
1 parent b9f060d commit f9631b6

File tree

6 files changed

+31
-27
lines changed

6 files changed

+31
-27
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
/.phpunit.result.cache
12
/composer.lock
23
/vendor/

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"symfony/validator": "5.0.*"
1515
},
1616
"require-dev": {
17-
"phpunit/phpunit": "^7.5"
17+
"phpunit/phpunit": "^8.5"
1818
},
1919
"suggest": {
2020
"darkwebdesign/symfony-addon-pack": "All Symfony add-ons bundled together"

tests/BsnValidatorTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use DarkWebDesign\SymfonyAddonConstraints\BsnValidator;
2525
use DarkWebDesign\SymfonyAddonConstraints\Tests\Models\ToStringObject;
2626
use Symfony\Component\Validator\Constraints as Assert;
27+
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
2728
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
2829

2930
class BsnValidatorTest extends ConstraintValidatorTestCase
@@ -48,11 +49,10 @@ public function testValidate($bsn)
4849
$this->assertNoViolation();
4950
}
5051

51-
/**
52-
* @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
53-
*/
5452
public function testValidateInvalidConstraint()
5553
{
54+
$this->expectException(UnexpectedTypeException::class);
55+
5656
$this->validator->validate([], new Assert\NotNull());
5757

5858
$this->assertNoViolation();
@@ -76,11 +76,11 @@ public function testValidateEmptyString()
7676
* @param string $bsn
7777
*
7878
* @dataProvider providerNoScalar
79-
*
80-
* @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
8179
*/
8280
public function testValidateNoScalar($bsn)
8381
{
82+
$this->expectException(UnexpectedTypeException::class);
83+
8484
$this->validator->validate($bsn, new Bsn());
8585

8686
$this->assertNoViolation();

tests/CollectionTest.php

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
use DarkWebDesign\SymfonyAddonConstraints\Collection;
2424
use PHPUnit\Framework\TestCase;
2525
use Symfony\Component\Validator\Constraints as Assert;
26+
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
27+
use Symfony\Component\Validator\Exception\MissingOptionsException;
2628

2729
class CollectionTest extends TestCase
2830
{
@@ -33,54 +35,55 @@ public function testConstruct()
3335
new Assert\NotBlank(),
3436
],
3537
]);
38+
39+
$this->assertTrue(true);
3640
}
3741

3842
public function testConstructDefaultOption()
3943
{
4044
new Collection([
4145
new Assert\NotBlank(),
4246
]);
47+
48+
$this->assertTrue(true);
4349
}
4450

45-
/**
46-
* @expectedException \Symfony\Component\Validator\Exception\MissingOptionsException
47-
*/
4851
public function testConstructMissingRequiredConstraintsOption()
4952
{
53+
$this->expectException(MissingOptionsException::class);
54+
5055
new Collection();
5156
}
5257

5358
/**
5459
* @param mixed $constraints
5560
*
5661
* @dataProvider providerNoArray
57-
*
58-
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
5962
*/
6063
public function testConstructConstraintsOptionNoArray($constraints)
6164
{
65+
$this->expectException(ConstraintDefinitionException::class);
66+
6267
new Collection([
6368
'constraints' => $constraints,
6469
]);
6570
}
6671

67-
/**
68-
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
69-
*/
7072
public function testConstructNoConstraint()
7173
{
74+
$this->expectException(ConstraintDefinitionException::class);
75+
7276
new Collection([
7377
'constraints' => [
7478
'foo',
7579
],
7680
]);
7781
}
7882

79-
/**
80-
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
81-
*/
8283
public function testConstructValidConstraint()
8384
{
85+
$this->expectException(ConstraintDefinitionException::class);
86+
8487
new Collection([
8588
'constraints' => [
8689
new Assert\Valid(),

tests/CollectionValidatorTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use DarkWebDesign\SymfonyAddonConstraints\CollectionValidator;
2525
use DarkWebDesign\SymfonyAddonConstraints\Tests\Models\TraversableObject;
2626
use Symfony\Component\Validator\Constraints as Assert;
27+
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
2728
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
2829

2930
class CollectionValidatorTest extends ConstraintValidatorTestCase
@@ -61,11 +62,10 @@ public function testValidate($value)
6162
$this->assertNoViolation();
6263
}
6364

64-
/**
65-
* @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
66-
*/
6765
public function testValidateInvalidConstraint()
6866
{
67+
$this->expectException(UnexpectedTypeException::class);
68+
6969
$this->validator->validate([], new Assert\NotNull());
7070

7171
$this->assertNoViolation();
@@ -84,11 +84,11 @@ public function testValidateNull()
8484
* @param mixed $value
8585
*
8686
* @dataProvider providerNoArray
87-
*
88-
* @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
8987
*/
9088
public function testValidateNoArray($value)
9189
{
90+
$this->expectException(UnexpectedTypeException::class);
91+
9292
$this->validator->validate($value, new Collection([
9393
new Assert\NotBlank(),
9494
]));

tests/JsonValidatorTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use DarkWebDesign\SymfonyAddonConstraints\JsonValidator;
2525
use DarkWebDesign\SymfonyAddonConstraints\Tests\Models\ToStringObject;
2626
use Symfony\Component\Validator\Constraints as Assert;
27+
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
2728
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
2829

2930
class JsonValidatorTest extends ConstraintValidatorTestCase
@@ -48,11 +49,10 @@ public function testValidate($json)
4849
$this->assertNoViolation();
4950
}
5051

51-
/**
52-
* @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
53-
*/
5452
public function testValidateInvalidConstraint()
5553
{
54+
$this->expectException(UnexpectedTypeException::class);
55+
5656
$this->validator->validate([], new Assert\NotNull());
5757

5858
$this->assertNoViolation();
@@ -76,11 +76,11 @@ public function testValidateEmptyString()
7676
* @param string $bsn
7777
*
7878
* @dataProvider providerNoScalar
79-
*
80-
* @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
8179
*/
8280
public function testValidateNoScalar($bsn)
8381
{
82+
$this->expectException(UnexpectedTypeException::class);
83+
8484
$this->validator->validate($bsn, new Json());
8585

8686
$this->assertNoViolation();

0 commit comments

Comments
 (0)