Skip to content

Commit 631967a

Browse files
authored
Merge pull request #70 from tezhm/phpunit-update
Upgrading PHPUnit to version 9 in preparation for PHP 8.0 support
2 parents fb994e8 + 97e0ddd commit 631967a

File tree

66 files changed

+331
-278
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+331
-278
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
"doctrine/persistence": "^1.3.5|^2.0"
3030
},
3131
"require-dev": {
32-
"phpunit/phpunit": "~5.0",
33-
"mockery/mockery": "~0.9",
32+
"phpunit/phpunit": "~8.0|~9.0",
33+
"mockery/mockery": "~1.0",
3434
"beberlei/doctrineextensions": "~1.0",
3535
"zf1/zend-date": "~1.12",
3636
"nesbot/carbon": "*",

phpunit.xml.dist

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit backupGlobals="false"
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
backupGlobals="false"
34
backupStaticAttributes="false"
45
bootstrap="vendor/autoload.php"
56
colors="true"
@@ -8,18 +9,17 @@
89
convertWarningsToExceptions="true"
910
processIsolation="false"
1011
stopOnFailure="false"
11-
syntaxCheck="false"
12-
>
12+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
1313
<testsuites>
1414
<testsuite name="Package Test Suite">
1515
<directory suffix="Test.php">./tests/</directory>
1616
</testsuite>
1717
</testsuites>
18-
<filter>
19-
<whitelist>
18+
<coverage>
19+
<include>
2020
<directory suffix=".php">./src</directory>
21-
</whitelist>
22-
</filter>
21+
</include>
22+
</coverage>
2323
<listeners>
2424
<listener class="\Mockery\Adapter\Phpunit\TestListener" />
2525
</listeners>

tests/Builders/BuilderTest.php

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,15 @@
3232
use LaravelDoctrine\Fluent\Relations\OneToOne;
3333
use LaravelDoctrine\Fluent\Relations\Relation;
3434
use LogicException;
35+
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
36+
use PHPUnit\Framework\TestCase;
3537
use Tests\FakeEntity;
3638
use Tests\Stubs\Embedabbles\StubEmbeddable;
3739
use Tests\Stubs\StubEntityListener;
3840

39-
class BuilderTest extends \PHPUnit_Framework_TestCase
41+
class BuilderTest extends TestCase
4042
{
41-
use IsMacroable;
43+
use IsMacroable, MockeryPHPUnitIntegration;
4244

4345
/**
4446
* @var ClassMetadataBuilder
@@ -82,7 +84,7 @@ class BuilderTest extends \PHPUnit_Framework_TestCase
8284
'simpleArray' => Type::SIMPLE_ARRAY,
8385
];
8486

85-
public static function setUpBeforeClass()
87+
public static function setUpBeforeClass(): void
8688
{
8789
Type::addType(CarbonDateTimeType::CARBONDATETIME, CarbonDateTimeType::class);
8890
Type::addType(CarbonDateTimeTzType::CARBONDATETIMETZ, CarbonDateTimeTzType::class);
@@ -91,7 +93,7 @@ public static function setUpBeforeClass()
9193
Type::addType(ZendDateType::ZENDDATE, ZendDateType::class);
9294
}
9395

94-
protected function setUp()
96+
protected function setUp(): void
9597
{
9698
$this->builder = new ClassMetadataBuilder(new ClassMetadataInfo(
9799
FluentEntity::class
@@ -161,7 +163,7 @@ public function test_can_set_table_settings()
161163
public function test_cannot_use_table_settings_for_embeddable()
162164
{
163165
$this->builder->setEmbeddable();
164-
$this->setExpectedException(LogicException::class);
166+
$this->expectException(LogicException::class);
165167

166168
$this->fluent->table('users');
167169
}
@@ -222,7 +224,7 @@ public function test_cannot_use_entity_settings_for_embeddable()
222224
{
223225
$this->builder->setEmbeddable();
224226

225-
$this->setExpectedException(LogicException::class);
227+
$this->expectException(LogicException::class);
226228

227229
$this->fluent->entity();
228230
}
@@ -374,7 +376,7 @@ public function test_cannot_add_increments_to_embeddable()
374376
{
375377
$this->builder->setEmbeddable();
376378

377-
$this->setExpectedException(LogicException::class);
379+
$this->expectException(LogicException::class);
378380

379381
$this->fluent->increments('id');
380382
}
@@ -383,7 +385,7 @@ public function test_cannot_add_small_increments_to_embeddable()
383385
{
384386
$this->builder->setEmbeddable();
385387

386-
$this->setExpectedException(LogicException::class);
388+
$this->expectException(LogicException::class);
387389

388390
$this->fluent->smallIncrements('id');
389391
}
@@ -392,7 +394,7 @@ public function test_cannot_add_big_increments_to_embeddable()
392394
{
393395
$this->builder->setEmbeddable();
394396

395-
$this->setExpectedException(LogicException::class);
397+
$this->expectException(LogicException::class);
396398

397399
$this->fluent->bigIncrements('id');
398400
}
@@ -640,10 +642,8 @@ public function test_can_embed_embeddables()
640642

641643
public function test_fluent_builder_method_should_exist()
642644
{
643-
$this->setExpectedException(
644-
InvalidArgumentException::class,
645-
'Fluent builder method [doesNotExist] does not exist'
646-
);
645+
$this->expectException(InvalidArgumentException::class);
646+
$this->expectExceptionMessage('Fluent builder method [doesNotExist] does not exist');
647647

648648
$this->fluent->doesNotExist();
649649
}
@@ -768,6 +768,8 @@ public function test_can_override_many_to_many_association()
768768

769769
public function test_can_guess_a_one_to_one_relation_name()
770770
{
771+
$this->expectNotToPerformAssertions();
772+
771773
$this->fluent->oneToOne(FluentEntity::class);
772774

773775
$this->fluent->build();
@@ -781,6 +783,8 @@ public function test_can_guess_a_one_to_one_relation_name()
781783

782784
public function test_can_guess_a_has_one_relation_name()
783785
{
786+
$this->expectNotToPerformAssertions();
787+
784788
$this->fluent->hasOne(FluentEntity::class);
785789

786790
$this->fluent->build();
@@ -794,6 +798,8 @@ public function test_can_guess_a_has_one_relation_name()
794798

795799
public function test_can_guess_a_belongs_to_relation_name()
796800
{
801+
$this->expectNotToPerformAssertions();
802+
797803
$this->fluent->belongsTo(FluentEntity::class);
798804

799805
$this->fluent->build();
@@ -807,6 +813,8 @@ public function test_can_guess_a_belongs_to_relation_name()
807813

808814
public function test_can_guess_a_one_to_many_relation_name()
809815
{
816+
$this->expectNotToPerformAssertions();
817+
810818
$this->fluent->oneToMany(FluentEntity::class)->mappedBy('fluentEntity');
811819

812820
$this->fluent->build();
@@ -820,6 +828,8 @@ public function test_can_guess_a_one_to_many_relation_name()
820828

821829
public function test_can_guess_a_has_many_relation_name()
822830
{
831+
$this->expectNotToPerformAssertions();
832+
823833
$this->fluent->hasMany(FluentEntity::class)->mappedBy('fluentEntity');
824834

825835
$this->fluent->build();
@@ -833,6 +843,8 @@ public function test_can_guess_a_has_many_relation_name()
833843

834844
public function test_can_guess_a_many_to_many_relation_name()
835845
{
846+
$this->expectNotToPerformAssertions();
847+
836848
$this->fluent->manyToMany(FluentEntity::class);
837849

838850
$this->fluent->build();
@@ -846,6 +858,8 @@ public function test_can_guess_a_many_to_many_relation_name()
846858

847859
public function test_can_guess_a_belongs_to_many_relation_name()
848860
{
861+
$this->expectNotToPerformAssertions();
862+
849863
$this->fluent->belongsToMany(FluentEntity::class);
850864

851865
$this->fluent->build();

tests/Builders/EmbeddedTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
use Doctrine\ORM\Mapping\ClassMetadataInfo;
77
use Doctrine\ORM\Mapping\DefaultNamingStrategy;
88
use LaravelDoctrine\Fluent\Builders\Embedded;
9+
use PHPUnit\Framework\TestCase;
910

10-
class EmbeddedTest extends \PHPUnit_Framework_TestCase
11+
class EmbeddedTest extends TestCase
1112
{
1213
/**
1314
* @var ClassMetadataBuilder
@@ -19,7 +20,7 @@ class EmbeddedTest extends \PHPUnit_Framework_TestCase
1920
*/
2021
protected $embedded;
2122

22-
protected function setUp()
23+
protected function setUp(): void
2324
{
2425
$this->builder = new ClassMetadataBuilder(new ClassMetadataInfo(
2526
FluentEmbeddable::class

tests/Builders/EntityListenersTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
77
use Doctrine\ORM\Mapping\ClassMetadataInfo;
88
use LaravelDoctrine\Fluent\Builders\EntityListeners;
9-
use Symfony\Component\VarDumper\Cloner\Stub;
9+
use PHPUnit\Framework\TestCase;
1010
use Tests\Stubs\Entities\StubEntity;
1111
use Tests\Stubs\StubEntityListener;
1212

13-
class EntityListenersTest extends \PHPUnit_Framework_TestCase
13+
class EntityListenersTest extends TestCase
1414
{
1515
/**
1616
* @var EntityListeners
@@ -22,7 +22,7 @@ class EntityListenersTest extends \PHPUnit_Framework_TestCase
2222
*/
2323
protected $fluent;
2424

25-
protected function setUp()
25+
protected function setUp(): void
2626
{
2727
$this->fluent = new ClassMetadataBuilder(
2828
new ClassMetadataInfo(StubEntity::class)

tests/Builders/EntityTest.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
use Doctrine\ORM\Mapping\ClassMetadataInfo;
77
use LaravelDoctrine\Fluent\Builders\Entity;
88
use LaravelDoctrine\Fluent\Builders\Traits\Macroable;
9+
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
10+
use PHPUnit\Framework\TestCase;
911
use Tests\Stubs\Entities\StubEntity;
1012

11-
class EntityTest extends \PHPUnit_Framework_TestCase
13+
class EntityTest extends TestCase
1214
{
13-
use IsMacroable;
14-
15+
use IsMacroable, MockeryPHPUnitIntegration;
16+
1517
/**
1618
* @var ClassMetadataBuilder
1719
*/
@@ -22,7 +24,7 @@ class EntityTest extends \PHPUnit_Framework_TestCase
2224
*/
2325
protected $entity;
2426

25-
protected function setUp()
27+
protected function setUp(): void
2628
{
2729
$this->builder = new ClassMetadataBuilder(new ClassMetadataInfo(StubEntity::class));
2830
$this->entity = new Entity($this->builder);
@@ -59,7 +61,7 @@ public function test_can_enable_2nd_level_cache()
5961

6062
public function test_builder_method_should_exist()
6163
{
62-
$this->setExpectedException(\InvalidArgumentException::class);
64+
$this->expectException(\InvalidArgumentException::class);
6365

6466
$this->entity->doesNotExist();
6567
}

tests/Builders/FieldTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111
use LaravelDoctrine\Fluent\Builders\Field;
1212
use LaravelDoctrine\Fluent\Builders\GeneratedValue;
1313
use LaravelDoctrine\Fluent\Builders\Traits\Macroable;
14+
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
15+
use PHPUnit\Framework\TestCase;
1416
use Tests\Stubs\Entities\StubEntity;
1517

16-
class FieldTest extends \PHPUnit_Framework_TestCase
18+
class FieldTest extends TestCase
1719
{
18-
use IsMacroable;
19-
20+
use IsMacroable, MockeryPHPUnitIntegration;
21+
2022
/**
2123
* @var ClassMetadataBuilder
2224
*/
@@ -27,7 +29,7 @@ class FieldTest extends \PHPUnit_Framework_TestCase
2729
*/
2830
protected $field;
2931

30-
protected function setUp()
32+
protected function setUp(): void
3133
{
3234
$this->builder = new ClassMetadataBuilder(new ClassMetadataInfo(StubEntity::class));
3335
$this->builder->setTable('stub_entities');
@@ -202,10 +204,8 @@ public function test_can_make_field_primary()
202204

203205
public function test_cannot_call_non_existing_field_builder_methods()
204206
{
205-
$this->setExpectedException(
206-
BadMethodCallException::class,
207-
'FieldBuilder method [nonExisting] does not exist.'
208-
);
207+
$this->expectException(BadMethodCallException::class);
208+
$this->expectExceptionMessage('FieldBuilder method [nonExisting] does not exist.');
209209

210210
$this->field->nonExisting();
211211
}
@@ -312,7 +312,7 @@ public function test_guid_cannot_be_used_for_versioning()
312312

313313
public function test_ids_cannot_be_used_for_versioning()
314314
{
315-
$this->setExpectedException(MappingException::class);
315+
$this->expectException(MappingException::class);
316316

317317
$this->field
318318
->primary()
@@ -327,7 +327,7 @@ public function test_can_obtain_its_type_after_creation()
327327

328328
public function test_buildable_objects_returned_from_macros_get_queued_and_built()
329329
{
330-
Field::macro('foo', function(){
330+
Field::macro('foo', function(){
331331
/** @var Buildable|\Mockery\Mock $buildable */
332332
$buildable = \Mockery::mock(Buildable::class);
333333
$buildable->shouldReceive('build')->once();
@@ -356,7 +356,7 @@ private function doTestInvalidTypeForVersioning($type)
356356
$builder = new ClassMetadataBuilder(new ClassMetadataInfo(StubEntity::class));
357357
$field = Field::make($builder, $type, "aField");
358358

359-
$this->setExpectedException(MappingException::class);
359+
$this->expectException(MappingException::class);
360360
$field->useForVersioning()->build();
361361
}
362362

tests/Builders/GeneratedValueTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
use Doctrine\ORM\Mapping\Builder\FieldBuilder;
66
use Doctrine\ORM\Mapping\ClassMetadataInfo;
77
use LaravelDoctrine\Fluent\Builders\GeneratedValue;
8+
use PHPUnit\Framework\TestCase;
89

9-
class GeneratedValueTest extends \PHPUnit_Framework_TestCase
10+
class GeneratedValueTest extends TestCase
1011
{
1112
/**
1213
* @var \PHPUnit_Framework_MockObject_MockObject|FieldBuilder
@@ -23,7 +24,7 @@ class GeneratedValueTest extends \PHPUnit_Framework_TestCase
2324
*/
2425
protected $fluent;
2526

26-
protected function setUp()
27+
protected function setUp(): void
2728
{
2829
$this->field = $this->getMockBuilder(FieldBuilder::class)->disableOriginalConstructor()->getMock();
2930
$this->cm = $this->getMockBuilder(ClassMetadataInfo::class)->disableOriginalConstructor()->getMock();

tests/Builders/IndexTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@
55
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
66
use Doctrine\ORM\Mapping\ClassMetadataInfo;
77
use LaravelDoctrine\Fluent\Builders\Index;
8+
use PHPUnit\Framework\TestCase;
89
use Tests\Stubs\Entities\StubEntity;
910

10-
class IndexTest extends \PHPUnit_Framework_TestCase
11+
class IndexTest extends TestCase
1112
{
1213
/**
1314
* @var ClassMetadataBuilder
1415
*/
1516
protected $builder;
1617

17-
protected function setUp()
18+
protected function setUp(): void
1819
{
1920
$this->builder = new ClassMetadataBuilder(new ClassMetadataInfo(StubEntity::class));
2021
$this->builder->setTable('stub_entities');

0 commit comments

Comments
 (0)