Skip to content

Commit d353809

Browse files
authored
Merge pull request #12337 from greg0ire/3.6.x
Merge 2.20.x up into 3.6.x
2 parents 8cbd34c + 0c1bf14 commit d353809

File tree

9 files changed

+25
-75
lines changed

9 files changed

+25
-75
lines changed

UPGRADE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2301,7 +2301,7 @@ from 2.0 have to configure the annotation driver if they don't use `Configuratio
23012301

23022302
## Scalar mappings can now be omitted from DQL result
23032303

2304-
You are now allowed to mark scalar SELECT expressions as HIDDEN an they are not hydrated anymore.
2304+
You are now allowed to mark scalar SELECT expressions as HIDDEN and they are not hydrated anymore.
23052305
Example:
23062306

23072307
SELECT u, SUM(a.id) AS HIDDEN numArticles FROM User u LEFT JOIN u.Articles a ORDER BY numArticles DESC HAVING numArticles > 10

docs/en/reference/second-level-cache.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ Caching mode
133133
* Read Write cache employs locks before update/delete.
134134
* Use if data needs to be updated.
135135
* Slowest strategy.
136-
* To use it a the cache region implementation must support locking.
136+
* To use it the cache region implementation must support locking.
137137

138138

139139
Built-in cached persisters

docs/en/reference/tools.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ have to register them yourself.
2222
All the commands of the Doctrine Console require access to the
2323
``EntityManager``. You have to inject it into the console application.
2424

25-
Here is an example of a the project-specific ``bin/doctrine`` binary.
25+
Here is an example of a project-specific ``bin/doctrine`` binary.
2626

2727
.. code-block:: php
2828

src/AbstractQuery.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,7 @@ public function setResultCacheId(string|null $id): static
10651065
}
10661066

10671067
/**
1068-
* Executes the query and returns a the resulting Statement object.
1068+
* Executes the query and returns the resulting Statement object.
10691069
*
10701070
* @return Result|int The executed database statement that holds
10711071
* the results, or an integer indicating how

src/Mapping/MappingException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public static function oneToManyRequiresMappedBy(string $entityName, string $fie
179179

180180
public static function joinTableRequired(string $fieldName): self
181181
{
182-
return new self(sprintf("The mapping of field '%s' requires an the 'joinTable' attribute.", $fieldName));
182+
return new self(sprintf("The mapping of field '%s' requires the 'joinTable' attribute.", $fieldName));
183183
}
184184

185185
/**

tests/Tests/ORM/Functional/Ticket/DDC2359Test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function testIssue(): void
4949
$entityManager->expects(self::any())->method('getConnection')->willReturn($connection);
5050
$entityManager
5151
->method('getEventManager')
52-
->willReturn($this->createMock(EventManager::class));
52+
->willReturn(new EventManager());
5353

5454
$metadataFactory->method('newClassMetadataInstance')->willReturn($mockMetadata);
5555
$metadataFactory->expects(self::once())->method('wakeupReflection');

tests/Tests/ORM/Functional/Ticket/GH10387Test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static function classHierachies(): Generator
3434
{
3535
yield 'hierarchy with Entity classes only' => [[GH10387EntitiesOnlyRoot::class, GH10387EntitiesOnlyMiddle::class, GH10387EntitiesOnlyLeaf::class]];
3636
yield 'MappedSuperclass in the middle of the hierarchy' => [[GH10387MappedSuperclassRoot::class, GH10387MappedSuperclassMiddle::class, GH10387MappedSuperclassLeaf::class]];
37-
yield 'abstract entity the the root and in the middle of the hierarchy' => [[GH10387AbstractEntitiesRoot::class, GH10387AbstractEntitiesMiddle::class, GH10387AbstractEntitiesLeaf::class]];
37+
yield 'abstract entity at the root and in the middle of the hierarchy' => [[GH10387AbstractEntitiesRoot::class, GH10387AbstractEntitiesMiddle::class, GH10387AbstractEntitiesLeaf::class]];
3838
}
3939
}
4040

tests/Tests/ORM/Functional/Ticket/GH6394Test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ protected function setUp(): void
2323
}
2424

2525
/**
26-
* Test the the version of an entity can be fetched, when the id field and
26+
* Test the version of an entity can be fetched, when the id field and
2727
* the id column are different.
2828
*/
2929
#[Group('6393')]

tests/Tests/ORM/Hydration/AbstractHydratorTest.php

