Skip to content

Commit

Permalink
Fix Doctrine Proxy resolution and Add shorter timeout to avoid minute…
Browse files Browse the repository at this point in the history
…s-long tests
  • Loading branch information
smnandre authored and kbond committed Jun 26, 2024
1 parent 2b981bf commit 99dd33f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
4 changes: 4 additions & 0 deletions src/Turbo/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 2.19.0

- Fix Doctrine proxies are not Broadcasted #3139

## 2.15.0

- Add Turbo 8 support #1476
Expand Down
9 changes: 4 additions & 5 deletions src/Turbo/src/Doctrine/ClassUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace Symfony\UX\Turbo\Doctrine;

use Doctrine\Common\Util\ClassUtils as LegacyClassUtils;
use Symfony\Component\VarExporter\LazyObjectInterface;

/**
Expand All @@ -24,13 +23,13 @@ final class ClassUtil
*/
public static function getEntityClass(object $entity): string
{
if ($entity instanceof LazyObjectInterface) {
// Doctrine proxies (old versions)
if (str_contains($entity::class, 'Proxies\\__CG__')) {
return get_parent_class($entity) ?: $entity::class;
}

// @legacy for old versions of Doctrine
if (class_exists(LegacyClassUtils::class)) {
return LegacyClassUtils::getClass($entity);
if ($entity instanceof LazyObjectInterface) {
return get_parent_class($entity) ?: $entity::class;
}

return $entity::class;
Expand Down
11 changes: 6 additions & 5 deletions src/Turbo/tests/BroadcastTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class BroadcastTest extends PantherTestCase
protected function setUp(): void
{
if (!file_exists(__DIR__.'/app/public/build')) {
throw new \Exception(\sprintf('Move into %s and execute Encore before running this test.', realpath(__DIR__.'/app')));
throw new \Exception(\sprintf('Move into "%s" and execute Encore before running this test.', realpath(__DIR__.'/app')));
}

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

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

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

$client->submitForm('Submit', ['name' => self::ARTIST_NAME_1]);
$client->waitForElementToContain('#artists div:nth-child(1)', self::ARTIST_NAME_1);
$client->waitForElementToContain('#artists div:nth-child(1)', self::ARTIST_NAME_1, 5);

$client->submitForm('Submit', ['name' => self::ARTIST_NAME_2]);
$client->waitForElementToContain('#artists div:nth-child(2)', self::ARTIST_NAME_2);
$client->waitForElementToContain('#artists div:nth-child(2)', self::ARTIST_NAME_2, 5);

$crawlerArtist = $client->getCrawler();

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

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

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

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

Expand Down

0 comments on commit 99dd33f

Please sign in to comment.