Skip to content

Allow to add or remove server params #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/Codeception/Lib/InnerBrowser.php
Original file line number Diff line number Diff line change
Expand Up @@ -2034,4 +2034,29 @@ protected function getNormalizedResponseContent()

return $content;
}

/**
* Sets SERVER parameters valid for all next requests.
* this will remove old ones.
*
* ```php
* $I->setServerParameters([]);
* ```
*/
public function setServerParameters(array $params)
{
$this->client->setServerParameters($params);
}

/**
* Sets SERVER parameter valid for all next requests.
*
* ```php
* $I->haveServerParameter('name', 'value');
* ```
*/
public function haveServerParameter($name, $value)
{
$this->client->setServerParameter($name, $value);
}
}
2 changes: 1 addition & 1 deletion tests/data/app/db
Original file line number Diff line number Diff line change
@@ -1 +1 @@
a:0:{}
a:0:{}
23 changes: 23 additions & 0 deletions tests/unit/Codeception/Module/TestsForWeb.php
Original file line number Diff line number Diff line change
Expand Up @@ -1746,4 +1746,27 @@ public function testPasswordArgument()
$data = data::get('form');
$this->assertEquals('thisissecret', $data['password']);
}


public function testCanResetHTTPAuthenticated()
{
$this->module->amHttpAuthenticated('user', 'pass');
$this->module->amOnPage('/');
$server = $this->module->client->getRequest()->getServer();
$this->assertArrayHasKey('PHP_AUTH_USER', $server);
$this->assertArrayHasKey('PHP_AUTH_PW', $server);
$this->module->setServerParameters([]);
$this->module->amOnPage('/');
$server = $this->module->client->getRequest()->getServer();
$this->assertArrayNotHasKey('PHP_AUTH_USER', $server);
$this->assertArrayNotHasKey('PHP_AUTH_PW', $server);
}

public function testHaveServerParameter()
{
$this->module->haveServerParameter('my', 'param');
$this->module->amOnPage('/');
$server = $this->module->client->getRequest()->getServer();
$this->assertArrayHasKey('my', $server);
}
}