Skip to content

fixed failing tests for 3.1.x branch #660

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

Merged
merged 2 commits into from
Mar 10, 2025
Merged
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
40 changes: 20 additions & 20 deletions tests/Feature/IlluminateRegistryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace LaravelDoctrineTest\ORM\Feature;

use Doctrine\DBAL\Driver\Connection;
use Doctrine\ORM\Configuration;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
Expand All @@ -17,7 +18,6 @@
use LaravelDoctrineTest\ORM\TestCase;
use Mockery as m;
use RuntimeException;
use stdClass;
use Throwable;

class IlluminateRegistryTest extends TestCase
Expand Down Expand Up @@ -111,9 +111,9 @@ public function testCanGetDefaultConnection(): void

$this->container->shouldReceive('make')
->with('doctrine.connections.default')
->andReturn('connection');
->andReturn($conn = m::mock(Connection::class));

$this->assertEquals('connection', $this->registry->getConnection());
$this->assertEquals($conn, $this->registry->getConnection());
$this->assertEquals($this->registry->getConnection('default'), $this->registry->getConnection());
}

Expand All @@ -124,9 +124,9 @@ public function testCanGetCustomConnection(): void

$this->container->shouldReceive('make')
->with('doctrine.connections.custom')
->andReturn('connection');
->andReturn($conn = m::mock(Connection::class));

$this->assertEquals('connection', $this->registry->getConnection('custom'));
$this->assertEquals($conn, $this->registry->getConnection('custom'));
}

public function testCannotNonExistingConnection(): void
Expand All @@ -145,7 +145,7 @@ public function testConnectionGetsOnlyResolvedOnce(): void
$this->container->shouldReceive('make')
->once()// container@make will only be called once
->with('doctrine.connections.default')
->andReturn('connection');
->andReturn(m::mock(Connection::class));

$this->registry->getConnection();
$this->registry->getConnection();
Expand Down Expand Up @@ -182,20 +182,20 @@ public function testCanGetAllConnections(): void

$this->container->shouldReceive('make')
->with('doctrine.connections.default')
->andReturn('connection1');
->andReturn($conn1 = m::mock(Connection::class));

$this->container->shouldReceive('make')
->with('doctrine.connections.custom')
->andReturn('connection2');
->andReturn($conn2 = m::mock(Connection::class));

$this->registry->addConnection('default');
$this->registry->addConnection('custom');

$connections = $this->registry->getConnections();

$this->assertCount(2, $connections);
$this->assertContains('connection1', $connections);
$this->assertContains('connection2', $connections);
$this->assertContains($conn1, $connections);
$this->assertContains($conn2, $connections);
}

public function testCanGetDefaultManager(): void
Expand All @@ -205,9 +205,9 @@ public function testCanGetDefaultManager(): void

$this->container->shouldReceive('make')
->with('doctrine.managers.default')
->andReturn('manager');
->andReturn($em = m::mock(ObjectManager::class));

$this->assertEquals('manager', $this->registry->getManager());
$this->assertEquals($em, $this->registry->getManager());
$this->assertEquals($this->registry->getManager('default'), $this->registry->getManager());
}

Expand All @@ -218,9 +218,9 @@ public function testCanGetCustomManager(): void

$this->container->shouldReceive('make')
->with('doctrine.managers.custom')
->andReturn('connection');
->andReturn($em = m::mock(ObjectManager::class));

$this->assertEquals('connection', $this->registry->getManager('custom'));
$this->assertEquals($em, $this->registry->getManager('custom'));
}

public function testCannotNonExistingManager(): void
Expand All @@ -239,7 +239,7 @@ public function testManagerGetsOnlyResolvedOnce(): void
$this->container->shouldReceive('make')
->once()// container@make will only be called once
->with('doctrine.managers.default')
->andReturn('manager');
->andReturn($em = m::mock(ObjectManager::class));

$this->registry->getManager();
$this->registry->getManager();
Expand Down Expand Up @@ -276,20 +276,20 @@ public function testCanGetAllManagers(): void

$this->container->shouldReceive('make')
->with('doctrine.managers.default')
->andReturn('manager1');
->andReturn($em1 = m::mock(ObjectManager::class));

$this->container->shouldReceive('make')
->with('doctrine.managers.custom')
->andReturn('manager2');
->andReturn($em2 = m::mock(ObjectManager::class));

$this->registry->addManager('default');
$this->registry->addManager('custom');

$managers = $this->registry->getManagers();

$this->assertCount(2, $managers);
$this->assertContains('manager1', $managers);
$this->assertContains('manager2', $managers);
$this->assertContains($em1, $managers);
$this->assertContains($em2, $managers);
}

public function testCanPurgeDefaultManager(): void
Expand Down Expand Up @@ -574,7 +574,7 @@ public function testGetManagerAfterResetShouldReturnNewManager(): void

$this->container->shouldReceive('make')
->with('doctrine.managers.default')
->andReturn(new stdClass(), new stdClass());
->andReturn(m::mock(ObjectManager::class), m::mock(ObjectManager::class));

$first = $this->registry->getManager();

Expand Down
Loading