diff --git a/src/Relations/AbstractRelation.php b/src/Relations/AbstractRelation.php index 54f9709033c64454b170a6138db81c1cfefffe35..6e23714027fb6e6a0b4da2300dbad20e2dd00fab 100644 --- a/src/Relations/AbstractRelation.php +++ b/src/Relations/AbstractRelation.php @@ -86,7 +86,7 @@ abstract class AbstractRelation implements Relation public function cascade(array $cascade) { foreach ($cascade as $name) { - $method = 'cascade'.(InflectorFactory::create()->build())->classify(strtolower($name)); + $method = 'cascade'.InflectorFactory::create()->build()->classify(strtolower($name)); if (!method_exists($this->association, $method)) { throw new InvalidArgumentException('Cascade ['.$name.'] does not exist'); @@ -105,7 +105,7 @@ abstract class AbstractRelation implements Relation */ public function fetch($strategy) { - $method = 'fetch'.(InflectorFactory::create()->build())->classify(strtolower($strategy)); + $method = 'fetch'.InflectorFactory::create()->build()->classify(strtolower($strategy)); if (!method_exists($this->association, $method)) { throw new InvalidArgumentException('Fetch ['.$strategy.'] does not exist'); diff --git a/tests/Builders/BuilderTest.php b/tests/Builders/BuilderTest.php index ffe7de48d3df62b5f38da4d875b1d62ed376a3a2..74a34e7df05bbbfbc4a5d1ba282ef0b3aab0a845 100644 --- a/tests/Builders/BuilderTest.php +++ b/tests/Builders/BuilderTest.php @@ -41,7 +41,8 @@ use Tests\Stubs\StubEntityListener; class BuilderTest extends TestCase { - use IsMacroable, MockeryPHPUnitIntegration; + use IsMacroable; + use MockeryPHPUnitIntegration; /** * @var ClassMetadataBuilder @@ -549,8 +550,9 @@ class BuilderTest extends TestCase $result = $this->builder->getClassMetadata()->associationMappings['one']; - $this->assertFalse($result['isOwningSide'], - "HasOne relation is an inversed one-to-one, but resulted in the owning side." + $this->assertFalse( + $result['isOwningSide'], + 'HasOne relation is an inversed one-to-one, but resulted in the owning side.' ); } @@ -703,21 +705,21 @@ class BuilderTest extends TestCase [ 'class' => StubEntityListener::class, 'method' => 'swipeFloor', - ] + ], ], $this->fluent->getClassMetadata()->entityListeners['onFlush']); $this->assertEquals([ [ 'class' => StubEntityListener::class, 'method' => 'cleanToilet', - ] + ], ], $this->fluent->getClassMetadata()->entityListeners['postFlush']); $this->assertEquals([ [ 'class' => StubEntityListener::class, 'method' => 'onClear', - ] + ], ], $this->fluent->getClassMetadata()->entityListeners['onClear']); } @@ -745,8 +747,10 @@ class BuilderTest extends TestCase $this->fluent->build(); - $this->assertEquals('target_id', - $this->fluent->getClassMetadata()->getAssociationMapping('manyToOne')['joinColumns'][0]['name']); + $this->assertEquals( + 'target_id', + $this->fluent->getClassMetadata()->getAssociationMapping('manyToOne')['joinColumns'][0]['name'] + ); $this->assertEquals('source_id', $this->fluent->getClassMetadata() ->getAssociationMapping('manyToOne')['joinColumns'][0]['referencedColumnName']); } @@ -761,8 +765,10 @@ class BuilderTest extends TestCase $this->fluent->build(); - $this->assertEquals('custom_table_name', - $this->fluent->getClassMetadata()->getAssociationMapping('manyToMany')['joinTable']['name']); + $this->assertEquals( + 'custom_table_name', + $this->fluent->getClassMetadata()->getAssociationMapping('manyToMany')['joinTable']['name'] + ); $this->assertEquals('source_id', $this->fluent->getClassMetadata() ->getAssociationMapping('manyToMany')['joinTable']['joinColumns'][0]['name']); } @@ -778,7 +784,7 @@ class BuilderTest extends TestCase try { $this->fluent->getClassMetadata()->getAssociationMapping('fluentEntity'); } catch (MappingException $e) { - $this->fail("Could not find default name for the oneToOne relation. " . $e->getMessage()); + $this->fail('Could not find default name for the oneToOne relation. '.$e->getMessage()); } } @@ -793,7 +799,7 @@ class BuilderTest extends TestCase try { $this->fluent->getClassMetadata()->getAssociationMapping('fluentEntity'); } catch (MappingException $e) { - $this->fail("Could not find default name for the hasOne relation. " . $e->getMessage()); + $this->fail('Could not find default name for the hasOne relation. '.$e->getMessage()); } } @@ -808,7 +814,7 @@ class BuilderTest extends TestCase try { $this->fluent->getClassMetadata()->getAssociationMapping('fluentEntity'); } catch (MappingException $e) { - $this->fail("Could not find default name for the belongsTo relation. " . $e->getMessage()); + $this->fail('Could not find default name for the belongsTo relation. '.$e->getMessage()); } } @@ -823,7 +829,7 @@ class BuilderTest extends TestCase try { $this->fluent->getClassMetadata()->getAssociationMapping('fluentEntities'); } catch (MappingException $e) { - $this->fail("Could not find default name for the oneToMany relation. " . $e->getMessage()); + $this->fail('Could not find default name for the oneToMany relation. '.$e->getMessage()); } } @@ -838,7 +844,7 @@ class BuilderTest extends TestCase try { $this->fluent->getClassMetadata()->getAssociationMapping('fluentEntities'); } catch (MappingException $e) { - $this->fail("Could not find default name for the hasMany relation. " . $e->getMessage()); + $this->fail('Could not find default name for the hasMany relation. '.$e->getMessage()); } } @@ -853,7 +859,7 @@ class BuilderTest extends TestCase try { $this->fluent->getClassMetadata()->getAssociationMapping('fluentEntities'); } catch (MappingException $e) { - $this->fail("Could not find default name for the manyToMany relation. " . $e->getMessage()); + $this->fail('Could not find default name for the manyToMany relation. '.$e->getMessage()); } } @@ -868,7 +874,7 @@ class BuilderTest extends TestCase try { $this->fluent->getClassMetadata()->getAssociationMapping('fluentEntities'); } catch (MappingException $e) { - $this->fail("Could not find default name for the belongsToMany relation. " . $e->getMessage()); + $this->fail('Could not find default name for the belongsToMany relation. '.$e->getMessage()); } } @@ -909,5 +915,8 @@ class BuilderTest extends TestCase class FluentEntity { - protected $id, $name, $fluentEntity, $fluentEntities; + protected $id; + protected $name; + protected $fluentEntity; + protected $fluentEntities; } diff --git a/tests/Builders/EmbeddedTest.php b/tests/Builders/EmbeddedTest.php index a1bd1a187e8420314ebd137272e53b3f9e10cc53..48b51d5be967dae4ea08b9f134860c9ff83d70bb 100644 --- a/tests/Builders/EmbeddedTest.php +++ b/tests/Builders/EmbeddedTest.php @@ -28,7 +28,7 @@ class EmbeddedTest extends TestCase $this->embedded = new Embedded( $this->builder, - new DefaultNamingStrategy, + new DefaultNamingStrategy(), 'field', FluentEmbeddable::class ); diff --git a/tests/Builders/EntityListenersTest.php b/tests/Builders/EntityListenersTest.php index 8f3f4dbc981ad30a9bc32e1593789854aedbfc52..cf7dc7f7ee1ef00693e41d11a4c55d2927f780d2 100644 --- a/tests/Builders/EntityListenersTest.php +++ b/tests/Builders/EntityListenersTest.php @@ -50,14 +50,15 @@ class EntityListenersTest extends TestCase ); $this->assertCount( - 1, $this->fluent->getClassMetadata()->entityListeners[$event] + 1, + $this->fluent->getClassMetadata()->entityListeners[$event] ); $this->assertEquals([ [ 'class' => $listener, - 'method' => $expectedMethod - ] + 'method' => $expectedMethod, + ], ], $this->fluent->getClassMetadata()->entityListeners[$event]); } @@ -74,18 +75,19 @@ class EntityListenersTest extends TestCase ); $this->assertCount( - 2, $this->fluent->getClassMetadata()->entityListeners['onClear'] + 2, + $this->fluent->getClassMetadata()->entityListeners['onClear'] ); $this->assertEquals([ [ 'class' => StubEntityListener::class, - 'method' => 'onClear' + 'method' => 'onClear', ], [ 'class' => StubEntityListener::class, - 'method' => 'handle' - ] + 'method' => 'handle', + ], ], $this->fluent->getClassMetadata()->entityListeners['onClear']); } diff --git a/tests/Builders/EntityTest.php b/tests/Builders/EntityTest.php index 7a81db06c60810e5c162e926365223b30c3ee2aa..b490d14715cec7837b87ec122696ad81fc5e5383 100644 --- a/tests/Builders/EntityTest.php +++ b/tests/Builders/EntityTest.php @@ -12,7 +12,8 @@ use Tests\Stubs\Entities\StubEntity; class EntityTest extends TestCase { - use IsMacroable, MockeryPHPUnitIntegration; + use IsMacroable; + use MockeryPHPUnitIntegration; /** * @var ClassMetadataBuilder @@ -27,7 +28,7 @@ class EntityTest extends TestCase protected function setUp(): void { $this->builder = new ClassMetadataBuilder(new ClassMetadataInfo(StubEntity::class)); - $this->entity = new Entity($this->builder); + $this->entity = new Entity($this->builder); } public function test_can_set_repository_class() diff --git a/tests/Builders/FieldTest.php b/tests/Builders/FieldTest.php index 9a0ef4b8ec3709214a6988505e5a48a9fe091e20..137ab8e4ff2dad632e07a23e6986d3faf3e7aad8 100644 --- a/tests/Builders/FieldTest.php +++ b/tests/Builders/FieldTest.php @@ -17,7 +17,8 @@ use Tests\Stubs\Entities\StubEntity; class FieldTest extends TestCase { - use IsMacroable, MockeryPHPUnitIntegration; + use IsMacroable; + use MockeryPHPUnitIntegration; /** * @var ClassMetadataBuilder @@ -160,8 +161,10 @@ class FieldTest extends TestCase $this->field->build(); - $this->assertEquals('default', - $this->builder->getClassMetadata()->getFieldMapping('name')['options']['default']); + $this->assertEquals( + 'default', + $this->builder->getClassMetadata()->getFieldMapping('name')['options']['default'] + ); } public function test_can_set_fixed() @@ -179,8 +182,10 @@ class FieldTest extends TestCase $this->field->build(); - $this->assertEquals('comment', - $this->builder->getClassMetadata()->getFieldMapping('name')['options']['comment']); + $this->assertEquals( + 'comment', + $this->builder->getClassMetadata()->getFieldMapping('name')['options']['comment'] + ); } public function test_can_set_collation() @@ -189,8 +194,10 @@ class FieldTest extends TestCase $this->field->build(); - $this->assertEquals('collation', - $this->builder->getClassMetadata()->getFieldMapping('name')['options']['collation']); + $this->assertEquals( + 'collation', + $this->builder->getClassMetadata()->getFieldMapping('name')['options']['collation'] + ); } public function test_can_make_field_primary() @@ -217,97 +224,97 @@ class FieldTest extends TestCase public function test_integer_can_be_used_for_versioning() { - $this->doTestValidTypeForVersioning("integer"); + $this->doTestValidTypeForVersioning('integer'); } public function test_bigint_can_be_used_for_versioning() { - $this->doTestValidTypeForVersioning("bigint"); + $this->doTestValidTypeForVersioning('bigint'); } public function test_smallint_can_be_used_for_versioning() { - $this->doTestValidTypeForVersioning("smallint"); + $this->doTestValidTypeForVersioning('smallint'); } public function test_datetime_can_be_used_for_versioning() { - $this->doTestValidTypeForVersioning("datetime"); + $this->doTestValidTypeForVersioning('datetime'); } public function test_array_cannot_be_used_for_versioning() { - $this->doTestInvalidTypeForVersioning("array"); + $this->doTestInvalidTypeForVersioning('array'); } public function test_simple_array_cannot_be_used_for_versioning() { - $this->doTestInvalidTypeForVersioning("simple_array"); + $this->doTestInvalidTypeForVersioning('simple_array'); } public function test_json_array_cannot_be_used_for_versioning() { - $this->doTestInvalidTypeForVersioning("json"); + $this->doTestInvalidTypeForVersioning('json'); } public function test_boolean_cannot_be_used_for_versioning() { - $this->doTestInvalidTypeForVersioning("boolean"); + $this->doTestInvalidTypeForVersioning('boolean'); } public function test_datetimetz_cannot_be_used_for_versioning() { - $this->doTestInvalidTypeForVersioning("datetimetz"); + $this->doTestInvalidTypeForVersioning('datetimetz'); } public function test_date_cannot_be_used_for_versioning() { - $this->doTestInvalidTypeForVersioning("date"); + $this->doTestInvalidTypeForVersioning('date'); } public function test_time_cannot_be_used_for_versioning() { - $this->doTestInvalidTypeForVersioning("time"); + $this->doTestInvalidTypeForVersioning('time'); } public function test_decimal_cannot_be_used_for_versioning() { - $this->doTestInvalidTypeForVersioning("decimal"); + $this->doTestInvalidTypeForVersioning('decimal'); } public function test_object_cannot_be_used_for_versioning() { - $this->doTestInvalidTypeForVersioning("object"); + $this->doTestInvalidTypeForVersioning('object'); } public function test_string_cannot_be_used_for_versioning() { - $this->doTestInvalidTypeForVersioning("string"); + $this->doTestInvalidTypeForVersioning('string'); } public function test_text_cannot_be_used_for_versioning() { - $this->doTestInvalidTypeForVersioning("text"); + $this->doTestInvalidTypeForVersioning('text'); } public function test_binary_cannot_be_used_for_versioning() { - $this->doTestInvalidTypeForVersioning("binary"); + $this->doTestInvalidTypeForVersioning('binary'); } public function test_blob_cannot_be_used_for_versioning() { - $this->doTestInvalidTypeForVersioning("blob"); + $this->doTestInvalidTypeForVersioning('blob'); } public function test_float_cannot_be_used_for_versioning() { - $this->doTestInvalidTypeForVersioning("float"); + $this->doTestInvalidTypeForVersioning('float'); } public function test_guid_cannot_be_used_for_versioning() { - $this->doTestInvalidTypeForVersioning("guid"); + $this->doTestInvalidTypeForVersioning('guid'); } public function test_ids_cannot_be_used_for_versioning() @@ -327,7 +334,7 @@ class FieldTest extends TestCase public function test_buildable_objects_returned_from_macros_get_queued_and_built() { - Field::macro('foo', function(){ + Field::macro('foo', function () { /** @var Buildable|\Mockery\Mock $buildable */ $buildable = \Mockery::mock(Buildable::class); $buildable->shouldReceive('build')->once(); @@ -342,7 +349,7 @@ class FieldTest extends TestCase private function doTestValidTypeForVersioning($type) { $builder = new ClassMetadataBuilder(new ClassMetadataInfo(StubEntity::class)); - $field = Field::make($builder, $type, "{$type}Field"); + $field = Field::make($builder, $type, "{$type}Field"); $field->useForVersioning()->build(); @@ -354,7 +361,7 @@ class FieldTest extends TestCase private function doTestInvalidTypeForVersioning($type) { $builder = new ClassMetadataBuilder(new ClassMetadataInfo(StubEntity::class)); - $field = Field::make($builder, $type, "aField"); + $field = Field::make($builder, $type, 'aField'); $this->expectException(MappingException::class); $field->useForVersioning()->build(); diff --git a/tests/Builders/GeneratedValueTest.php b/tests/Builders/GeneratedValueTest.php index f21d0bf8600c5a542c4820b8792d3499be8d2f3d..ab77e5a5296999a1e55f478501f561c0af8ddeb3 100644 --- a/tests/Builders/GeneratedValueTest.php +++ b/tests/Builders/GeneratedValueTest.php @@ -27,7 +27,7 @@ class GeneratedValueTest extends TestCase protected function setUp(): void { $this->field = $this->getMockBuilder(FieldBuilder::class)->disableOriginalConstructor()->getMock(); - $this->cm = $this->getMockBuilder(ClassMetadataInfo::class)->disableOriginalConstructor()->getMock(); + $this->cm = $this->getMockBuilder(ClassMetadataInfo::class)->disableOriginalConstructor()->getMock(); $this->fluent = new GeneratedValue($this->field, $this->cm); } @@ -81,7 +81,9 @@ class GeneratedValueTest extends TestCase { $this->field->expects($this->once())->method('generatedValue')->with('AUTO'); $this->field->expects($this->once())->method('setSequenceGenerator')->with( - 'crazy_name', $this->anything(), $this->anything() + 'crazy_name', + $this->anything(), + $this->anything() ); $this->fluent->auto('crazy_name')->build(); @@ -91,7 +93,9 @@ class GeneratedValueTest extends TestCase { $this->field->expects($this->once())->method('generatedValue')->with('AUTO'); $this->field->expects($this->once())->method('setSequenceGenerator')->with( - 'crazy_name', $this->anything(), 42 + 'crazy_name', + $this->anything(), + 42 ); $this->fluent @@ -103,7 +107,9 @@ class GeneratedValueTest extends TestCase { $this->field->expects($this->once())->method('generatedValue')->with('AUTO'); $this->field->expects($this->once())->method('setSequenceGenerator')->with( - 'crazy_name', 23, $this->anything() + 'crazy_name', + 23, + $this->anything() ); $this->fluent @@ -115,7 +121,9 @@ class GeneratedValueTest extends TestCase { $this->field->expects($this->once())->method('generatedValue')->with('AUTO'); $this->field->expects($this->once())->method('setSequenceGenerator')->with( - 'crazy_name', 23, 42 + 'crazy_name', + 23, + 42 ); $this->fluent @@ -137,7 +145,9 @@ class GeneratedValueTest extends TestCase { $this->field->expects($this->once())->method('generatedValue')->with('SEQUENCE'); $this->field->expects($this->once())->method('setSequenceGenerator')->with( - 'crazy_name', $this->anything(), $this->anything() + 'crazy_name', + $this->anything(), + $this->anything() ); $this->fluent->sequence('crazy_name')->build(); @@ -147,7 +157,9 @@ class GeneratedValueTest extends TestCase { $this->field->expects($this->once())->method('generatedValue')->with('SEQUENCE'); $this->field->expects($this->once())->method('setSequenceGenerator')->with( - 'crazy_name', $this->anything(), 42 + 'crazy_name', + $this->anything(), + 42 ); $this->fluent @@ -159,7 +171,9 @@ class GeneratedValueTest extends TestCase { $this->field->expects($this->once())->method('generatedValue')->with('SEQUENCE'); $this->field->expects($this->once())->method('setSequenceGenerator')->with( - 'crazy_name', 23, $this->anything() + 'crazy_name', + 23, + $this->anything() ); $this->fluent @@ -171,7 +185,9 @@ class GeneratedValueTest extends TestCase { $this->field->expects($this->once())->method('generatedValue')->with('SEQUENCE'); $this->field->expects($this->once())->method('setSequenceGenerator')->with( - 'crazy_name', 23, 42 + 'crazy_name', + 23, + 42 ); $this->fluent diff --git a/tests/Builders/Inheritance/InheritanceTestCase.php b/tests/Builders/Inheritance/InheritanceTestCase.php index c8927fd6c3365ce8b1e7636bb717ffabd5262cc5..b169f93dfae84de98dad3bab28b5593f92001589 100644 --- a/tests/Builders/Inheritance/InheritanceTestCase.php +++ b/tests/Builders/Inheritance/InheritanceTestCase.php @@ -70,7 +70,7 @@ class InheritanceTestCase extends TestCase $this->inheritance->map([ 'stub1' => StubEntity::class, 'stub2' => StubEntity2::class, - 'stub3' => StubEntity3::class + 'stub3' => StubEntity3::class, ]); $map = $this->builder->getClassMetadata()->discriminatorMap; diff --git a/tests/Builders/IsMacroable.php b/tests/Builders/IsMacroable.php index ae4df93e055ddb91b3d7b4cc280dce645e992399..ae0fea4a22b96e61f50dfc2af1f5aca1e2e6bf15 100644 --- a/tests/Builders/IsMacroable.php +++ b/tests/Builders/IsMacroable.php @@ -1,4 +1,5 @@ getMacroableBuilder(); @@ -37,20 +39,19 @@ trait IsMacroable $this->expectExceptionMessage('Macros should be used with a closure argument, none given'); call_user_func( - [get_class($this->getMacroableBuilder()), 'macro'], + [get_class($this->getMacroableBuilder()), 'macro'], 'fail' ); - } public function test_two_different_instances_contain_all_macros() { $builder = $this->getMacroableBuilder(); $other = clone $builder; - + $this->addMacroCallExpectation($builder, [], 'addedOnBuilder'); $this->addMacroCallExpectation($other, [], 'addedOnOther'); - + $builder->addedOnOther(); $other->addedOnBuilder(); } @@ -65,11 +66,11 @@ trait IsMacroable private function addMacroCallExpectation($builder, array $params = [], $method = 'callTheMock') { array_unshift($params, \Mockery::type(get_class($builder))); - + /** @var \Mockery\Mock $mock */ $mock = \Mockery::mock(['callMe' => true]); $mock->shouldReceive('callMe')->once()->withArgs($params); - + call_user_func( [get_class($builder), 'macro'], $method, @@ -77,7 +78,7 @@ trait IsMacroable call_user_func_array([$mock, 'callMe'], func_get_args()); } ); - + return $mock; } } diff --git a/tests/Builders/LifecycleEventsTest.php b/tests/Builders/LifecycleEventsTest.php index c16ba169ec1b07ae1ad5f527cfc7588ea8879ff7..28220ba978d6b289a9c9246483c657d973e1c08d 100644 --- a/tests/Builders/LifecycleEventsTest.php +++ b/tests/Builders/LifecycleEventsTest.php @@ -84,7 +84,7 @@ class LifecycleEventsTest extends TestCase "Event [$event] is already associated!" ); - for ($i = 0, $max = mt_rand(1, 5); $i < $max; ++$i) { + for ($i = 0, $max = mt_rand(1, 5); $i < $max; $i++) { $this->builder->$event(uniqid()); } @@ -96,8 +96,9 @@ class LifecycleEventsTest extends TestCase ); $this->assertCount( - $max, $actual = $this->fluent->getClassMetadata()->getLifecycleCallbacks($event), - "Expected [$max] events associated for [$event], got " . count($actual) + $max, + $actual = $this->fluent->getClassMetadata()->getLifecycleCallbacks($event), + "Expected [$max] events associated for [$event], got ".count($actual) ); } } diff --git a/tests/Builders/Overrides/AttributeOverrideTest.php b/tests/Builders/Overrides/AttributeOverrideTest.php index f2d65c2ba1692ce54948a162820e748efbfda13c..d443f66ab1c3c80b29e2076d9afe10452a431930 100644 --- a/tests/Builders/Overrides/AttributeOverrideTest.php +++ b/tests/Builders/Overrides/AttributeOverrideTest.php @@ -64,7 +64,7 @@ class AttributeOverrideTest extends TestCase public function test_default_settings_should_be_kept() { $this->builder->addField('nullable_attribute', 'string', [ - 'nullable' => true + 'nullable' => true, ]); $override = $this->override('nullable_attribute', function ($field) { @@ -80,7 +80,7 @@ class AttributeOverrideTest extends TestCase public function test_can_override_settings() { $this->builder->addField('nullable_attribute', 'string', [ - 'nullable' => true + 'nullable' => true, ]); $override = $this->override('nullable_attribute', function ($field) { @@ -97,8 +97,8 @@ class AttributeOverrideTest extends TestCase { $this->builder->addField('nullable_attribute', 'string', [ 'options' => [ - 'default' => 'some_default' - ] + 'default' => 'some_default', + ], ]); $override = $this->override('nullable_attribute', function ($field) { diff --git a/tests/Builders/TableTest.php b/tests/Builders/TableTest.php index bf5a44cfe2a85834acf116a34321ceb4059ed054..ee987618a9e4ba245b1c5d396daf97ec1a60af33 100644 --- a/tests/Builders/TableTest.php +++ b/tests/Builders/TableTest.php @@ -23,25 +23,25 @@ class TableTest extends TestCase protected function setUp(): void { $this->builder = new ClassMetadataBuilder(new ClassMetadataInfo(StubEntity::class)); - $this->table = new Table($this->builder); + $this->table = new Table($this->builder); } public function test_can_be_constructed_with_a_name_string() { - new Table($this->builder, 'users'); + new Table($this->builder, 'users'); $this->assertEquals('users', $this->builder->getClassMetadata()->getTableName()); } public function test_it_ignores_empty_names() { - $this->assertNull($this->builder->getClassMetadata()->table); + $this->assertNull($this->builder->getClassMetadata()->table); } public function test_it_can_be_constructed_with_a_callback_instead_of_a_name() { - new Table($this->builder, function(Table $builder){ - $builder->setName('crazy_logic'); + new Table($this->builder, function (Table $builder) { + $builder->setName('crazy_logic'); }); $this->assertEquals('crazy_logic', $this->builder->getClassMetadata()->getTableName()); @@ -74,18 +74,19 @@ class TableTest extends TestCase { $this->table->options([ 'collate' => 'utf8mb4_unicode_ci', - 'charset' => 'utf8mb4' + 'charset' => 'utf8mb4', ]); $this->table->build(); $this->assertEquals([ 'collate' => 'utf8mb4_unicode_ci', - 'charset' => 'utf8mb4' + 'charset' => 'utf8mb4', ], $this->builder->getClassMetadata()->table['options']); } - public function test_set_options_does_not_touch_other_data() { + public function test_set_options_does_not_touch_other_data() + { $table = $this->table->getClassMetadata()->table; $this->table->options(['collate' => 'utf8mb4_unicode_ci']); @@ -96,7 +97,8 @@ class TableTest extends TestCase $this->assertEquals($table, $this->builder->getClassMetadata()->table); } - public function test_can_set_options_and_change_schema () { + public function test_can_set_options_and_change_schema() + { $this->table->options(['collate' => 'utf8mb4_unicode_ci']); $this->table->schema('a_schema'); @@ -106,7 +108,8 @@ class TableTest extends TestCase $this->assertEquals(['collate' => 'utf8mb4_unicode_ci'], $this->builder->getClassMetadata()->table['options']); } - public function test_can_set_charset() { + public function test_can_set_charset() + { $this->table->charset('utf8mb4'); $this->table->build(); @@ -114,7 +117,8 @@ class TableTest extends TestCase $this->assertEquals('utf8mb4', $this->builder->getClassMetadata()->table['options']['charset']); } - public function test_can_set_collate() { + public function test_can_set_collate() + { $this->table->collate('utf8mb4_unicode_ci'); $this->table->build(); @@ -122,7 +126,8 @@ class TableTest extends TestCase $this->assertEquals('utf8mb4_unicode_ci', $this->builder->getClassMetadata()->table['options']['collate']); } - public function test_can_chain_collate_charset_schema() { + public function test_can_chain_collate_charset_schema() + { $this->table->collate('utf8mb4_unicode_ci')->charset('utf8mb4')->schema('a_schema'); $this->table->build(); @@ -130,7 +135,7 @@ class TableTest extends TestCase $this->assertEquals('a_schema', $this->builder->getClassMetadata()->table['schema']); $this->assertEquals([ 'collate' => 'utf8mb4_unicode_ci', - 'charset' => 'utf8mb4' + 'charset' => 'utf8mb4', ], $this->builder->getClassMetadata()->table['options']); } } diff --git a/tests/Builders/Traits/QueueableTest.php b/tests/Builders/Traits/QueueableTest.php index 174dc52dcb5447d6347f5d51404d7ae3cd8ac948..6c417a5cee52dc1135e02b3fefec0da58bc4dabe 100644 --- a/tests/Builders/Traits/QueueableTest.php +++ b/tests/Builders/Traits/QueueableTest.php @@ -80,11 +80,11 @@ class QueueableTest extends TestCase $mock = \Mockery::mock(Buildable::class); $mock->shouldReceive('build')->once(); - QueueableClass::macro('firstLevel', function() use ($mock) { + QueueableClass::macro('firstLevel', function () use ($mock) { return $mock; }); - QueueableClass::macro('inception', function(QueueableClass $builder){ + QueueableClass::macro('inception', function (QueueableClass $builder) { return $builder->firstLevel(); }); @@ -95,7 +95,9 @@ class QueueableTest extends TestCase class QueueableClass { - use Queueable, Macroable, QueuesMacros; + use Queueable; + use Macroable; + use QueuesMacros; public function addToQueue(Buildable $buildable) { diff --git a/tests/Extensions/ExtensibleClassMetadataFactoryFactoryTest.php b/tests/Extensions/ExtensibleClassMetadataFactoryFactoryTest.php index 1b88c9fe18bb64882d205219a210650f5b60579a..7df215fd82f3a2c4cbe21d3778804a7962ba0b22 100644 --- a/tests/Extensions/ExtensibleClassMetadataFactoryFactoryTest.php +++ b/tests/Extensions/ExtensibleClassMetadataFactoryFactoryTest.php @@ -1,4 +1,5 @@ shouldReceive('getConfiguration')->once()->andReturn($config); $config->shouldReceive('getNamingStrategy')->once()->andReturn($namingStrategy); $factory = new ExtensionFactoryTest(); $factory->setEntityManager($em); - + $this->assertInstanceOf(ExtensibleClassMetadata::class, $factory->getClassMetadataInstance()); } } -class ExtensionFactoryTest extends ExtensibleClassMetadataFactory { +class ExtensionFactoryTest extends ExtensibleClassMetadataFactory +{ /** * This is the only sane way of testing the small part of what we do in this factory. * Every other test would require infinite mocking. - * + * * @return ExtensibleClassMetadata */ public function getClassMetadataInstance() { - return $this->newClassMetadataInstance("Foo"); + return $this->newClassMetadataInstance('Foo'); } } diff --git a/tests/Extensions/ExtensibleClassMetadataTest.php b/tests/Extensions/ExtensibleClassMetadataTest.php index 8825a17ff94749d109d379bbca49a138a75376a4..f9b793c414d7c48e50105938152ec28743e55d36 100644 --- a/tests/Extensions/ExtensibleClassMetadataTest.php +++ b/tests/Extensions/ExtensibleClassMetadataTest.php @@ -1,8 +1,9 @@ cm = new ExtensibleClassMetadata("Foo"); + $this->cm = new ExtensibleClassMetadata('Foo'); } public function test_it_should_be_a_doctrine_class_metadata() @@ -26,8 +27,8 @@ class ExtensibleClassMetadataTest extends TestCase public function test_it_should_hold_extension_information() { - $this->cm->addExtension('foo', [ - 'bar' => 'baz' + $this->cm->addExtension('foo', [ + 'bar' => 'baz', ]); $this->assertNotEmpty($this->cm->extensions); @@ -36,14 +37,14 @@ class ExtensibleClassMetadataTest extends TestCase public function test_it_can_merge_and_overwrite_existing_extension() { - $this->cm->addExtension('foo', [ + $this->cm->addExtension('foo', [ 'foo' => 'foo', 'bar' => 'bar', ]); $this->cm->mergeExtension('foo', [ 'bar' => 'baz', - 'baz' => 'baz' + 'baz' => 'baz', ]); $this->assertEquals([ @@ -55,14 +56,14 @@ class ExtensibleClassMetadataTest extends TestCase public function test_it_can_merge_and_append_to_existing_extension() { - $this->cm->addExtension('foo', [ + $this->cm->addExtension('foo', [ 'foo' => 'foo', 'bar' => 'bar', ]); $this->cm->appendExtension('foo', [ 'bar' => 'baz', - 'baz' => 'baz' + 'baz' => 'baz', ]); $this->assertEquals([ diff --git a/tests/Extensions/Gedmo/BlameableTest.php b/tests/Extensions/Gedmo/BlameableTest.php index d1e1a50475d3c6d0a926a760c565bf1db56a5ed2..3bd8306a346b2fa96197728e77803ce093ac705c 100644 --- a/tests/Extensions/Gedmo/BlameableTest.php +++ b/tests/Extensions/Gedmo/BlameableTest.php @@ -1,4 +1,5 @@ classMetadata = new ExtensibleClassMetadata('foo'); - $this->extension = new Blameable($this->classMetadata, $this->fieldName); + $this->extension = new Blameable($this->classMetadata, $this->fieldName); } - + public function test_it_should_add_itself_as_a_field_macro() { - Blameable::enable(); - + Blameable::enable(); + $field = Field::make(new ClassMetadataBuilder(new ExtensibleClassMetadata('Foo')), 'string', $this->fieldName); - + $this->assertInstanceOf( - Blameable::class, + Blameable::class, call_user_func([$field, Blameable::MACRO_METHOD]) ); } - + public function test_it_should_add_itself_as_a_many_to_one_macro() { - Blameable::enable(); - + Blameable::enable(); + $manyToOne = new ManyToOne( new ClassMetadataBuilder(new ExtensibleClassMetadata('Foo')), new DefaultNamingStrategy(), $this->fieldName, 'Bar' ); - + $this->assertInstanceOf( - Blameable::class, + Blameable::class, call_user_func([$manyToOne, Blameable::MACRO_METHOD]) ); } - + /** * @return AbstractTrackingExtension */ diff --git a/tests/Extensions/Gedmo/ClosureTableTest.php b/tests/Extensions/Gedmo/ClosureTableTest.php index 6ab94f853dc222b1bc4b099025d27e6fb25f093f..9a2629f60e6888a6ce0c97fbd893bef92e8d7bd3 100644 --- a/tests/Extensions/Gedmo/ClosureTableTest.php +++ b/tests/Extensions/Gedmo/ClosureTableTest.php @@ -37,7 +37,7 @@ class ClosureTableTest extends TreeStrategyTest { Tree::enable(); - $this->builder->tree()->asClosureTable('Bar'); + $this->builder->tree()->asClosureTable('Bar'); $this->builder->belongsTo('Foo', 'parent')->treeParent(); $this->builder->integer('lvl')->treeLevel(); @@ -54,7 +54,7 @@ class ClosureTableTest extends TreeStrategyTest public function test_it_adds_the_closure_table_repository_as_default() { - $this->builder->tree()->asClosureTable('Bar'); + $this->builder->tree()->asClosureTable('Bar'); $this->builder->build(); $this->assertEquals( diff --git a/tests/Extensions/Gedmo/IpTraceableTest.php b/tests/Extensions/Gedmo/IpTraceableTest.php index e7c652aeaa389d32492b5cf13e159aba4313dce0..415397656ae457b4691431be1bb74ccc5cdb9f87 100644 --- a/tests/Extensions/Gedmo/IpTraceableTest.php +++ b/tests/Extensions/Gedmo/IpTraceableTest.php @@ -1,4 +1,5 @@ fieldName = 'ip'; + $this->fieldName = 'ip'; $this->classMetadata = new ExtensibleClassMetadata('foo'); - $this->extension = new IpTraceable($this->classMetadata, $this->fieldName); + $this->extension = new IpTraceable($this->classMetadata, $this->fieldName); } - + public function test_it_should_add_itself_as_a_field_macro() { IpTraceable::enable(); @@ -36,7 +37,6 @@ class IpTraceableTest extends TestCase call_user_func([$field, IpTraceable::MACRO_METHOD]) ); } - /** * @return AbstractTrackingExtension diff --git a/tests/Extensions/Gedmo/LocaleTest.php b/tests/Extensions/Gedmo/LocaleTest.php index 95a012f6c52fbaed49bf37afb6128e9e2193b5b6..2b93340293b36539094345dd564e23ceb4a312e9 100644 --- a/tests/Extensions/Gedmo/LocaleTest.php +++ b/tests/Extensions/Gedmo/LocaleTest.php @@ -39,9 +39,9 @@ class LocaleTest extends TestCase { Locale::enable(); - $this->fieldName = 'locale'; + $this->fieldName = 'locale'; $this->classMetadata = new ExtensibleClassMetadata('foo'); - $this->builder = new Builder(new ClassMetadataBuilder($this->classMetadata)); + $this->builder = new Builder(new ClassMetadataBuilder($this->classMetadata)); $this->extension = new Locale($this->classMetadata, $this->fieldName); } @@ -81,14 +81,14 @@ class LocaleTest extends TestCase $this->builder->build(); } - /** * Assert that the resulting build matches exactly with the given array. * * @param array $expected * - * @return void * @throws \PHPUnit_Framework_ExpectationFailedException + * + * @return void */ protected function assertBuildResultIs(array $expected) { diff --git a/tests/Extensions/Gedmo/LoggableTest.php b/tests/Extensions/Gedmo/LoggableTest.php index 59337063ed6308acfb027467de8da3b875c2b80d..285f8bf789592b870519f4057afe938a9e6f55f5 100644 --- a/tests/Extensions/Gedmo/LoggableTest.php +++ b/tests/Extensions/Gedmo/LoggableTest.php @@ -28,7 +28,7 @@ class LoggableTest extends TestCase protected function setUp(): void { $this->classMetadata = new ExtensibleClassMetadata('foo'); - $this->loggable = new Loggable($this->classMetadata); + $this->loggable = new Loggable($this->classMetadata); } public function test_it_should_mark_the_entity_as_loggable() @@ -68,12 +68,12 @@ class LoggableTest extends TestCase public function test_it_should_add_itself_as_a_builder_macro() { - Loggable::enable(); - + Loggable::enable(); + $entity = new Builder(new ClassMetadataBuilder($this->classMetadata), new DefaultNamingStrategy()); - + $entity->loggable(); - + $this->assertNotNull($this->classMetadata->getExtension(Fluent::EXTENSION_NAME)); } @@ -100,7 +100,6 @@ class LoggableTest extends TestCase 'SomeEntity' ); - $relation->versioned(); $relation->build(); @@ -118,7 +117,6 @@ class LoggableTest extends TestCase 'SomeEntity' ); - $relation->versioned(); $relation->build(); diff --git a/tests/Extensions/Gedmo/Mappings/Loggable/LogEntryMappingTest.php b/tests/Extensions/Gedmo/Mappings/Loggable/LogEntryMappingTest.php index 94ba123ad8f6495e62ea8f6dcb49092d15fcac9c..909a93108f4aa6cf183f32772f234460bad034f0 100644 --- a/tests/Extensions/Gedmo/Mappings/Loggable/LogEntryMappingTest.php +++ b/tests/Extensions/Gedmo/Mappings/Loggable/LogEntryMappingTest.php @@ -16,19 +16,19 @@ class LogEntryMappingTest extends MappingTestCase /** @var \Mockery\Mock|Entity $entity */ $entity = \Mockery::mock(Entity::class); $entity->shouldReceive('setRepositoryClass')->with(LogEntryRepository::class)->andReturnSelf(); - + /** @var Index|\Mockery\Mock $index */ $index = \Mockery::mock(Index::class); - $index->shouldReceive('name')->with("log_class_lookup_idx")->once()->andReturnSelf(); - $index->shouldReceive('name')->with("log_date_lookup_idx")->once()->andReturnSelf(); - $index->shouldReceive('name')->with("log_user_lookup_idx")->once()->andReturnSelf(); - $index->shouldReceive('name')->with("log_version_lookup_idx")->once()->andReturnSelf(); - + $index->shouldReceive('name')->with('log_class_lookup_idx')->once()->andReturnSelf(); + $index->shouldReceive('name')->with('log_date_lookup_idx')->once()->andReturnSelf(); + $index->shouldReceive('name')->with('log_user_lookup_idx')->once()->andReturnSelf(); + $index->shouldReceive('name')->with('log_version_lookup_idx')->once()->andReturnSelf(); + $this->builder->shouldReceive('table')->with('ext_log_entries')->andReturnSelf(); - $this->builder->shouldReceive('index')->with(["object_class"])->andReturn($index); - $this->builder->shouldReceive('index')->with(["logged_at"])->andReturn($index); - $this->builder->shouldReceive('index')->with(["username"])->andReturn($index); - $this->builder->shouldReceive('index')->with(["object_id", "object_class", "version"])->andReturn($index); + $this->builder->shouldReceive('index')->with(['object_class'])->andReturn($index); + $this->builder->shouldReceive('index')->with(['logged_at'])->andReturn($index); + $this->builder->shouldReceive('index')->with(['username'])->andReturn($index); + $this->builder->shouldReceive('index')->with(['object_id', 'object_class', 'version'])->andReturn($index); $this->builder->shouldReceive('entity')->andReturn($entity); } diff --git a/tests/Extensions/Gedmo/Mappings/MappingTestCase.php b/tests/Extensions/Gedmo/Mappings/MappingTestCase.php index 651e9ffe5fc70bec06b3f08f42f2a275e0432fbb..022ca2ec9a2bdc01539fd822bc272dd1cc8334ab 100644 --- a/tests/Extensions/Gedmo/Mappings/MappingTestCase.php +++ b/tests/Extensions/Gedmo/Mappings/MappingTestCase.php @@ -37,6 +37,7 @@ abstract class MappingTestCase extends TestCase /** * Get the class name of the mapped class. + * * @return string */ abstract protected function getMappedClass(); @@ -52,7 +53,7 @@ abstract class MappingTestCase extends TestCase protected function setUp(): void { $class = $this->getMappingClass(); - $this->mapping = new $class; + $this->mapping = new $class(); $this->builder = \Mockery::mock(Fluent::class); $this->field = \Mockery::mock(Field::class); @@ -79,7 +80,7 @@ abstract class MappingTestCase extends TestCase */ protected function generatedValueExpectation($strategy = 'identity') { - return \Mockery::on(function($argument) use ($strategy) { + return \Mockery::on(function ($argument) use ($strategy) { /** @var GeneratedValue|\Mockery\Mock $gen */ $gen = \Mockery::mock(GeneratedValue::class); $gen->shouldReceive($strategy)->once(); @@ -89,6 +90,7 @@ abstract class MappingTestCase extends TestCase } $argument($gen); + return true; }); } diff --git a/tests/Extensions/Gedmo/Mappings/Translatable/TranslationMappingTest.php b/tests/Extensions/Gedmo/Mappings/Translatable/TranslationMappingTest.php index 041e438fe535861a37ffabb21c33f0dffc195d00..63b83d7f8105e53514e586ce23e04b275203da6a 100644 --- a/tests/Extensions/Gedmo/Mappings/Translatable/TranslationMappingTest.php +++ b/tests/Extensions/Gedmo/Mappings/Translatable/TranslationMappingTest.php @@ -27,18 +27,18 @@ class TranslationMappingTest extends MappingTestCase /** @var Entity|\Mockery\Mock $entity */ $entity = \Mockery::mock(Entity::class); $entity->shouldReceive('setRepositoryClass')->with(TranslationRepository::class)->once()->andReturnSelf(); - + /** @var Index|\Mockery\Mock $index */ $index = \Mockery::mock(Index::class); $index->shouldReceive('name')->with('translations_lookup_idx')->once()->andReturnSelf(); - + /** @var UniqueConstraint|\Mockery\Mock $unique */ $unique = \Mockery::mock(UniqueConstraint::class); $unique->shouldReceive('name')->with('lookup_unique_idx')->once()->andReturnSelf(); - + $this->builder->shouldReceive('table')->with('ext_translations')->once()->andReturnSelf(); $this->builder->shouldReceive('entity')->once()->andReturn($entity); - $this->builder->shouldReceive('index')->with(["locale", "object_class", "foreign_key"])->once()->andReturn($index); - $this->builder->shouldReceive('unique')->with(["locale", "object_class", "field", "foreign_key"])->once()->andReturn($unique); + $this->builder->shouldReceive('index')->with(['locale', 'object_class', 'foreign_key'])->once()->andReturn($index); + $this->builder->shouldReceive('unique')->with(['locale', 'object_class', 'field', 'foreign_key'])->once()->andReturn($unique); } } diff --git a/tests/Extensions/Gedmo/MaterializedPathTest.php b/tests/Extensions/Gedmo/MaterializedPathTest.php index c73e79384c88ade821adcef7af477d220d2ceea4..6d8b9a11e00a788e6e7338d550d05ee161a57cea 100644 --- a/tests/Extensions/Gedmo/MaterializedPathTest.php +++ b/tests/Extensions/Gedmo/MaterializedPathTest.php @@ -33,13 +33,14 @@ class MaterializedPathTest extends TestCase protected function setUp(): void { - $this->classMetadata = new ExtensibleClassMetadata("Foo"); - $this->builder = new Builder(new ClassMetadataBuilder($this->classMetadata)); - $this->tree = new MaterializedPath($this->builder); + $this->classMetadata = new ExtensibleClassMetadata('Foo'); + $this->builder = new Builder(new ClassMetadataBuilder($this->classMetadata)); + $this->tree = new MaterializedPath($this->builder); } /** * @runInSeparateProcess + * * @preserveGlobalState false */ public function test_it_should_enable_field_macros() @@ -61,11 +62,12 @@ class MaterializedPathTest extends TestCase /** * @runInSeparateProcess + * * @preserveGlobalState false */ public function test_it_gets_along_with_other_tree_field_builders() { - Tree::enable(); + Tree::enable(); $this->builder->tree()->asMaterializedPath(); @@ -95,7 +97,6 @@ class MaterializedPathTest extends TestCase ]); } - public function test_it_lets_me_customize_the_path_field() { $this->tree->path('thePath')->build(); @@ -158,14 +159,14 @@ class MaterializedPathTest extends TestCase public function test_it_returns_a_false_value_for_activate_locking_as_its_not_supported() { - $this->tree->build(); + $this->tree->build(); $this->assertExtensionKeyEquals('activate_locking', false); } public function test_the_path_is_forced_to_nullable() { - $this->tree->path('someField')->build(); + $this->tree->path('someField')->build(); $this->builder->build(); $this->assertTrue($this->classMetadata->fieldMappings['someField']['nullable']); @@ -176,8 +177,9 @@ class MaterializedPathTest extends TestCase * * @param array $expected * - * @return void * @throws \PHPUnit_Framework_ExpectationFailedException + * + * @return void */ protected function assertExtensionEquals(array $expected) { @@ -190,8 +192,9 @@ class MaterializedPathTest extends TestCase * @param string $key * @param mixed $expected * - * @return void * @throws \PHPUnit_Framework_ExpectationFailedException + * + * @return void */ protected function assertExtensionKeyEquals($key, $expected) { diff --git a/tests/Extensions/Gedmo/NestedSetTest.php b/tests/Extensions/Gedmo/NestedSetTest.php index 439a620d05dc4e7eeafb67c06770725bc8c57db8..43065748a0378ba96fd71c560d128ee9a634054b 100644 --- a/tests/Extensions/Gedmo/NestedSetTest.php +++ b/tests/Extensions/Gedmo/NestedSetTest.php @@ -23,6 +23,7 @@ class NestedSetTest extends TreeStrategyTest /** * @runInSeparateProcess + * * @preserveGlobalState false */ public function test_building_a_nested_tree_through_the_tree_facade() diff --git a/tests/Extensions/Gedmo/SluggableTest.php b/tests/Extensions/Gedmo/SluggableTest.php index 49c5c4249471822fb5e8d8dff548a0d6ea5d4bb2..2ad98b140fa53d9c43cf25f543a29eecc1166809 100644 --- a/tests/Extensions/Gedmo/SluggableTest.php +++ b/tests/Extensions/Gedmo/SluggableTest.php @@ -1,4 +1,5 @@ classMetadataBuilder); @@ -89,7 +90,7 @@ class SluggableTest extends TestCase 'unique_base' => null, 'separator' => '-', 'prefix' => '', - 'suffix' => '' + 'suffix' => '', ]); } @@ -109,7 +110,7 @@ class SluggableTest extends TestCase 'unique_base' => null, 'separator' => '-', 'prefix' => '', - 'suffix' => '' + 'suffix' => '', ]); } @@ -141,7 +142,7 @@ class SluggableTest extends TestCase 'unique_base' => 'base', 'separator' => '_', 'prefix' => 'prefix-', - 'suffix' => '-suffix' + 'suffix' => '-suffix', ]); } @@ -163,15 +164,16 @@ class SluggableTest extends TestCase * * @param array $expected * - * @return void * @throws \PHPUnit_Framework_ExpectationFailedException + * + * @return void */ protected function assertBuildResultIs(array $expected) { $this->assertEquals([ 'slugs' => [ - $this->fieldName => $expected - ] + $this->fieldName => $expected, + ], ], $this->classMetadata->getExtension( $this->getExtensionName() )); diff --git a/tests/Extensions/Gedmo/SoftDeleteableTest.php b/tests/Extensions/Gedmo/SoftDeleteableTest.php index e1c1bf8795b95fd81c7ff68f9c7444fc9da87a51..2d6955c68b718f09c7cb4de86ff62c42ed122f75 100644 --- a/tests/Extensions/Gedmo/SoftDeleteableTest.php +++ b/tests/Extensions/Gedmo/SoftDeleteableTest.php @@ -1,4 +1,5 @@ fieldName = 'deletedAt'; + $this->fieldName = 'deletedAt'; $this->classMetadata = new ExtensibleClassMetadata('foo'); - $this->extension = new SoftDeleteable($this->classMetadata, $this->fieldName); + $this->extension = new SoftDeleteable($this->classMetadata, $this->fieldName); } public function test_it_should_add_itself_as_a_field_macro() @@ -67,7 +68,7 @@ class SoftDeleteableTest extends TestCase $this->assertBuildResultIs([ 'softDeleteable' => true, 'fieldName' => $this->fieldName, - 'timeAware' => false + 'timeAware' => false, ]); } @@ -78,7 +79,7 @@ class SoftDeleteableTest extends TestCase $this->assertBuildResultIs([ 'softDeleteable' => true, 'fieldName' => $this->fieldName, - 'timeAware' => true + 'timeAware' => true, ]); } @@ -87,8 +88,9 @@ class SoftDeleteableTest extends TestCase * * @param array $expected * - * @return void * @throws \PHPUnit_Framework_ExpectationFailedException + * + * @return void */ protected function assertBuildResultIs(array $expected) { diff --git a/tests/Extensions/Gedmo/SortableGroupTest.php b/tests/Extensions/Gedmo/SortableGroupTest.php index 420785a53bb9b4e1273af88bb283d4dca1e9a097..216c0d1ee2bddcc16f476b911d4860dab04fa9d3 100644 --- a/tests/Extensions/Gedmo/SortableGroupTest.php +++ b/tests/Extensions/Gedmo/SortableGroupTest.php @@ -31,9 +31,9 @@ class SortableGroupTest extends TestCase protected function setUp(): void { - $this->fieldName = 'category'; + $this->fieldName = 'category'; $this->classMetadata = new ExtensibleClassMetadata('foo'); - $this->extension = new SortableGroup($this->classMetadata, $this->fieldName, 'name'); + $this->extension = new SortableGroup($this->classMetadata, $this->fieldName, 'name'); } public function test_it_should_add_itself_as_a_field_macro() @@ -98,8 +98,9 @@ class SortableGroupTest extends TestCase * * @param array $expected * - * @return void * @throws \PHPUnit_Framework_ExpectationFailedException + * + * @return void */ protected function assertBuildResultIs(array $expected) { diff --git a/tests/Extensions/Gedmo/SortablePositionTest.php b/tests/Extensions/Gedmo/SortablePositionTest.php index 3141cf062f479c312d62bc0552cf558927c2a7fd..171d71f0d8e4dc5b82041dd62ed59251a5c401ab 100644 --- a/tests/Extensions/Gedmo/SortablePositionTest.php +++ b/tests/Extensions/Gedmo/SortablePositionTest.php @@ -28,9 +28,9 @@ class SortablePositionTest extends TestCase protected function setUp(): void { - $this->fieldName = 'position'; + $this->fieldName = 'position'; $this->classMetadata = new ExtensibleClassMetadata('foo'); - $this->extension = new SortablePosition($this->classMetadata, $this->fieldName, 'name'); + $this->extension = new SortablePosition($this->classMetadata, $this->fieldName, 'name'); } public function test_it_should_add_itself_as_a_field_macro() @@ -61,8 +61,9 @@ class SortablePositionTest extends TestCase * * @param array $expected * - * @return void * @throws \PHPUnit_Framework_ExpectationFailedException + * + * @return void */ protected function assertBuildResultIs(array $expected) { diff --git a/tests/Extensions/Gedmo/TimestampableTest.php b/tests/Extensions/Gedmo/TimestampableTest.php index 6625e36b099f53a4e042080d5ad27afe9089caa9..2588de51129aeca0685ef262643d5376c8093aa1 100644 --- a/tests/Extensions/Gedmo/TimestampableTest.php +++ b/tests/Extensions/Gedmo/TimestampableTest.php @@ -1,4 +1,5 @@ fieldName = 'ip'; + $this->fieldName = 'ip'; $this->classMetadata = new ExtensibleClassMetadata('foo'); - $this->extension = new Timestampable($this->classMetadata, $this->fieldName); + $this->extension = new Timestampable($this->classMetadata, $this->fieldName); } - + public function test_it_should_add_itself_as_a_field_macro() { Timestampable::enable(); diff --git a/tests/Extensions/Gedmo/TrackingExtensions.php b/tests/Extensions/Gedmo/TrackingExtensions.php index 0e1977ea160eaccfb02521ce2eeb267ba51828d1..2c106cd7fbb2beba0e7517b99d78d6897096bd45 100644 --- a/tests/Extensions/Gedmo/TrackingExtensions.php +++ b/tests/Extensions/Gedmo/TrackingExtensions.php @@ -1,4 +1,5 @@ expectException(InvalidMappingException::class); @@ -132,8 +132,9 @@ trait TrackingExtensions * * @param array $expected * - * @return void * @throws \PHPUnit_Framework_ExpectationFailedException + * + * @return void */ protected function assertBuildResultIs(array $expected) { diff --git a/tests/Extensions/Gedmo/TranslatableTest.php b/tests/Extensions/Gedmo/TranslatableTest.php index d5c3e6f93f7e995fcff2710d0ddb8aa0b4921178..ab179571d7e886aeab0759e128cf92c5412097a7 100644 --- a/tests/Extensions/Gedmo/TranslatableTest.php +++ b/tests/Extensions/Gedmo/TranslatableTest.php @@ -1,4 +1,5 @@ fieldName = 'title'; + $this->fieldName = 'title'; $this->classMetadata = new ExtensibleClassMetadata('foo'); Field::make(new ClassMetadataBuilder($this->classMetadata), 'string', 'title')->build(); @@ -41,8 +42,11 @@ class TranslatableTest extends TestCase { Translatable::enable(); - $field = Field::make(new ClassMetadataBuilder(new ExtensibleClassMetadata('Foo')), 'string', - $this->fieldName)->build(); + $field = Field::make( + new ClassMetadataBuilder(new ExtensibleClassMetadata('Foo')), + 'string', + $this->fieldName + )->build(); $this->assertInstanceOf( Translatable::class, @@ -77,8 +81,9 @@ class TranslatableTest extends TestCase * * @param array $expected * - * @return void * @throws \PHPUnit_Framework_ExpectationFailedException + * + * @return void */ protected function assertBuildResultIs(array $expected) { diff --git a/tests/Extensions/Gedmo/TranslationClassTest.php b/tests/Extensions/Gedmo/TranslationClassTest.php index 678da895bdccd40f575dc73f864778028993446c..1f0779cfe9d4a1c9377bbae4aac156b1818ea0f4 100644 --- a/tests/Extensions/Gedmo/TranslationClassTest.php +++ b/tests/Extensions/Gedmo/TranslationClassTest.php @@ -33,7 +33,7 @@ class TranslationClassTest extends TestCase protected function setUp(): void { - $this->className = 'TranslationClass'; + $this->className = 'TranslationClass'; $this->classMetadata = new ExtensibleClassMetadata('foo'); $this->extension = new TranslationClass($this->classMetadata, $this->className); } @@ -64,8 +64,9 @@ class TranslationClassTest extends TestCase * * @param array $expected * - * @return void * @throws \PHPUnit_Framework_ExpectationFailedException + * + * @return void */ protected function assertBuildResultIs(array $expected) { diff --git a/tests/Extensions/Gedmo/TreeLeftTest.php b/tests/Extensions/Gedmo/TreeLeftTest.php index 36904f951c269c4f8a506319cf0f1bc1329c8f0f..a4038342bfe71e711190eca7ac07dcd7965870c8 100644 --- a/tests/Extensions/Gedmo/TreeLeftTest.php +++ b/tests/Extensions/Gedmo/TreeLeftTest.php @@ -32,7 +32,7 @@ class TreeLeftTest extends TestCase protected function setUp(): void { - $this->fieldName = 'lft'; + $this->fieldName = 'lft'; $this->classMetadata = new ExtensibleClassMetadata('foo'); Field::make(new ClassMetadataBuilder($this->classMetadata), 'integer', $this->fieldName)->build(); @@ -43,8 +43,12 @@ class TreeLeftTest extends TestCase { TreeLeft::enable(); - $field = Field::make(new ClassMetadataBuilder( - new ExtensibleClassMetadata('Foo')), 'integer', $this->fieldName + $field = Field::make( + new ClassMetadataBuilder( + new ExtensibleClassMetadata('Foo') + ), + 'integer', + $this->fieldName )->build(); $this->assertInstanceOf( @@ -79,8 +83,9 @@ class TreeLeftTest extends TestCase * * @param array $expected * - * @return void * @throws \PHPUnit_Framework_ExpectationFailedException + * + * @return void */ protected function assertBuildResultIs(array $expected) { diff --git a/tests/Extensions/Gedmo/TreeLevelTest.php b/tests/Extensions/Gedmo/TreeLevelTest.php index 95cf1c1d83b8582f340e2b9ecdb3117b3da56cf7..43bb9001bfcf01812c7254a2d3fdbc8033c36289 100644 --- a/tests/Extensions/Gedmo/TreeLevelTest.php +++ b/tests/Extensions/Gedmo/TreeLevelTest.php @@ -32,7 +32,7 @@ class TreeLevelTest extends TestCase protected function setUp(): void { - $this->fieldName = 'lvl'; + $this->fieldName = 'lvl'; $this->classMetadata = new ExtensibleClassMetadata('foo'); Field::make(new ClassMetadataBuilder($this->classMetadata), 'integer', $this->fieldName)->build(); @@ -43,8 +43,12 @@ class TreeLevelTest extends TestCase { TreeLevel::enable(); - $field = Field::make(new ClassMetadataBuilder( - new ExtensibleClassMetadata('Foo')), 'integer', $this->fieldName + $field = Field::make( + new ClassMetadataBuilder( + new ExtensibleClassMetadata('Foo') + ), + 'integer', + $this->fieldName )->build(); $this->assertInstanceOf( @@ -79,8 +83,9 @@ class TreeLevelTest extends TestCase * * @param array $expected * - * @return void * @throws \PHPUnit_Framework_ExpectationFailedException + * + * @return void */ protected function assertBuildResultIs(array $expected) { diff --git a/tests/Extensions/Gedmo/TreePathHashTest.php b/tests/Extensions/Gedmo/TreePathHashTest.php index eee9c506b9e9d55ec20e2b4d8330ee2fbb19ff42..7a708c6a9459b234a1f6357936e3589ed9e1928a 100644 --- a/tests/Extensions/Gedmo/TreePathHashTest.php +++ b/tests/Extensions/Gedmo/TreePathHashTest.php @@ -31,7 +31,7 @@ class TreePathHashTest extends TestCase protected function setUp(): void { - $this->fieldName = 'hash'; + $this->fieldName = 'hash'; $this->classMetadata = new ExtensibleClassMetadata('foo'); Field::make(new ClassMetadataBuilder($this->classMetadata), 'integer', $this->fieldName)->build(); @@ -42,8 +42,12 @@ class TreePathHashTest extends TestCase { TreePathHash::enable(); - $field = Field::make(new ClassMetadataBuilder( - new ExtensibleClassMetadata('Foo')), 'integer', $this->fieldName + $field = Field::make( + new ClassMetadataBuilder( + new ExtensibleClassMetadata('Foo') + ), + 'integer', + $this->fieldName )->build(); $this->assertInstanceOf( @@ -66,8 +70,9 @@ class TreePathHashTest extends TestCase * * @param array $expected * - * @return void * @throws \PHPUnit_Framework_ExpectationFailedException + * + * @return void */ protected function assertBuildResultIs(array $expected) { diff --git a/tests/Extensions/Gedmo/TreePathSourceTest.php b/tests/Extensions/Gedmo/TreePathSourceTest.php index 98540eac218afc8717236a8a47a6d2428b0a4845..a46931dc4d3bdbd8854d8247c06441ef3e0a5572 100644 --- a/tests/Extensions/Gedmo/TreePathSourceTest.php +++ b/tests/Extensions/Gedmo/TreePathSourceTest.php @@ -32,7 +32,7 @@ class TreePathSourceTest extends TestCase protected function setUp(): void { - $this->fieldName = 'source'; + $this->fieldName = 'source'; $this->classMetadata = new ExtensibleClassMetadata('foo'); Field::make(new ClassMetadataBuilder($this->classMetadata), 'integer', $this->fieldName)->build(); @@ -43,8 +43,12 @@ class TreePathSourceTest extends TestCase { TreePathSource::enable(); - $field = Field::make(new ClassMetadataBuilder( - new ExtensibleClassMetadata('Foo')), 'integer', $this->fieldName + $field = Field::make( + new ClassMetadataBuilder( + new ExtensibleClassMetadata('Foo') + ), + 'integer', + $this->fieldName )->build(); $this->assertInstanceOf( @@ -79,8 +83,9 @@ class TreePathSourceTest extends TestCase * * @param array $expected * - * @return void * @throws \PHPUnit_Framework_ExpectationFailedException + * + * @return void */ protected function assertBuildResultIs(array $expected) { diff --git a/tests/Extensions/Gedmo/TreePathTest.php b/tests/Extensions/Gedmo/TreePathTest.php index f6fea6a10af677990fc2d4a74e38f8a6309248f5..43cdaa156877c914c43755cee230f769c9f17d05 100644 --- a/tests/Extensions/Gedmo/TreePathTest.php +++ b/tests/Extensions/Gedmo/TreePathTest.php @@ -32,7 +32,7 @@ class TreePathTest extends TestCase protected function setUp(): void { - $this->fieldName = 'path'; + $this->fieldName = 'path'; $this->classMetadata = new ExtensibleClassMetadata('foo'); Field::make(new ClassMetadataBuilder($this->classMetadata), 'integer', $this->fieldName)->build(); @@ -43,8 +43,12 @@ class TreePathTest extends TestCase { TreePath::enable(); - $field = Field::make(new ClassMetadataBuilder( - new ExtensibleClassMetadata('Foo')), 'integer', $this->fieldName + $field = Field::make( + new ClassMetadataBuilder( + new ExtensibleClassMetadata('Foo') + ), + 'integer', + $this->fieldName )->build(); $this->assertInstanceOf( @@ -92,7 +96,6 @@ class TreePathTest extends TestCase $this->getExtension() ->separator('|||') ->build(); - } /** @@ -100,8 +103,9 @@ class TreePathTest extends TestCase * * @param array $expected * - * @return void * @throws \PHPUnit_Framework_ExpectationFailedException + * + * @return void */ protected function assertBuildResultIs(array $expected) { diff --git a/tests/Extensions/Gedmo/TreeRightTest.php b/tests/Extensions/Gedmo/TreeRightTest.php index 1c283c2a1584164c53318a874c9c97fda0711a81..e6ffcf8ed3c1ac66aedb3ff7f3ddaf1dab9d8f6f 100644 --- a/tests/Extensions/Gedmo/TreeRightTest.php +++ b/tests/Extensions/Gedmo/TreeRightTest.php @@ -32,7 +32,7 @@ class TreeRightTest extends TestCase protected function setUp(): void { - $this->fieldName = 'rgt'; + $this->fieldName = 'rgt'; $this->classMetadata = new ExtensibleClassMetadata('foo'); Field::make(new ClassMetadataBuilder($this->classMetadata), 'integer', $this->fieldName)->build(); @@ -43,8 +43,12 @@ class TreeRightTest extends TestCase { TreeRight::enable(); - $field = Field::make(new ClassMetadataBuilder( - new ExtensibleClassMetadata('Foo')), 'integer', $this->fieldName + $field = Field::make( + new ClassMetadataBuilder( + new ExtensibleClassMetadata('Foo') + ), + 'integer', + $this->fieldName )->build(); $this->assertInstanceOf( @@ -79,8 +83,9 @@ class TreeRightTest extends TestCase * * @param array $expected * - * @return void * @throws \PHPUnit_Framework_ExpectationFailedException + * + * @return void */ protected function assertBuildResultIs(array $expected) { diff --git a/tests/Extensions/Gedmo/TreeSelfReferenceTest.php b/tests/Extensions/Gedmo/TreeSelfReferenceTest.php index c0e2f3b564df3d36230f6a636abd96976881ac00..098a8a1118036211bd4c75c847e7277674fdf93e 100644 --- a/tests/Extensions/Gedmo/TreeSelfReferenceTest.php +++ b/tests/Extensions/Gedmo/TreeSelfReferenceTest.php @@ -28,7 +28,7 @@ class TreeSelfReferenceTest extends TestCase protected function setUp(): void { - $this->fieldName = 'root'; + $this->fieldName = 'root'; $this->classMetadata = new ExtensibleClassMetadata('foo'); Field::make(new ClassMetadataBuilder($this->classMetadata), 'integer', $this->fieldName)->build(); } @@ -40,8 +40,12 @@ class TreeSelfReferenceTest extends TestCase { TreeSelfReference::enable(); - $field = Field::make(new ClassMetadataBuilder( - new ExtensibleClassMetadata('Foo')), 'integer', $this->fieldName + $field = Field::make( + new ClassMetadataBuilder( + new ExtensibleClassMetadata('Foo') + ), + 'integer', + $this->fieldName )->build(); $this->assertInstanceOf( @@ -57,8 +61,13 @@ class TreeSelfReferenceTest extends TestCase { TreeSelfReference::enable(); - $relation = new ManyToOne(new ClassMetadataBuilder( - new ExtensibleClassMetadata('Foo')), new DefaultNamingStrategy(), $this->fieldName, 'Foo' + $relation = new ManyToOne( + new ClassMetadataBuilder( + new ExtensibleClassMetadata('Foo') + ), + new DefaultNamingStrategy(), + $this->fieldName, + 'Foo' ); $this->assertInstanceOf( @@ -148,8 +157,9 @@ class TreeSelfReferenceTest extends TestCase * * @param array $expected * - * @return void * @throws \PHPUnit_Framework_ExpectationFailedException + * + * @return void */ protected function assertBuildResultIs(array $expected) { diff --git a/tests/Extensions/Gedmo/TreeStrategyTest.php b/tests/Extensions/Gedmo/TreeStrategyTest.php index cc676611cfcea811afe1a74d9bc159bc393cb1ae..b8b9b54d24abb92c886f671e9ced9300d85dc41a 100644 --- a/tests/Extensions/Gedmo/TreeStrategyTest.php +++ b/tests/Extensions/Gedmo/TreeStrategyTest.php @@ -36,6 +36,7 @@ abstract class TreeStrategyTest extends TestCase /** * @param Fluent $builder + * * @return TreeStrategy */ abstract protected function getStrategy(Fluent $builder); @@ -46,8 +47,8 @@ abstract class TreeStrategyTest extends TestCase protected function bootStrategy() { $this->classMetadata = new ExtensibleClassMetadata('foo'); - $this->builder = new Builder(new ClassMetadataBuilder($this->classMetadata)); - $this->strategy = $this->getStrategy($this->builder); + $this->builder = new Builder(new ClassMetadataBuilder($this->classMetadata)); + $this->strategy = $this->getStrategy($this->builder); } public function test_it_should_create_a_belongs_to_relation_to_the_parent_class_on_the_given_field() @@ -62,6 +63,7 @@ abstract class TreeStrategyTest extends TestCase /** * @param string $fieldName + * * @dataProvider getAllFields */ public function test_can_set_a_custom_field($fieldName) @@ -73,6 +75,7 @@ abstract class TreeStrategyTest extends TestCase /** * @param string $fieldName + * * @dataProvider getNumericFields */ public function test_can_set_a_custom_field_as_integer($fieldName) @@ -84,6 +87,7 @@ abstract class TreeStrategyTest extends TestCase /** * @param string $fieldName + * * @dataProvider getNumericFields */ public function test_can_set_a_custom_field_as_big_int($fieldName) @@ -95,6 +99,7 @@ abstract class TreeStrategyTest extends TestCase /** * @param string $fieldName + * * @dataProvider getNumericFields */ public function test_can_set_a_custom_field_as_small_int($fieldName) @@ -116,6 +121,7 @@ abstract class TreeStrategyTest extends TestCase /** * @dataProvider getNumericFields + * * @param string $fieldName */ public function test_it_allows_further_field_configuration_through_a_callback($fieldName) @@ -123,7 +129,7 @@ abstract class TreeStrategyTest extends TestCase $mock = \Mockery::mock(['callMe' => true]); $mock->shouldReceive('callMe')->once(); - $this->strategy->$fieldName('custom', 'integer', function($field) use ($mock) { + $this->strategy->$fieldName('custom', 'integer', function ($field) use ($mock) { $this->assertInstanceOf(Field::class, $field); $mock->callMe(); }); @@ -137,7 +143,7 @@ abstract class TreeStrategyTest extends TestCase $mock = \Mockery::mock(['callMe' => true]); $mock->shouldReceive('callMe')->once(); - $this->strategy->$relation('myself', function($belongsTo) use ($mock) { + $this->strategy->$relation('myself', function ($belongsTo) use ($mock) { $this->assertInstanceOf(ManyToOne::class, $belongsTo); $mock->callMe(); }); @@ -145,12 +151,11 @@ abstract class TreeStrategyTest extends TestCase public function test_it_always_maps_the_parent_self_reference_relation() { - $this->strategy->build(); + $this->strategy->build(); $this->assertExtensionKeyEquals('parent', 'parent'); } - public function getNumericFields() { return [ @@ -173,8 +178,9 @@ abstract class TreeStrategyTest extends TestCase * * @param array $expected * - * @return void * @throws \PHPUnit_Framework_ExpectationFailedException + * + * @return void */ protected function assertExtensionEquals(array $expected) { @@ -185,10 +191,11 @@ abstract class TreeStrategyTest extends TestCase * Assert that a given key of the built extension matches the expected value. * * @param string $key - * @param mixed $expected + * @param mixed $expected * - * @return void * @throws \PHPUnit_Framework_ExpectationFailedException + * + * @return void */ protected function assertExtensionKeyEquals($key, $expected) { diff --git a/tests/Extensions/Gedmo/TreeTest.php b/tests/Extensions/Gedmo/TreeTest.php index 009978c5a77e3c4bfbbff0db06b7b37b8254088e..37af55c362eb2fb892caf7cc060065eda3bfbf10 100644 --- a/tests/Extensions/Gedmo/TreeTest.php +++ b/tests/Extensions/Gedmo/TreeTest.php @@ -44,12 +44,13 @@ class TreeTest extends TestCase protected function setUp(): void { $this->classMetadata = new ExtensibleClassMetadata('foo'); - $this->builder = new Builder(new ClassMetadataBuilder($this->classMetadata), new DefaultNamingStrategy); - $this->extension = new Tree($this->builder); + $this->builder = new Builder(new ClassMetadataBuilder($this->classMetadata), new DefaultNamingStrategy()); + $this->extension = new Tree($this->builder); } /** * @runInSeparateProcess + * * @preserveGlobalState false */ public function test_it_should_add_itself_as_a_builder_macro() @@ -64,6 +65,7 @@ class TreeTest extends TestCase /** * @runInSeparateProcess + * * @preserveGlobalState false */ public function test_it_should_add_itself_as_a_builder_macro_with_optional_callback() @@ -73,21 +75,21 @@ class TreeTest extends TestCase $mock = \Mockery::mock(['callMe' => true]); $mock->shouldReceive('callMe')->once(); - $this->builder->tree(function(Tree $tree) use ($mock) { + $this->builder->tree(function (Tree $tree) use ($mock) { $mock->callMe(); }); } public function test_it_delegates_on_a_nested_set_buildable() { - $nested = $this->extension->asNestedSet(); + $nested = $this->extension->asNestedSet(); $this->assertInstanceOf(NestedSet::class, $nested); } public function test_it_builds_the_delegated_nested_set_on_build() { - $this->extension->asNestedSet(); + $this->extension->asNestedSet(); $this->extension->build(); $this->assertEquals('nested', $this->classMetadata->getExtension($this->getExtensionName())['strategy']); @@ -95,14 +97,14 @@ class TreeTest extends TestCase public function test_it_delegates_on_a_materialized_path_buildable() { - $materializedPath = $this->extension->asMaterializedPath(); + $materializedPath = $this->extension->asMaterializedPath(); $this->assertInstanceOf(MaterializedPath::class, $materializedPath); } public function test_it_builds_the_delegated_materialized_path_on_build() { - $this->extension->asMaterializedPath(); + $this->extension->asMaterializedPath(); $this->extension->build(); $this->assertEquals('materializedPath', $this->classMetadata->getExtension($this->getExtensionName())['strategy']); @@ -110,27 +112,27 @@ class TreeTest extends TestCase public function test_it_delegates_on_a_closure_table_buildable() { - $materializedPath = $this->extension->asClosureTable("Foo"); + $materializedPath = $this->extension->asClosureTable('Foo'); $this->assertInstanceOf(ClosureTable::class, $materializedPath); } public function test_it_builds_the_delegated_closure_table_on_build() { - $this->extension->asClosureTable("Foo"); + $this->extension->asClosureTable('Foo'); $this->extension->build(); $this->assertEquals('closure', $this->classMetadata->getExtension($this->getExtensionName())['strategy']); } - /** * Assert that the resulting build matches exactly with the given array. * * @param array $expected * - * @return void * @throws \PHPUnit_Framework_ExpectationFailedException + * + * @return void */ protected function assertBuildResultIs(array $expected) { diff --git a/tests/Extensions/Gedmo/UploadableFileTest.php b/tests/Extensions/Gedmo/UploadableFileTest.php index 494ebde864c8079f6b72dcfd3d54151d880bdcf6..2aecbacdfa011e1d5cd18d933ed91d95aa787969 100644 --- a/tests/Extensions/Gedmo/UploadableFileTest.php +++ b/tests/Extensions/Gedmo/UploadableFileTest.php @@ -24,25 +24,26 @@ class UploadableFileTest extends TestCase protected function setUp(): void { - $this->classMetadata = new ExtensibleClassMetadata("Foo"); + $this->classMetadata = new ExtensibleClassMetadata('Foo'); } /** * @dataProvider getTypes - * + * * @param string $type + * * @return void */ public function test_it_adds_itself_as_a_field_macro_for_type($type) { - UploadableFile::enable(); + UploadableFile::enable(); $field = Field::make(new ClassMetadataBuilder($this->classMetadata), 'string', $this->fieldName); - + call_user_func([$field, "asFile$type"])->build(); - + $this->assertExtension([ - "file{$type}Field" => $this->fieldName + "file{$type}Field" => $this->fieldName, ]); } @@ -55,62 +56,61 @@ class UploadableFileTest extends TestCase ['MimeType'], ]; } - - + public function test_it_holds_the_path() { - $this->getBuilder("Path")->build(); - + $this->getBuilder('Path')->build(); + $this->assertExtension([ - 'filePathField' => $this->fieldName + 'filePathField' => $this->fieldName, ]); } - + public function test_it_holds_the_name() { - $this->getBuilder("Name")->build(); - + $this->getBuilder('Name')->build(); + $this->assertExtension([ - 'fileNameField' => $this->fieldName + 'fileNameField' => $this->fieldName, ]); } - + public function test_it_holds_the_size() { - $this->getBuilder("Size")->build(); - + $this->getBuilder('Size')->build(); + $this->assertExtension([ - 'fileSizeField' => $this->fieldName + 'fileSizeField' => $this->fieldName, ]); } - + public function test_it_holds_the_mime_type() { - $this->getBuilder("MimeType")->build(); - + $this->getBuilder('MimeType')->build(); + $this->assertExtension([ - 'fileMimeTypeField' => $this->fieldName + 'fileMimeTypeField' => $this->fieldName, ]); } - + public function test_it_validates_the_type() { $this->expectException(InvalidMappingException::class); - - $this->getBuilder("Foo")->build(); + + $this->getBuilder('Foo')->build(); } - + public function test_it_merges_with_previous_extension_config() { - $this->classMetadata->addExtension(Fluent::EXTENSION_NAME, ['foo' => 'bar']); + $this->classMetadata->addExtension(Fluent::EXTENSION_NAME, ['foo' => 'bar']); $this->getBuilder('Name')->build(); - + $this->assertExtension([ - 'foo' => 'bar', - 'fileNameField' => $this->fieldName + 'foo' => 'bar', + 'fileNameField' => $this->fieldName, ]); } - + /** * @param string $type * diff --git a/tests/Extensions/Gedmo/UploadableTest.php b/tests/Extensions/Gedmo/UploadableTest.php index 56ae0fb588540e3c5d41c37f6c180bdbfb6295ad..b2114a970823c64a4d3ef938855d46075a0aea90 100644 --- a/tests/Extensions/Gedmo/UploadableTest.php +++ b/tests/Extensions/Gedmo/UploadableTest.php @@ -2,10 +2,10 @@ namespace Tests\Extensions\Gedmo; -use Doctrine\Persistence\Mapping\RuntimeReflectionService; use Doctrine\DBAL\Types\Type; use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder; use Doctrine\ORM\Mapping\DefaultNamingStrategy; +use Doctrine\Persistence\Mapping\RuntimeReflectionService; use Gedmo\Exception\InvalidMappingException; use Gedmo\Uploadable\FilenameGenerator\FilenameGeneratorInterface; use Gedmo\Uploadable\Mapping\Driver\Fluent; @@ -42,7 +42,7 @@ class UploadableTest extends TestCase { Uploadable::enable(); - $builder = new Builder(new ClassMetadataBuilder($this->classMetadata), new DefaultNamingStrategy); + $builder = new Builder(new ClassMetadataBuilder($this->classMetadata), new DefaultNamingStrategy()); $this->assertInstanceOf( Uploadable::class, @@ -54,7 +54,7 @@ class UploadableTest extends TestCase { Uploadable::enable(); - $builder = new Builder(new ClassMetadataBuilder($this->classMetadata), new DefaultNamingStrategy); + $builder = new Builder(new ClassMetadataBuilder($this->classMetadata), new DefaultNamingStrategy()); $builder->uploadable(); $builder->string('fooes')->asFileName(); @@ -208,7 +208,7 @@ class UploadableTest extends TestCase { $this->expectException(InvalidMappingException::class); - $this->workingBuilder()->allow('jpg')->disallow('doc')->build(); + $this->workingBuilder()->allow('jpg')->disallow('doc')->build(); } public function test_it_needs_a_field_set_up_as_path_or_name() @@ -248,7 +248,7 @@ class UploadableTest extends TestCase Uploadable::enable(); - $fluent = new Builder(new ClassMetadataBuilder($this->classMetadata), new DefaultNamingStrategy); + $fluent = new Builder(new ClassMetadataBuilder($this->classMetadata), new DefaultNamingStrategy()); $fluent->uploadable(); $fluent->field($type, 'bar')->asFilePath(); $fluent->build(); @@ -263,7 +263,7 @@ class UploadableTest extends TestCase Uploadable::enable(); - $fluent = new Builder(new ClassMetadataBuilder($this->classMetadata), new DefaultNamingStrategy); + $fluent = new Builder(new ClassMetadataBuilder($this->classMetadata), new DefaultNamingStrategy()); $fluent->uploadable(); $fluent->field($type, 'bar')->asFileName(); $fluent->build(); @@ -278,7 +278,7 @@ class UploadableTest extends TestCase Uploadable::enable(); - $fluent = new Builder(new ClassMetadataBuilder($this->classMetadata), new DefaultNamingStrategy); + $fluent = new Builder(new ClassMetadataBuilder($this->classMetadata), new DefaultNamingStrategy()); $fluent->uploadable(); $fluent->field($type, 'bar')->asFileMimeType(); $fluent->build(); @@ -293,7 +293,7 @@ class UploadableTest extends TestCase Uploadable::enable(); - $fluent = new Builder(new ClassMetadataBuilder($this->classMetadata), new DefaultNamingStrategy); + $fluent = new Builder(new ClassMetadataBuilder($this->classMetadata), new DefaultNamingStrategy()); $fluent->uploadable(); $fluent->field($type, 'bar')->asFileSize(); $fluent->build(); @@ -323,7 +323,7 @@ class UploadableTest extends TestCase 'filePathField' => false, 'fileSizeField' => false, 'filenameGenerator' => Validator::FILENAME_GENERATOR_NONE, - 'maxSize' => (double)0, + 'maxSize' => (float) 0, 'allowedTypes' => false, 'disallowedTypes' => false, ], $overrides); @@ -356,7 +356,7 @@ class UploadableTest extends TestCase $types = Type::getTypesMap(); unset($types[$type]); - return array_map(function($type){ + return array_map(function ($type) { return [$type]; }, array_keys($types)); } diff --git a/tests/Extensions/Gedmo/VersionedTest.php b/tests/Extensions/Gedmo/VersionedTest.php index cb5125c777ed8e39eefd48d1e9c07fcab0ece4f9..7e6ec07a0e43904c3240bdfcb5e565d3bfc6fa72 100644 --- a/tests/Extensions/Gedmo/VersionedTest.php +++ b/tests/Extensions/Gedmo/VersionedTest.php @@ -32,7 +32,7 @@ class VersionedTest extends TestCase protected function setUp(): void { $this->classMetadata = new ExtensibleClassMetadata('foo'); - $this->fieldName = 'someField'; + $this->fieldName = 'someField'; $this->builder = new Versioned($this->classMetadata, $this->fieldName); } @@ -60,7 +60,6 @@ class VersionedTest extends TestCase 'SomeEntity' ); - $relation->versioned(); $relation->build(); @@ -78,7 +77,6 @@ class VersionedTest extends TestCase 'SomeEntity' ); - $relation->versioned(); $relation->build(); diff --git a/tests/Extensions/GedmoExtensionsTest.php b/tests/Extensions/GedmoExtensionsTest.php index 777fb6253bbad6de3184d080c80209ab66bcbfe4..53bae5c4e281e47c1972b3b8bb43d3083a5c1c57 100644 --- a/tests/Extensions/GedmoExtensionsTest.php +++ b/tests/Extensions/GedmoExtensionsTest.php @@ -2,9 +2,9 @@ namespace Tests\Extensions; -use Doctrine\Persistence\Mapping\Driver\MappingDriverChain; use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder; use Doctrine\ORM\Mapping\DefaultNamingStrategy; +use Doctrine\Persistence\Mapping\Driver\MappingDriverChain; use Gedmo\Loggable\Entity\LogEntry; use Gedmo\Loggable\Entity\MappedSuperclass\AbstractLogEntry; use Gedmo\Translatable\Entity\MappedSuperclass\AbstractPersonalTranslation; diff --git a/tests/FluentDriverTest.php b/tests/FluentDriverTest.php index 64d996ee09153d5438a43c04805b5e6f264cb9c0..809d8fbc7f366543f0c96091b2ee6850c7b97aad 100644 --- a/tests/FluentDriverTest.php +++ b/tests/FluentDriverTest.php @@ -2,10 +2,10 @@ namespace Tests; -use Doctrine\Persistence\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder; use Doctrine\ORM\Mapping\ClassMetadataInfo; use Doctrine\ORM\Mapping\MappingException; +use Doctrine\Persistence\Mapping\ClassMetadata; use LaravelDoctrine\Fluent\Builders\Builder; use LaravelDoctrine\Fluent\EntityMapping; use LaravelDoctrine\Fluent\Fluent; @@ -25,9 +25,9 @@ class FluentDriverTest extends TestCase { public function test_it_should_load_metadata_for_entities_that_were_added_to_it() { - $driver = new FluentDriver; + $driver = new FluentDriver(); - $driver->addMapping(new FakeClassMapping); + $driver->addMapping(new FakeClassMapping()); $driver->loadMetadataForClass( FakeEntity::class, new ClassMetadataInfo(FakeEntity::class) @@ -41,9 +41,9 @@ class FluentDriverTest extends TestCase public function test_it_should_load_metadata_for_embeddables_that_were_added_to_it() { - $driver = new FluentDriver; + $driver = new FluentDriver(); - $driver->addMapping(new StubEmbeddableMapping); + $driver->addMapping(new StubEmbeddableMapping()); $driver->loadMetadataForClass( StubEmbeddable::class, new ClassMetadataInfo(StubEmbeddable::class) @@ -57,9 +57,9 @@ class FluentDriverTest extends TestCase public function test_it_should_load_metadata_for_mapped_super_classes_that_were_added_to_it() { - $driver = new FluentDriver; + $driver = new FluentDriver(); - $driver->addMapping(new StubMappedSuperClassMapping); + $driver->addMapping(new StubMappedSuperClassMapping()); $driver->loadMetadataForClass( StubMappedSuperClass::class, new ClassMetadataInfo(StubMappedSuperClass::class) @@ -76,7 +76,7 @@ class FluentDriverTest extends TestCase $driver = new FluentDriver([ StubEntityMapping::class, StubEmbeddableMapping::class, - StubMappedSuperClassMapping::class + StubMappedSuperClassMapping::class, ]); $driver->loadMetadataForClass( @@ -109,11 +109,11 @@ class FluentDriverTest extends TestCase public function test_can_add_array_of_new_mappings() { - $driver = new FluentDriver; + $driver = new FluentDriver(); $driver->addMappings([ FakeClassMapping::class, - StubEntityMapping::class + StubEntityMapping::class, ]); $this->assertContains( @@ -132,10 +132,10 @@ class FluentDriverTest extends TestCase $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Mapping class [Tests\DoesnExist] does not exist'); - $driver = new FluentDriver; + $driver = new FluentDriver(); $driver->addMappings([ - DoesnExist::class + DoesnExist::class, ]); } @@ -144,19 +144,19 @@ class FluentDriverTest extends TestCase $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Mapping class [Tests\Stubs\Entities\StubEntity] should implement LaravelDoctrine\Fluent\Mapping'); - $driver = new FluentDriver; + $driver = new FluentDriver(); $driver->addMappings([ - StubEntity::class + StubEntity::class, ]); } public function test_it_should_return_all_class_names_of_loaded_entities() { - $driver = new FluentDriver; + $driver = new FluentDriver(); - $driver->addMapping(new FakeClassMapping); - $driver->addMapping(new StubEntityMapping); + $driver->addMapping(new FakeClassMapping()); + $driver->addMapping(new StubEntityMapping()); $this->assertContains( FakeEntity::class, @@ -171,34 +171,34 @@ class FluentDriverTest extends TestCase public function test_entities_should_not_be_transient() { - $driver = new FluentDriver; + $driver = new FluentDriver(); - $driver->addMapping(new FakeClassMapping); + $driver->addMapping(new FakeClassMapping()); $this->assertFalse($driver->isTransient(FakeEntity::class)); } public function test_embeddables_should_be_transient() { - $driver = new FluentDriver; + $driver = new FluentDriver(); - $driver->addMapping(new StubEmbeddableMapping); + $driver->addMapping(new StubEmbeddableMapping()); $this->assertTrue($driver->isTransient(StubEmbeddable::class)); } public function test_mapped_super_classes_should_not_be_transient() { - $driver = new FluentDriver; + $driver = new FluentDriver(); - $driver->addMapping(new StubMappedSuperClassMapping); + $driver->addMapping(new StubMappedSuperClassMapping()); $this->assertFalse($driver->isTransient(StubMappedSuperClass::class)); } public function test_unmapped_classes_should_be_transient() { - $driver = new FluentDriver; + $driver = new FluentDriver(); $this->assertTrue($driver->isTransient(StubMappedSuperClass::class)); } @@ -248,7 +248,8 @@ class FakeClassMapping extends EntityMapping class FakeEntity { - protected $id, $name; + protected $id; + protected $name; } class CustomBuilder extends Builder diff --git a/tests/Mappers/EmbeddableMapperTest.php b/tests/Mappers/EmbeddableMapperTest.php index 3bd3cfc5efc835d2abe053c8d5144692ebf6cddf..3cdd19ab43160af106943088cc16c8115815b4ef 100644 --- a/tests/Mappers/EmbeddableMapperTest.php +++ b/tests/Mappers/EmbeddableMapperTest.php @@ -20,7 +20,7 @@ class EmbeddableMapperTest extends TestCase protected function setUp(): void { - $mapping = new StubEmbeddableMapping(); + $mapping = new StubEmbeddableMapping(); $this->mapper = new EmbeddableMapper($mapping); } @@ -37,7 +37,7 @@ class EmbeddableMapperTest extends TestCase public function test_it_should_delegate_the_proper_mapping_to_the_mapping_class() { $metadata = new ClassMetadataInfo(StubEmbeddable::class); - $builder = new Builder(new ClassMetadataBuilder($metadata)); + $builder = new Builder(new ClassMetadataBuilder($metadata)); $this->mapper->map($builder); diff --git a/tests/Mappers/EntityMapperTest.php b/tests/Mappers/EntityMapperTest.php index 38dc5acb4cde1d8a9c57981b345dc2a313382c12..81d66cbfb75fd3d4c978d0efe3fc2e684bbd02f0 100644 --- a/tests/Mappers/EntityMapperTest.php +++ b/tests/Mappers/EntityMapperTest.php @@ -20,7 +20,7 @@ class EntityMapperTest extends TestCase protected function setUp(): void { - $mapping = new StubEntityMapping; + $mapping = new StubEntityMapping(); $this->mapper = new EntityMapper($mapping); } @@ -37,7 +37,7 @@ class EntityMapperTest extends TestCase public function test_it_should_delegate_the_proper_mapping_to_the_mapping_class() { $metadata = new ClassMetadataInfo(StubEntity::class); - $builder = new Builder(new ClassMetadataBuilder($metadata)); + $builder = new Builder(new ClassMetadataBuilder($metadata)); $this->mapper->map($builder); diff --git a/tests/Mappers/MappedSuperClassMapperTest.php b/tests/Mappers/MappedSuperClassMapperTest.php index 36167255abf8c933f2de782b00552e37f03beca5..310e50fbe8bc89c380aa0df8abfda7dfbd333ccf 100644 --- a/tests/Mappers/MappedSuperClassMapperTest.php +++ b/tests/Mappers/MappedSuperClassMapperTest.php @@ -20,7 +20,7 @@ class MappedSuperClassMapperTest extends TestCase protected function setUp(): void { - $mapping = new StubMappedSuperClassMapping(); + $mapping = new StubMappedSuperClassMapping(); $this->mapper = new MappedSuperClassMapper($mapping); } @@ -37,7 +37,7 @@ class MappedSuperClassMapperTest extends TestCase public function test_it_should_delegate_the_proper_mapping_to_the_mapping_class() { $metadata = new ClassMetadataInfo(StubMappedSuperClass::class); - $builder = new Builder(new ClassMetadataBuilder($metadata)); + $builder = new Builder(new ClassMetadataBuilder($metadata)); $this->mapper->map($builder); diff --git a/tests/Mappers/MapperSetTest.php b/tests/Mappers/MapperSetTest.php index a5b97d5e94ca4210eed0dea9373bbefcbc84af60..3d1ba7c4187981c544ba07afd9d92d1337e88ac8 100644 --- a/tests/Mappers/MapperSetTest.php +++ b/tests/Mappers/MapperSetTest.php @@ -15,15 +15,15 @@ use Tests\Stubs\Mappings\StubEntityMapping; class MapperSetTest extends TestCase { /** - * @type MapperSet + * @var MapperSet */ protected $mapperSet; protected function setUp(): void { - $this->mapperSet = new MapperSet; - $this->mapperSet->add(new StubEntityMapping); - $this->mapperSet->add(new StubEmbeddableMapping); + $this->mapperSet = new MapperSet(); + $this->mapperSet->add(new StubEntityMapping()); + $this->mapperSet->add(new StubEmbeddableMapping()); } public function test_it_should_accumulate_mapping_implementations() @@ -55,19 +55,19 @@ class MapperSetTest extends TestCase public function test_can_check_if_has_mappers() { - $set = new MapperSet; + $set = new MapperSet(); $this->assertFalse($set->hasMappers()); - $set->add(new StubEntityMapping); + $set->add(new StubEntityMapping()); $this->assertTrue($set->hasMappers()); } public function test_can_get_mappers() { - $set = new MapperSet; + $set = new MapperSet(); $this->assertCount(0, $set->getMappers()); - $mapping = new StubEntityMapping; + $mapping = new StubEntityMapping(); $set->add($mapping); $this->assertCount(1, $set->getMappers()); diff --git a/tests/Relations/ManyToManyTest.php b/tests/Relations/ManyToManyTest.php index 7f3fe925e5bf42ac7bc60ec398d863be41f26e67..32cf25bc0c34c71031264e175cf0f4b25b7dec7e 100644 --- a/tests/Relations/ManyToManyTest.php +++ b/tests/Relations/ManyToManyTest.php @@ -16,7 +16,13 @@ use Tests\Relations\Traits\Owning; class ManyToManyTest extends RelationTestCase { - use Indexable, Orderable, Owning, Ownable, NonPrimary, IsMacroable, MockeryPHPUnitIntegration; + use Indexable; + use Orderable; + use Owning; + use Ownable; + use NonPrimary; + use IsMacroable; + use MockeryPHPUnitIntegration; /** * @var ManyToMany @@ -39,8 +45,12 @@ class ManyToManyTest extends RelationTestCase FluentEntity::class )); - $this->relation = new ManyToMany($this->builder, new DefaultNamingStrategy(), $this->field, - FluentEntity::class); + $this->relation = new ManyToMany( + $this->builder, + new DefaultNamingStrategy(), + $this->field, + FluentEntity::class + ); } public function test_can_set_join_table() @@ -59,8 +69,10 @@ class ManyToManyTest extends RelationTestCase $this->relation->build(); $this->assertEquals('join_column', $this->getAssocValue($this->field, 'joinTable')['joinColumns'][0]['name']); - $this->assertEquals('other_reference', - $this->getAssocValue($this->field, 'joinTable')['joinColumns'][0]['referencedColumnName']); + $this->assertEquals( + 'other_reference', + $this->getAssocValue($this->field, 'joinTable')['joinColumns'][0]['referencedColumnName'] + ); $this->assertFalse($this->getAssocValue($this->field, 'joinTable')['joinColumns'][0]['nullable']); $this->assertFalse($this->getAssocValue($this->field, 'joinTable')['joinColumns'][0]['unique']); } @@ -72,8 +84,10 @@ class ManyToManyTest extends RelationTestCase $this->relation->build(); $this->assertEquals('join_column', $this->getAssocValue($this->field, 'joinTable')['joinColumns'][0]['name']); - $this->assertEquals('other_reference', - $this->getAssocValue($this->field, 'joinTable')['joinColumns'][0]['referencedColumnName']); + $this->assertEquals( + 'other_reference', + $this->getAssocValue($this->field, 'joinTable')['joinColumns'][0]['referencedColumnName'] + ); $this->assertFalse($this->getAssocValue($this->field, 'joinTable')['joinColumns'][0]['nullable']); $this->assertTrue($this->getAssocValue($this->field, 'joinTable')['joinColumns'][0]['unique']); } @@ -85,8 +99,10 @@ class ManyToManyTest extends RelationTestCase $this->relation->build(); $this->assertEquals('foreign_key', $this->getAssocValue($this->field, 'joinTable')['joinColumns'][0]['name']); - $this->assertEquals('other_reference', - $this->getAssocValue($this->field, 'joinTable')['joinColumns'][0]['referencedColumnName']); + $this->assertEquals( + 'other_reference', + $this->getAssocValue($this->field, 'joinTable')['joinColumns'][0]['referencedColumnName'] + ); $this->assertFalse($this->getAssocValue($this->field, 'joinTable')['joinColumns'][0]['nullable']); $this->assertFalse($this->getAssocValue($this->field, 'joinTable')['joinColumns'][0]['unique']); } @@ -98,8 +114,10 @@ class ManyToManyTest extends RelationTestCase $this->relation->build(); $this->assertEquals('foreign_key', $this->getAssocValue($this->field, 'joinTable')['joinColumns'][0]['name']); - $this->assertEquals('other_reference', - $this->getAssocValue($this->field, 'joinTable')['joinColumns'][0]['referencedColumnName']); + $this->assertEquals( + 'other_reference', + $this->getAssocValue($this->field, 'joinTable')['joinColumns'][0]['referencedColumnName'] + ); $this->assertFalse($this->getAssocValue($this->field, 'joinTable')['joinColumns'][0]['nullable']); $this->assertTrue($this->getAssocValue($this->field, 'joinTable')['joinColumns'][0]['unique']); } @@ -111,8 +129,10 @@ class ManyToManyTest extends RelationTestCase $this->relation->build(); $this->assertEquals('source', $this->getAssocValue($this->field, 'joinTable')['joinColumns'][0]['name']); - $this->assertEquals('other_reference', - $this->getAssocValue($this->field, 'joinTable')['joinColumns'][0]['referencedColumnName']); + $this->assertEquals( + 'other_reference', + $this->getAssocValue($this->field, 'joinTable')['joinColumns'][0]['referencedColumnName'] + ); $this->assertFalse($this->getAssocValue($this->field, 'joinTable')['joinColumns'][0]['nullable']); $this->assertFalse($this->getAssocValue($this->field, 'joinTable')['joinColumns'][0]['unique']); } @@ -124,8 +144,10 @@ class ManyToManyTest extends RelationTestCase $this->relation->build(); $this->assertEquals('source', $this->getAssocValue($this->field, 'joinTable')['joinColumns'][0]['name']); - $this->assertEquals('other_reference', - $this->getAssocValue($this->field, 'joinTable')['joinColumns'][0]['referencedColumnName']); + $this->assertEquals( + 'other_reference', + $this->getAssocValue($this->field, 'joinTable')['joinColumns'][0]['referencedColumnName'] + ); $this->assertFalse($this->getAssocValue($this->field, 'joinTable')['joinColumns'][0]['nullable']); $this->assertTrue($this->getAssocValue($this->field, 'joinTable')['joinColumns'][0]['unique']); } @@ -136,10 +158,14 @@ class ManyToManyTest extends RelationTestCase $this->relation->build(); - $this->assertEquals('inverse_key', - $this->getAssocValue($this->field, 'joinTable')['inverseJoinColumns'][0]['name']); - $this->assertEquals('other_reference', - $this->getAssocValue($this->field, 'joinTable')['inverseJoinColumns'][0]['referencedColumnName']); + $this->assertEquals( + 'inverse_key', + $this->getAssocValue($this->field, 'joinTable')['inverseJoinColumns'][0]['name'] + ); + $this->assertEquals( + 'other_reference', + $this->getAssocValue($this->field, 'joinTable')['inverseJoinColumns'][0]['referencedColumnName'] + ); $this->assertFalse($this->getAssocValue($this->field, 'joinTable')['inverseJoinColumns'][0]['nullable']); $this->assertFalse($this->getAssocValue($this->field, 'joinTable')['inverseJoinColumns'][0]['unique']); } @@ -150,10 +176,14 @@ class ManyToManyTest extends RelationTestCase $this->relation->build(); - $this->assertEquals('inverse_key', - $this->getAssocValue($this->field, 'joinTable')['inverseJoinColumns'][0]['name']); - $this->assertEquals('other_reference', - $this->getAssocValue($this->field, 'joinTable')['inverseJoinColumns'][0]['referencedColumnName']); + $this->assertEquals( + 'inverse_key', + $this->getAssocValue($this->field, 'joinTable')['inverseJoinColumns'][0]['name'] + ); + $this->assertEquals( + 'other_reference', + $this->getAssocValue($this->field, 'joinTable')['inverseJoinColumns'][0]['referencedColumnName'] + ); $this->assertFalse($this->getAssocValue($this->field, 'joinTable')['inverseJoinColumns'][0]['nullable']); $this->assertTrue($this->getAssocValue($this->field, 'joinTable')['inverseJoinColumns'][0]['unique']); } @@ -165,8 +195,10 @@ class ManyToManyTest extends RelationTestCase $this->relation->build(); $this->assertEquals('target', $this->getAssocValue($this->field, 'joinTable')['inverseJoinColumns'][0]['name']); - $this->assertEquals('other_reference', - $this->getAssocValue($this->field, 'joinTable')['inverseJoinColumns'][0]['referencedColumnName']); + $this->assertEquals( + 'other_reference', + $this->getAssocValue($this->field, 'joinTable')['inverseJoinColumns'][0]['referencedColumnName'] + ); $this->assertFalse($this->getAssocValue($this->field, 'joinTable')['inverseJoinColumns'][0]['nullable']); $this->assertFalse($this->getAssocValue($this->field, 'joinTable')['inverseJoinColumns'][0]['unique']); } @@ -178,8 +210,10 @@ class ManyToManyTest extends RelationTestCase $this->relation->build(); $this->assertEquals('target', $this->getAssocValue($this->field, 'joinTable')['inverseJoinColumns'][0]['name']); - $this->assertEquals('other_reference', - $this->getAssocValue($this->field, 'joinTable')['inverseJoinColumns'][0]['referencedColumnName']); + $this->assertEquals( + 'other_reference', + $this->getAssocValue($this->field, 'joinTable')['inverseJoinColumns'][0]['referencedColumnName'] + ); $this->assertFalse($this->getAssocValue($this->field, 'joinTable')['inverseJoinColumns'][0]['nullable']); $this->assertTrue($this->getAssocValue($this->field, 'joinTable')['inverseJoinColumns'][0]['unique']); } diff --git a/tests/Relations/ManyToOneTest.php b/tests/Relations/ManyToOneTest.php index 77ae26a230334e7ea361a40b5954daadc612710b..b5c7b0ccfad67024b6ee93045b24262bf08b809a 100644 --- a/tests/Relations/ManyToOneTest.php +++ b/tests/Relations/ManyToOneTest.php @@ -15,7 +15,10 @@ use Tests\Relations\Traits\Primary; class ManyToOneTest extends RelationTestCase { - use Owning, Primary, IsMacroable, MockeryPHPUnitIntegration; + use Owning; + use Primary; + use IsMacroable; + use MockeryPHPUnitIntegration; /** * @var ManyToOne diff --git a/tests/Relations/OneToManyTest.php b/tests/Relations/OneToManyTest.php index 97ce41d0f5785e6a14ad8f77d141ff455547b70e..c33f9277d89ba2816c8c4040ed0560e80935311e 100644 --- a/tests/Relations/OneToManyTest.php +++ b/tests/Relations/OneToManyTest.php @@ -15,7 +15,11 @@ use Tests\Relations\Traits\Ownable; class OneToManyTest extends RelationTestCase { - use OneTo, Indexable, Orderable, Ownable, NonPrimary; + use OneTo; + use Indexable; + use Orderable; + use Ownable; + use NonPrimary; /** * @var OneToMany diff --git a/tests/Relations/OneToOneTest.php b/tests/Relations/OneToOneTest.php index f1774972df80d0bf158abb1c62a7434366047f4d..df51cbddc125531fd3ea6b7b390e1bd92ec4fac7 100644 --- a/tests/Relations/OneToOneTest.php +++ b/tests/Relations/OneToOneTest.php @@ -17,7 +17,12 @@ use Tests\Relations\Traits\Primary; class OneToOneTest extends RelationTestCase { - use OneTo, Owning, Ownable, Primary, IsMacroable, MockeryPHPUnitIntegration; + use OneTo; + use Owning; + use Ownable; + use Primary; + use IsMacroable; + use MockeryPHPUnitIntegration; /** * @var ManyToOne diff --git a/tests/Relations/RelationTestCase.php b/tests/Relations/RelationTestCase.php index 4b43d915c89f40c3bb4562c5b73c48fb50cbd0b7..e37906959cb6add6a94b4d860eb79db1511686ca 100644 --- a/tests/Relations/RelationTestCase.php +++ b/tests/Relations/RelationTestCase.php @@ -68,7 +68,7 @@ class RelationTestCase extends TestCase $cache = $this->getAssocValue($this->field, 'cache'); $this->assertEquals(1, $cache['usage']); - $this->assertEquals('tests_relations_fluententity__' . $this->field, $cache['region']); + $this->assertEquals('tests_relations_fluententity__'.$this->field, $cache['region']); } public function test_can_cache_the_association_with_usage() @@ -79,7 +79,7 @@ class RelationTestCase extends TestCase $cache = $this->getAssocValue($this->field, 'cache'); $this->assertEquals(3, $cache['usage']); - $this->assertEquals('tests_relations_fluententity__' . $this->field, $cache['region']); + $this->assertEquals('tests_relations_fluententity__'.$this->field, $cache['region']); } public function test_valid_cache_usage_should_be_given() @@ -126,5 +126,6 @@ class RelationTestCase extends TestCase class FluentEntity { - protected $parent, $children; + protected $parent; + protected $children; } diff --git a/tests/Relations/Traits/NonPrimary.php b/tests/Relations/Traits/NonPrimary.php index 2cd5b325f86785762f6c524217200105d055aa2e..58ba2b5049186ef2742fbcd7c135e9a6ba845291 100644 --- a/tests/Relations/Traits/NonPrimary.php +++ b/tests/Relations/Traits/NonPrimary.php @@ -9,7 +9,7 @@ trait NonPrimary $this->assertFalse($this->relation->getBuilder()->getClassMetadata()->isIdentifier($this->field)); $this->expectException('Doctrine\ORM\Mapping\MappingException'); - $this->expectExceptionMessage('Many-to-many or one-to-many associations are not allowed to be identifier in \'Tests\Relations\FluentEntity#' . $this->field . '\''); + $this->expectExceptionMessage('Many-to-many or one-to-many associations are not allowed to be identifier in \'Tests\Relations\FluentEntity#'.$this->field.'\''); $this->relation->makePrimaryKey(); $this->relation->build(); diff --git a/tests/Stubs/Entities/StubEntity.php b/tests/Stubs/Entities/StubEntity.php index 5ee27ec3d8c8b5269b2916581de488b170774d00..352e760d507bcd5277f1255c86566ccebc552f2c 100644 --- a/tests/Stubs/Entities/StubEntity.php +++ b/tests/Stubs/Entities/StubEntity.php @@ -4,5 +4,11 @@ namespace Tests\Stubs\Entities; class StubEntity { - protected $id, $name, $parent, $children, $one, $many, $slug; + protected $id; + protected $name; + protected $parent; + protected $children; + protected $one; + protected $many; + protected $slug; } diff --git a/tests/Stubs/Entities/StubEntity2.php b/tests/Stubs/Entities/StubEntity2.php index 9f812e41c3cc45622c2b27614727842d8d13e92a..7b4956c0cbd417014f60f34651c2e1acdbc8fc5e 100644 --- a/tests/Stubs/Entities/StubEntity2.php +++ b/tests/Stubs/Entities/StubEntity2.php @@ -4,5 +4,6 @@ namespace Tests\Stubs\Entities; class StubEntity2 { - protected $id, $name; + protected $id; + protected $name; } diff --git a/tests/Stubs/Entities/StubEntity3.php b/tests/Stubs/Entities/StubEntity3.php index dda608dd2c0cb5d6f60a969b38745258595810e9..c653828f50bc5218a34a55127c385df568c9e2da 100644 --- a/tests/Stubs/Entities/StubEntity3.php +++ b/tests/Stubs/Entities/StubEntity3.php @@ -4,5 +4,6 @@ namespace Tests\Stubs\Entities; class StubEntity3 { - protected $id, $name; + protected $id; + protected $name; } diff --git a/tests/Stubs/Mappings/StubEmbeddableMapping.php b/tests/Stubs/Mappings/StubEmbeddableMapping.php index 80cdd27b98ab94872a3c1c9f2ca77566b95764e6..38b51f649939fa1126f6910d5008ebcb51526279 100644 --- a/tests/Stubs/Mappings/StubEmbeddableMapping.php +++ b/tests/Stubs/Mappings/StubEmbeddableMapping.php @@ -20,6 +20,7 @@ class StubEmbeddableMapping extends EmbeddableMapping /** * Returns the fully qualified name of the entity that this mapper maps. + * * @return string */ public function mapFor() diff --git a/tests/Stubs/Mappings/StubMappedSuperClassMapping.php b/tests/Stubs/Mappings/StubMappedSuperClassMapping.php index f88a9fd1605cf5345a532f012892bf5fc7e26f42..c76a891e59e78187c6a02951b26e653c7acc22ad 100644 --- a/tests/Stubs/Mappings/StubMappedSuperClassMapping.php +++ b/tests/Stubs/Mappings/StubMappedSuperClassMapping.php @@ -20,6 +20,7 @@ class StubMappedSuperClassMapping extends MappedSuperClassMapping /** * Returns the fully qualified name of the entity that this mapper maps. + * * @return string */ public function mapFor() diff --git a/tests/Stubs/StubEntityListener.php b/tests/Stubs/StubEntityListener.php index 8f6b83d0da209647e4e163922e786401714b24b7..820f8ad31a2b3ae339c8ba12b9c617aead6060f8 100644 --- a/tests/Stubs/StubEntityListener.php +++ b/tests/Stubs/StubEntityListener.php @@ -23,4 +23,4 @@ class StubEntityListener public function onClear() { } -} \ No newline at end of file +}