@@ -98,4 +98,74 @@ public function testInvalidResolverDoesNotResolveGoogle()
9898 $ promise = $ this ->resolver ->resolve ('google.com ' );
9999 $ promise ->then ($ this ->expectCallableNever (), $ this ->expectCallableOnce ());
100100 }
101+
102+ public function testResolveShouldNotCauseGarbageReferencesWhenUsingInvalidNameserver ()
103+ {
104+ if (class_exists ('React\Promise\When ' )) {
105+ $ this ->markTestSkipped ('Not supported on legacy Promise v1 API ' );
106+ }
107+
108+ $ factory = new Factory ();
109+ $ this ->resolver = $ factory ->create ('255.255.255.255 ' , $ this ->loop );
110+
111+ gc_collect_cycles ();
112+
113+ $ promise = $ this ->resolver ->resolve ('google.com ' );
114+ unset($ promise );
115+
116+ $ this ->assertEquals (0 , gc_collect_cycles ());
117+ }
118+
119+ public function testResolveCachedShouldNotCauseGarbageReferencesWhenUsingInvalidNameserver ()
120+ {
121+ if (class_exists ('React\Promise\When ' )) {
122+ $ this ->markTestSkipped ('Not supported on legacy Promise v1 API ' );
123+ }
124+
125+ $ factory = new Factory ();
126+ $ this ->resolver = $ factory ->createCached ('255.255.255.255 ' , $ this ->loop );
127+
128+ gc_collect_cycles ();
129+
130+ $ promise = $ this ->resolver ->resolve ('google.com ' );
131+ unset($ promise );
132+
133+ $ this ->assertEquals (0 , gc_collect_cycles ());
134+ }
135+
136+ public function testCancelResolveShouldNotCauseGarbageReferences ()
137+ {
138+ if (class_exists ('React\Promise\When ' )) {
139+ $ this ->markTestSkipped ('Not supported on legacy Promise v1 API ' );
140+ }
141+
142+ $ factory = new Factory ();
143+ $ this ->resolver = $ factory ->create ('127.0.0.1 ' , $ this ->loop );
144+
145+ gc_collect_cycles ();
146+
147+ $ promise = $ this ->resolver ->resolve ('google.com ' );
148+ $ promise ->cancel ();
149+ $ promise = null ;
150+
151+ $ this ->assertEquals (0 , gc_collect_cycles ());
152+ }
153+
154+ public function testCancelResolveCachedShouldNotCauseGarbageReferences ()
155+ {
156+ if (class_exists ('React\Promise\When ' )) {
157+ $ this ->markTestSkipped ('Not supported on legacy Promise v1 API ' );
158+ }
159+
160+ $ factory = new Factory ();
161+ $ this ->resolver = $ factory ->createCached ('127.0.0.1 ' , $ this ->loop );
162+
163+ gc_collect_cycles ();
164+
165+ $ promise = $ this ->resolver ->resolve ('google.com ' );
166+ $ promise ->cancel ();
167+ $ promise = null ;
168+
169+ $ this ->assertEquals (0 , gc_collect_cycles ());
170+ }
101171}
0 commit comments