Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Relations/AbstractRelation.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ abstract protected function createAssociation(ClassMetadataBuilder $builder, $re
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');
Expand All @@ -105,7 +105,7 @@ public function cascade(array $cascade)
*/
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');
Expand Down
45 changes: 27 additions & 18 deletions tests/Builders/BuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@

class BuilderTest extends TestCase
{
use IsMacroable, MockeryPHPUnitIntegration;
use IsMacroable;
use MockeryPHPUnitIntegration;

/**
* @var ClassMetadataBuilder
Expand Down Expand Up @@ -549,8 +550,9 @@ public function test_has_one_implies_an_inverse_one_to_one()

$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.'
);
}

Expand Down Expand Up @@ -703,21 +705,21 @@ public function test_entity_listeners_can_be_configured_through_a_callable()
[
'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']);
}

Expand Down Expand Up @@ -745,8 +747,10 @@ public function test_can_override_many_to_one_association()

$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']);
}
Expand All @@ -761,8 +765,10 @@ public function test_can_override_many_to_many_association()

$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']);
}
Expand All @@ -778,7 +784,7 @@ public function test_can_guess_a_one_to_one_relation_name()
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());
}
}

Expand All @@ -793,7 +799,7 @@ public function test_can_guess_a_has_one_relation_name()
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());
}
}

Expand All @@ -808,7 +814,7 @@ public function test_can_guess_a_belongs_to_relation_name()
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());
}
}

Expand All @@ -823,7 +829,7 @@ public function test_can_guess_a_one_to_many_relation_name()
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());
}
}

Expand All @@ -838,7 +844,7 @@ public function test_can_guess_a_has_many_relation_name()
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());
}
}

Expand All @@ -853,7 +859,7 @@ public function test_can_guess_a_many_to_many_relation_name()
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());
}
}

Expand All @@ -868,7 +874,7 @@ public function test_can_guess_a_belongs_to_many_relation_name()
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());
}
}

Expand Down Expand Up @@ -909,5 +915,8 @@ protected function getMacroableBuilder()

class FluentEntity
{
protected $id, $name, $fluentEntity, $fluentEntities;
protected $id;
protected $name;
protected $fluentEntity;
protected $fluentEntities;
}
2 changes: 1 addition & 1 deletion tests/Builders/EmbeddedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected function setUp(): void

$this->embedded = new Embedded(
$this->builder,
new DefaultNamingStrategy,
new DefaultNamingStrategy(),
'field',
FluentEmbeddable::class
);
Expand Down
16 changes: 9 additions & 7 deletions tests/Builders/EntityListenersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@ public function test_can_add_event_listeners($event, $listener, $expectedMethod,
);

$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]);
}

Expand All @@ -74,18 +75,19 @@ public function test_can_add_multiple_entity_listeners_per_event()
);

$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']);
}

Expand Down
5 changes: 3 additions & 2 deletions tests/Builders/EntityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@

class EntityTest extends TestCase
{
use IsMacroable, MockeryPHPUnitIntegration;
use IsMacroable;
use MockeryPHPUnitIntegration;

/**
* @var ClassMetadataBuilder
Expand All @@ -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()
Expand Down
Loading