@@ -26,8 +26,8 @@ final class InterceptChildComponentRenderSubscriberTest extends KernelTestCase
26
26
// in buildUrlForTodoListComponent
27
27
private static array $ actualTodoItemFingerprints = [
28
28
AddLiveAttributesSubscriberTest::TODO_ITEM_DETERMINISTIC_PREFIX .'0 ' => 'dSQ4+SgsF3QWeK4ngSOM1ROM50s6N1kWAK6bYW2JjZU= ' ,
29
- AddLiveAttributesSubscriberTest::TODO_ITEM_DETERMINISTIC_PREFIX . ' 1 ' => 'sMvvf7q68tz/Cuk+vDeisDiq+7YPWzT+WZFzI37dGHY= ' ,
30
- AddLiveAttributesSubscriberTest::TODO_ITEM_DETERMINISTIC_PREFIX .'2 ' => '8AooEz36WYQyxj54BCaDm/jKbcdDdPDLaNO4/49bcQk= ' ,
29
+ AddLiveAttributesSubscriberTest::TODO_ITEM_DETERMINISTIC_PREFIX_EMBEDDED . ' 0 ' => 'sMvvf7q68tz/Cuk+vDeisDiq+7YPWzT+WZFzI37dGHY= ' ,
30
+ AddLiveAttributesSubscriberTest::TODO_ITEM_DETERMINISTIC_PREFIX .'1 ' => '8AooEz36WYQyxj54BCaDm/jKbcdDdPDLaNO4/49bcQk= ' ,
31
31
];
32
32
33
33
public function testItAllowsFullChildRenderOnMissingFingerprints (): void
@@ -74,6 +74,7 @@ public function testItRendersEmptyElementOnMatchingFingerprintWithCustomDataLive
74
74
public function testItRendersNewPropWhenFingerprintDoesNotMatch (): void
75
75
{
76
76
$ fingerprints = self ::$ actualTodoItemFingerprints ;
77
+ $ fingerprints [AddLiveAttributesSubscriberTest::TODO_ITEM_DETERMINISTIC_PREFIX_EMBEDDED .'0 ' ] = 'wrong fingerprint ' ;
77
78
$ fingerprints [AddLiveAttributesSubscriberTest::TODO_ITEM_DETERMINISTIC_PREFIX .'1 ' ] = 'wrong fingerprint ' ;
78
79
79
80
$ this ->browser ()
@@ -93,11 +94,11 @@ public function testItRendersNewPropWhenFingerprintDoesNotMatch(): void
93
94
), $ content );
94
95
// new props are JUST the "textLength" + a checksum for it specifically
95
96
$ this ->assertStringContainsString (sprintf (
96
- '<li data-live-name-value="todo_item" data-live-id="%s1 " data-live-fingerprint-value="sMvvf7q68tz/Cuk+vDeisDiq+7YPWzT+WZFzI37dGHY=" data-live-props-value="{"textLength":18,"@checksum":"LGxXa9fMKrJ6PelkUPfqmdwnfkk+LORgoJHXyPpS3Pw="}"></li> ' ,
97
- AddLiveAttributesSubscriberTest::TODO_ITEM_DETERMINISTIC_PREFIX
97
+ '<li data-live-name-value="todo_item" data-live-id="%s0 " data-live-fingerprint-value="sMvvf7q68tz/Cuk+vDeisDiq+7YPWzT+WZFzI37dGHY=" data-live-props-value="{"textLength":18,"@checksum":"LGxXa9fMKrJ6PelkUPfqmdwnfkk+LORgoJHXyPpS3Pw="}"></li> ' ,
98
+ AddLiveAttributesSubscriberTest::TODO_ITEM_DETERMINISTIC_PREFIX_EMBEDDED
98
99
), $ content );
99
100
$ this ->assertStringContainsString (sprintf (
100
- '<li data-live-id="%s2 "></li> ' ,
101
+ '<li data-live-name-value="todo_item" data-live- id="%s1" data-live-fingerprint-value="8AooEz36WYQyxj54BCaDm/jKbcdDdPDLaNO4/49bcQk=" data-live-props-value="{"textLength":10,"@checksum":"BXUk7q6LI\/6Qx3c62Xiui6287YndmoK3QmVq6e5mcGk="} "></li> ' ,
101
102
AddLiveAttributesSubscriberTest::TODO_ITEM_DETERMINISTIC_PREFIX
102
103
), $ content );
103
104
});
@@ -107,11 +108,13 @@ public function testItUsesKeysToRenderChildrenLiveIds(): void
107
108
{
108
109
$ fingerprintValues = array_values (self ::$ actualTodoItemFingerprints );
109
110
$ fingerprints = [];
111
+ $ i = 0 ;
110
112
foreach ($ fingerprintValues as $ key => $ fingerprintValue ) {
113
+ $ prefix = 0 !== $ i ++ % 2 ? 'live-4172682817-the-key ' : 'live-521026374-the-key ' ;
111
114
// creating fingerprints keys to match todo_list_with_keys.html.twig
112
- $ fingerprints [' live-1745423312-the-key ' .$ key ] = $ fingerprintValue ;
115
+ $ fingerprints [$ prefix .$ key ] = $ fingerprintValue ;
113
116
}
114
- $ fingerprints ['live-1745423312 -the-key1 ' ] = 'wrong fingerprint ' ;
117
+ $ fingerprints ['live-4172682817 -the-key1 ' ] = 'wrong fingerprint ' ;
115
118
116
119
$ urlSimple = $ this ->doBuildUrlForComponent ('todo_list_with_keys ' , []);
117
120
$ urlWithChangedFingerprints = $ this ->doBuildUrlForComponent ('todo_list_with_keys ' , $ fingerprints );
@@ -122,12 +125,12 @@ public function testItUsesKeysToRenderChildrenLiveIds(): void
122
125
->assertHtml ()
123
126
->assertElementCount ('ul li ' , 3 )
124
127
// check for the live-id we expect based on the key
125
- ->assertContains ('data-live-id="live-1745423312 -the-key0" ' )
128
+ ->assertContains ('data-live-id="live-521026374 -the-key0" ' )
126
129
->assertNotContains ('key="the-key0" ' )
127
130
->visit ($ urlWithChangedFingerprints )
128
- ->assertContains ('<li data-live-id="live-1745423312 -the-key0"></li> ' )
131
+ ->assertContains ('<li data-live-id="live-521026374 -the-key0"></li> ' )
129
132
// this one is changed, so it renders a full element
130
- ->assertContains ('<li data-live-name-value="todo_item" data-live-id="live-1745423312 -the-key1" ' )
133
+ ->assertContains ('<li data-live-name-value="todo_item" data-live-id="live-4172682817 -the-key1" ' )
131
134
;
132
135
}
133
136
0 commit comments