@@ -14,6 +14,22 @@ public function initProxy(FunctionalTester $I)
1414 $ I ->assertInstanceOf ('Codeception\Extension\BrowserMob ' , $ module );
1515 }
1616
17+ /**
18+ * @env autostart
19+ * @env blacklist
20+ * @env whitelist
21+ * @env limits
22+ * @env timeouts
23+ */
24+ public function parameters (FunctionalTester $ I )
25+ {
26+ $ port = $ I ->getProxyPort ();
27+ $ I ->assertNotNull ($ port );
28+ $ I ->closeProxy ();
29+ $ port = $ I ->getProxyPort ();
30+ //$I->assertNotNull($port); // BrowserMobProxy_Client issue
31+ }
32+
1733 /**
1834 * @covers ::openProxy
1935 * @covers ::startHar
@@ -38,18 +54,49 @@ public function captureHar(FunctionalTester $I)
3854 }
3955
4056 /**
41- * @env autostart
42- * @env blacklist
43- * @env whitelist
44- * @env limits
45- * @env timeouts
57+ * @covers ::openProxy
58+ * @covers ::startHar
59+ * @covers ::addPage
60+ * @covers ::getHar
4661 */
47- public function parameters (FunctionalTester $ I )
62+ public function captureHarWithPage (FunctionalTester $ I )
4863 {
49- $ port = $ I ->getProxyPort ();
50- $ I ->assertNotNull ($ port );
64+ $ port = $ I ->openProxy ();
65+ $ I ->assertNotNull ($ port , "` $ {port}` is not a valid port " );
66+ $ I ->startHar ('codeception ' );
67+ Requests::get ('http://codeception.com/ ' , [], ['proxy ' => "127.0.0.1: $ {port}" ]);
68+ $ rep = $ I ->addPage ('github ' );
69+ $ I ->assertTrue ($ rep );
70+ Requests::get ('http://github.com/ ' , [], ['proxy ' => "127.0.0.1: $ {port}" ]);
71+ $ har = $ I ->getHar ();
72+ $ I ->assertEquals ('BrowserMob Proxy ' , $ har ['log ' ]['creator ' ]['name ' ]);
73+ $ I ->assertNotEmpty ($ har ['log ' ]['entries ' ]);
74+ $ I ->assertEquals ('github ' , $ har ['log ' ]['entries ' ][1 ]['pageref ' ]);
75+ $ I ->closeProxy ();
76+ }
77+
78+ public function setHeaders (FunctionalTester $ I )
79+ {
80+ $ port = $ I ->openProxy ();
81+ $ I ->assertNotNull ($ port , "` $ {port}` is not a valid port " );
82+ $ rep = $ I ->setHeaders (['User-Agent ' => 'BrowserMob-Agent ' ]);
83+ $ I ->assertTrue ($ rep );
84+ $ I ->startHar ('codeception ' );
85+ Requests::get ('http://codeception.com/ ' , [], ['proxy ' => "127.0.0.1: $ {port}" ]);
86+ $ I ->getHar ();
87+ $ I ->closeProxy ();
88+ }
89+
90+ public function redirectUrl (FunctionalTester $ I )
91+ {
92+ $ port = $ I ->openProxy ();
93+ $ I ->assertNotNull ($ port , "` $ {port}` is not a valid port " );
94+ $ rep = $ I ->redirectUrl ('http://testdomain.url/ ' , 'http://codeception.com/ ' );
95+ $ I ->assertTrue ($ rep );
96+ $ I ->startHar ('codeception ' );
97+ Requests::get ('http://testdomain.url/ ' , [], ['proxy ' => "127.0.0.1: $ {port}" ]);
98+ $ har = $ I ->getHar ();
99+ $ I ->assertEquals ('http://codeception.com/ ' , $ har ['log ' ]['entries ' ][0 ]['request ' ]['url ' ]);
51100 $ I ->closeProxy ();
52- $ port = $ I ->getProxyPort ();
53- //$I->assertNotNull($port); // BrowserMobProxy_Client issue
54101 }
55102}
0 commit comments