Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] primaryreplica connection init #561

Merged
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
3 changes: 3 additions & 0 deletions src/EntityManagerFactory.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php

Check failure on line 1 in src/EntityManagerFactory.php

View workflow job for this annotation

GitHub Actions / Static Analysis with PHPStan (8.0)

Ignored error pattern #^Method LaravelDoctrine\\ORM\\EntityManagerFactory\:\:hasValidPrimaryReadReplicaConfig\(\) has no return type specified\.$# in path /home/runner/work/orm/orm/src/EntityManagerFactory.php was not matched in reported errors.

Check failure on line 1 in src/EntityManagerFactory.php

View workflow job for this annotation

GitHub Actions / Static Analysis with PHPStan (8.1)

Ignored error pattern #^Method LaravelDoctrine\\ORM\\EntityManagerFactory\:\:hasValidPrimaryReadReplicaConfig\(\) has no return type specified\.$# in path /home/runner/work/orm/orm/src/EntityManagerFactory.php was not matched in reported errors.

namespace LaravelDoctrine\ORM;

Expand Down Expand Up @@ -524,6 +524,7 @@
* Check if slave configuration is valid.
*
* @param array $driverConfig
* @return bool
*/
private function hasValidPrimaryReadReplicaConfig(array $driverConfig)
{
Expand All @@ -540,5 +541,7 @@
if (($key = array_search(0, array_map('count', $slaves))) !== false) {
throw new \InvalidArgumentException("Parameter 'read' config no. {$key} is empty.");
}

return true;
}
}
5 changes: 3 additions & 2 deletions tests/EntityManagerFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use Doctrine\Common\Cache\Cache;
use Doctrine\Common\EventSubscriber;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Connections\PrimaryReadReplicaConnection;
use Doctrine\DBAL\Schema\DefaultSchemaManagerFactory;
use Doctrine\ORM\Cache\CacheFactory;
use Doctrine\ORM\Cache\RegionsConfiguration;
Expand Down Expand Up @@ -1172,9 +1173,9 @@ public function testPrimaryReadReplicaConnection(
}

$this->settings['connection'] = 'mysql';
$factory->create($this->settings);
$em = $factory->create($this->settings);

$this->assertTrue(true);
$this->assertInstanceOf(PrimaryReadReplicaConnection::class, $em->getConnection());
}

protected function tearDown(): void
Expand Down
Loading