Skip to content

Commit 99dd33f

Browse files
smnandrekbond
authored andcommitted
Fix Doctrine Proxy resolution and Add shorter timeout to avoid minutes-long tests
1 parent 2b981bf commit 99dd33f

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

src/Turbo/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# CHANGELOG
22

3+
## 2.19.0
4+
5+
- Fix Doctrine proxies are not Broadcasted #3139
6+
37
## 2.15.0
48

59
- Add Turbo 8 support #1476

src/Turbo/src/Doctrine/ClassUtil.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\UX\Turbo\Doctrine;
1313

14-
use Doctrine\Common\Util\ClassUtils as LegacyClassUtils;
1514
use Symfony\Component\VarExporter\LazyObjectInterface;
1615

1716
/**
@@ -24,13 +23,13 @@ final class ClassUtil
2423
*/
2524
public static function getEntityClass(object $entity): string
2625
{
27-
if ($entity instanceof LazyObjectInterface) {
26+
// Doctrine proxies (old versions)
27+
if (str_contains($entity::class, 'Proxies\\__CG__')) {
2828
return get_parent_class($entity) ?: $entity::class;
2929
}
3030

31-
// @legacy for old versions of Doctrine
32-
if (class_exists(LegacyClassUtils::class)) {
33-
return LegacyClassUtils::getClass($entity);
31+
if ($entity instanceof LazyObjectInterface) {
32+
return get_parent_class($entity) ?: $entity::class;
3433
}
3534

3635
return $entity::class;

src/Turbo/tests/BroadcastTest.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class BroadcastTest extends PantherTestCase
2727
protected function setUp(): void
2828
{
2929
if (!file_exists(__DIR__.'/app/public/build')) {
30-
throw new \Exception(\sprintf('Move into %s and execute Encore before running this test.', realpath(__DIR__.'/app')));
30+
throw new \Exception(\sprintf('Move into "%s" and execute Encore before running this test.', realpath(__DIR__.'/app')));
3131
}
3232

3333
parent::setUp();
@@ -38,7 +38,7 @@ public function testBroadcastBasic(): void
3838
($client = self::createPantherClient())->request('GET', '/books');
3939

4040
$crawler = $client->submitForm('Submit', ['title' => self::BOOK_TITLE]);
41-
$client->waitForElementToContain('#books div', self::BOOK_TITLE);
41+
// $client->waitForElementToContain('#books div', self::BOOK_TITLE);
4242

4343
$this->assertSelectorWillContain('#books', self::BOOK_TITLE);
4444
if (!preg_match('/\(#(\d+)\)/', $crawler->filter('#books div')->text(), $matches)) {
@@ -57,9 +57,10 @@ public function testExpressionLanguageBroadcast(): void
5757
($client = self::createPantherClient())->request('GET', '/artists');
5858

5959
$client->submitForm('Submit', ['name' => self::ARTIST_NAME_1]);
60-
$client->waitForElementToContain('#artists div:nth-child(1)', self::ARTIST_NAME_1);
60+
$client->waitForElementToContain('#artists div:nth-child(1)', self::ARTIST_NAME_1, 5);
61+
6162
$client->submitForm('Submit', ['name' => self::ARTIST_NAME_2]);
62-
$client->waitForElementToContain('#artists div:nth-child(2)', self::ARTIST_NAME_2);
63+
$client->waitForElementToContain('#artists div:nth-child(2)', self::ARTIST_NAME_2, 5);
6364

6465
$crawlerArtist = $client->getCrawler();
6566

@@ -78,7 +79,7 @@ public function testExpressionLanguageBroadcast(): void
7879

7980
$client->submitForm('Submit', ['title' => self::SONG_TITLE, 'artistId' => $artist1Id]);
8081

81-
$clientArtist1->waitForElementToContain('#songs div', self::SONG_TITLE);
82+
$clientArtist1->waitForElementToContain('#songs div', self::SONG_TITLE, 5);
8283

8384
$songsElement = $clientArtist2->findElement(WebDriverBy::cssSelector('#songs'));
8485

0 commit comments

Comments
 (0)