File tree Expand file tree Collapse file tree 2 files changed +47
-0
lines changed
tests/unit/Codeception/Module Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -1508,4 +1508,29 @@ public function startFollowingRedirects()
15081508 {
15091509 $ this ->client ->followRedirects (true );
15101510 }
1511+
1512+ /**
1513+ * Sets SERVER parameters valid for all next requests.
1514+ * this will remove old ones.
1515+ *
1516+ * ```php
1517+ * $I->setServerParameters([]);
1518+ * ```
1519+ */
1520+ public function setServerParameters (array $ params )
1521+ {
1522+ $ this ->client ->setServerParameters ($ params );
1523+ }
1524+
1525+ /**
1526+ * Sets SERVER parameter valid for all next requests.
1527+ *
1528+ * ```php
1529+ * $I->haveServerParameter('name', 'value');
1530+ * ```
1531+ */
1532+ public function haveServerParameter ($ name , $ value )
1533+ {
1534+ $ this ->client ->setServerParameter ($ name , $ value );
1535+ }
15111536}
Original file line number Diff line number Diff line change @@ -442,6 +442,28 @@ public function testAmDigestAuthenticatedThrowsExceptionWithFunctionalModules()
442442 $ this ->module ->amDigestAuthenticated ('username ' , 'password ' );
443443 }
444444
445+ public function testCanResetHTTPAuthenticated ()
446+ {
447+ $ this ->module ->amHttpAuthenticated ('user ' , 'pass ' );
448+ $ this ->module ->sendGET ('/rest/user/ ' );
449+ $ server = $ this ->module ->client ->getRequest ()->getServer ();
450+ $ this ->assertArrayHasKey ('PHP_AUTH_USER ' , $ server );
451+ $ this ->assertArrayHasKey ('PHP_AUTH_PW ' , $ server );
452+ $ this ->module ->setServerParameters ([]);
453+ $ this ->module ->sendGET ('/rest/user/ ' );
454+ $ server = $ this ->module ->client ->getRequest ()->getServer ();
455+ $ this ->assertArrayNotHasKey ('PHP_AUTH_USER ' , $ server );
456+ $ this ->assertArrayNotHasKey ('PHP_AUTH_PW ' , $ server );
457+ }
458+
459+ public function testHaveServerParameter ()
460+ {
461+ $ this ->module ->haveServerParameter ('my ' , 'param ' );
462+ $ this ->module ->sendGET ('/rest/user/ ' );
463+ $ server = $ this ->module ->client ->getRequest ()->getServer ();
464+ $ this ->assertArrayHasKey ('my ' , $ server );
465+ }
466+
445467 /**
446468 * @param $configUrl
447469 * @param $requestUrl
You can’t perform that action at this time.
0 commit comments