public function testBeforeHookResetsVariables() { $this->module->haveHttpHeader('Origin', 'http://www.example.com'); $this->module->sendGET('/rest/user/'); $this->assertEquals('http://www.example.com', $this->module->client->getServerParameter('HTTP_ORIGIN')); $this->module->_before(Stub::makeEmpty('\\Codeception\\TestCase\\Cest')); $this->assertNull($this->module->client->getServerParameter('HTTP_ORIGIN', null)); }
public function setUp() { $this->module = new \Codeception\Module\REST(); $connector = new \Codeception\Util\Connector\Universal(); $connector->setIndex(\Codeception\Configuration::dataDir() . '/rest/index.php'); $this->module->client = $connector; $this->module->_before(Stub::makeEmpty('\\Codeception\\TestCase\\Cest')); $this->module->client->setServerParameters(array('SCRIPT_FILENAME' => 'index.php', 'SCRIPT_NAME' => 'index', 'SERVER_NAME' => 'localhost', 'SERVER_PROTOCOL' => 'http')); }
public function setUp() { $this->phpBrowser = new \Codeception\Module\PhpBrowser(); $url = 'http://localhost:8010'; $this->phpBrowser->_setConfig(array('url' => $url)); $this->phpBrowser->_initialize(); $this->module = Stub::make('\\Codeception\\Module\\REST', ['getModules' => [$this->phpBrowser]]); $this->module->_initialize(); $this->module->_before(Stub::makeEmpty('\\Codeception\\TestCase\\Cest')); $this->phpBrowser->_before(Stub::makeEmpty('\\Codeception\\TestCase\\Cest')); }
public function testBeforeHookResetsVariables() { $this->module->haveHttpHeader('Origin', 'http://www.example.com'); $this->module->sendGET('/rest/user/'); $server = $this->module->client->getInternalRequest()->getServer(); $this->assertArrayHasKey('HTTP_ORIGIN', $server); $this->module->_before(Stub::makeEmpty('\\Codeception\\Test\\Test')); $this->module->sendGET('/rest/user/'); $server = $this->module->client->getInternalRequest()->getServer(); $this->assertArrayNotHasKey('HTTP_ORIGIN', $server); }
public function setUp() { $this->phpBrowser = new \Codeception\Module\PhpBrowser(); $url = 'http://localhost:8010'; $this->phpBrowser->_setConfig(array('url' => $url)); $this->phpBrowser->_initialize(); $this->phpBrowser->_before(Stub::makeEmpty('\Codeception\TestCase\Cest')); $this->module = new \Codeception\Module\REST(); $this->module->_initialize(); $this->module->client = $this->phpBrowser->client; $this->module->_before(Stub::makeEmpty('\Codeception\TestCase\Cest')); }
/** * @Issue https://github.com/Codeception/Codeception/issues/2075 * Client is undefined for the second test */ public function testTwoTests() { $cest1 = Stub::makeEmpty('\\Codeception\\TestCase\\Cest'); $cest2 = Stub::makeEmpty('\\Codeception\\TestCase\\Cest'); $this->module->sendGET('/rest/user/'); $this->module->seeResponseIsJson(); $this->module->seeResponseContains('davert'); $this->module->seeResponseContainsJson(array('name' => 'davert')); $this->module->seeResponseCodeIs(200); $this->module->dontSeeResponseCodeIs(404); $this->phpBrowser->_after($cest1); $this->module->_after($cest1); $this->module->_before($cest2); $this->phpBrowser->_before($cest2); $this->module->sendGET('/rest/user/'); $this->module->seeResponseIsJson(); $this->module->seeResponseContains('davert'); $this->module->seeResponseContainsJson(array('name' => 'davert')); $this->module->seeResponseCodeIs(200); $this->module->dontSeeResponseCodeIs(404); }