Lines changed: 17 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#[CoversClass(AbstractHydrator::class)]
2828
class AbstractHydratorTest extends OrmFunctionalTestCase
2929
{
30-
private EventManager&MockObject $mockEventManager;
30+
private EventManager $eventManager;
3131
private Result&MockObject $mockResult;
3232
private ResultSetMapping&MockObject $mockResultMapping;
3333
private DummyHydrator $hydrator;
@@ -38,7 +38,7 @@ protected function setUp(): void
3838

3939
$mockConnection = $this->createMock(Connection::class);
4040
$mockEntityManagerInterface = $this->createMock(EntityManagerInterface::class);
41-
$this->mockEventManager = $this->createMock(EventManager::class);
41+
$this->eventManager = new EventManager();
4242
$this->mockResult = $this->createMock(Result::class);
4343
$this->mockResultMapping = $this->createMock(ResultSetMapping::class);
4444

@@ -47,7 +47,7 @@ protected function setUp(): void
4747
->willReturn($this->createMock(AbstractPlatform::class));
4848
$mockEntityManagerInterface
4949
->method('getEventManager')
50-
->willReturn($this->mockEventManager);
50+
->willReturn($this->eventManager);
5151
$mockEntityManagerInterface
5252
->method('getConnection')
5353
->willReturn($mockConnection);
@@ -66,85 +66,29 @@ protected function setUp(): void
6666
#[Group('#1515')]
6767
public function testOnClearEventListenerIsDetachedOnCleanup(): void
6868
{
69-
$eventListenerHasBeenRegistered = false;
70-
71-
$this
72-
->mockEventManager
73-
->expects(self::once())
74-
->method('addEventListener')
75-
->with([Events::onClear], $this->hydrator)
76-
->willReturnCallback(function () use (&$eventListenerHasBeenRegistered): void {
77-
$this->assertFalse($eventListenerHasBeenRegistered);
78-
$eventListenerHasBeenRegistered = true;
79-
});
80-
81-
$this
82-
->mockEventManager
83-
->expects(self::once())
84-
->method('removeEventListener')
85-
->with([Events::onClear], $this->hydrator)
86-
->willReturnCallback(function () use (&$eventListenerHasBeenRegistered): void {
87-
$this->assertTrue($eventListenerHasBeenRegistered);
88-
});
89-
90-
iterator_to_array($this->hydrator->toIterable($this->mockResult, $this->mockResultMapping));
69+
$iterator = $this->hydrator->toIterable($this->mockResult, $this->mockResultMapping);
70+
iterator_to_array($iterator);
71+
self::assertTrue($this->hydrator->hasListener);
72+
self::assertFalse($this->eventManager->hasListeners(Events::onClear));
9173
}
9274

9375
#[Group('#6623')]
9476
public function testHydrateAllRegistersAndClearsAllAttachedListeners(): void
9577
{
96-
$eventListenerHasBeenRegistered = false;
97-
98-
$this
99-
->mockEventManager
100-
->expects(self::once())
101-
->method('addEventListener')
102-
->with([Events::onClear], $this->hydrator)
103-
->willReturnCallback(function () use (&$eventListenerHasBeenRegistered): void {
104-
$this->assertFalse($eventListenerHasBeenRegistered);
105-
$eventListenerHasBeenRegistered = true;
106-
});
107-
108-
$this
109-
->mockEventManager
110-
->expects(self::once())
111-
->method('removeEventListener')
112-
->with([Events::onClear], $this->hydrator)
113-
->willReturnCallback(function () use (&$eventListenerHasBeenRegistered): void {
114-
$this->assertTrue($eventListenerHasBeenRegistered);
115-
});
116-
11778
$this->hydrator->hydrateAll($this->mockResult, $this->mockResultMapping);
79+
self::assertTrue($this->hydrator->hasListener);
80+
self::assertFalse($this->eventManager->hasListeners(Events::onClear));
11881
}
11982

12083
#[Group('#8482')]
12184
public function testHydrateAllClearsAllAttachedListenersEvenOnError(): void
12285
{
123-
$eventListenerHasBeenRegistered = false;
124-
125-
$this
126-
->mockEventManager
127-
->expects(self::once())
128-
->method('addEventListener')
129-
->with([Events::onClear], $this->hydrator)
130-
->willReturnCallback(function () use (&$eventListenerHasBeenRegistered): void {
131-
$this->assertFalse($eventListenerHasBeenRegistered);
132-
$eventListenerHasBeenRegistered = true;
133-
});
134-
135-
$this
136-
->mockEventManager
137-
->expects(self::once())
138-
->method('removeEventListener')
139-
->with([Events::onClear], $this->hydrator)
140-
->willReturnCallback(function () use (&$eventListenerHasBeenRegistered): void {
141-
$this->assertTrue($eventListenerHasBeenRegistered);
142-
});
143-
14486
$this->hydrator->throwException = true;
14587

14688
$this->expectException(LogicException::class);
14789
$this->hydrator->hydrateAll($this->mockResult, $this->mockResultMapping);
90+
self::assertTrue($this->hydrator->hasListener);
91+
self::assertFalse($this->eventManager->hasListeners(Events::onClear));
14892
}
14993

15094
public function testEnumCastsIntegerBackedEnumValues(): void
@@ -198,6 +142,7 @@ public function testToIterableIfYieldAndBreakBeforeFinishAlwaysCleansUp(): void
198142
class DummyHydrator extends AbstractHydrator
199143
{
200144
public bool $throwException = false;
145+
public bool $hasListener = false;
201146

202147
public function buildEnumForTesting(mixed $value, string $enumType): BackedEnum|array
203148
{
@@ -213,4 +158,9 @@ protected function hydrateAllData(): array
213158

214159
return [];
215160
}
161+
162+
public function prepare(): void
163+
{
164+
$this->hasListener = $this->em->getEventManager()->hasListeners(Events::onClear);
165+
}
216166
}

0 commit comments

Comments
 (0)