@@ -23,6 +23,8 @@ class WindowManagerFake implements WindowManagerContract
2323
2424 public array $ shown = [];
2525
26+ public array $ reloaded = [];
27+
2628 public array $ forcedWindowReturnValues = [];
2729
2830 public function __construct (
@@ -74,6 +76,11 @@ public function show($id = null)
7476 $ this ->shown [] = $ id ;
7577 }
7678
79+ public function reload ($ id = null ): void
80+ {
81+ $ this ->reloaded [] = $ id ;
82+ }
83+
7784 public function current (): Window
7885 {
7986 $ this ->ensureForceReturnWindowsProvided ();
@@ -104,9 +111,9 @@ public function get(string $id): Window
104111 }
105112
106113 /**
107- * @param string|Closure(string): bool $id
114+ * @param null| string|Closure(string): bool $id
108115 */
109- public function assertOpened (string |Closure $ id ): void
116+ public function assertOpened (null | string |Closure $ id = null ): void
110117 {
111118 if (is_callable ($ id ) === false ) {
112119 PHPUnit::assertContains ($ id , $ this ->opened );
@@ -125,9 +132,9 @@ public function assertOpened(string|Closure $id): void
125132 }
126133
127134 /**
128- * @param string|Closure(string): bool $id
135+ * @param null| string|Closure(string): bool $id
129136 */
130- public function assertClosed (string |Closure $ id ): void
137+ public function assertClosed (null | string |Closure $ id = null ): void
131138 {
132139 if (is_callable ($ id ) === false ) {
133140 PHPUnit::assertContains ($ id , $ this ->closed );
@@ -146,9 +153,9 @@ public function assertClosed(string|Closure $id): void
146153 }
147154
148155 /**
149- * @param string|Closure(string): bool $id
156+ * @param null| string|Closure(string): bool $id
150157 */
151- public function assertHidden (string |Closure $ id ): void
158+ public function assertHidden (null | string |Closure $ id = null ): void
152159 {
153160 if (is_callable ($ id ) === false ) {
154161 PHPUnit::assertContains ($ id , $ this ->hidden );
@@ -167,9 +174,9 @@ public function assertHidden(string|Closure $id): void
167174 }
168175
169176 /**
170- * @param string|Closure(string): bool $id
177+ * @param null| string|Closure(string): bool $id
171178 */
172- public function assertShown (string |Closure $ id ): void
179+ public function assertShown (null | string |Closure $ id = null ): void
173180 {
174181 if (is_callable ($ id ) === false ) {
175182 PHPUnit::assertContains ($ id , $ this ->shown );
@@ -187,6 +194,48 @@ public function assertShown(string|Closure $id): void
187194 PHPUnit::assertTrue ($ hit );
188195 }
189196
197+ /**
198+ * @param null|string|Closure(string): bool $id
199+ */
200+ public function assertReloaded (null |string |Closure $ id = null ): void
201+ {
202+ if (is_callable ($ id ) === false ) {
203+ PHPUnit::assertContains ($ id , $ this ->reloaded );
204+
205+ return ;
206+ }
207+
208+ $ hit = empty (
209+ array_filter (
210+ $ this ->reloaded ,
211+ fn (mixed $ reloadedId ) => $ id ($ reloadedId ) === true
212+ )
213+ ) === false ;
214+
215+ PHPUnit::assertTrue ($ hit );
216+ }
217+
218+ /**
219+ * @param null|string|Closure(string): bool $id
220+ */
221+ public function assertNotReloaded (null |string |Closure $ id = null ): void
222+ {
223+ if (is_callable ($ id ) === false ) {
224+ PHPUnit::assertNotContains ($ id , $ this ->reloaded );
225+
226+ return ;
227+ }
228+
229+ $ hit = empty (
230+ array_filter (
231+ $ this ->reloaded ,
232+ fn (mixed $ reloadedId ) => $ id ($ reloadedId ) === true
233+ )
234+ ) === true ;
235+
236+ PHPUnit::assertTrue ($ hit );
237+ }
238+
190239 public function assertOpenedCount (int $ expected ): void
191240 {
192241 PHPUnit::assertCount ($ expected , $ this ->opened );
0 commit comments