Esempio n. 1
0
 public function testLoginToFacebook()
 {
     $this->markTestSkipped();
     // preconditions: #1 php web server being run
     $browserModule = new PhpBrowser(make_container());
     $browserModule->_setConfig(array('url' => 'http://localhost:8000'));
     $browserModule->_initialize();
     $browserModule->_cleanup();
     $browserModule->_before($this->makeTest());
     SuiteManager::$modules['PhpBrowser'] = $browserModule;
     // preconditions: #2 facebook test user was created
     $this->module->haveFacebookTestUserAccount();
     $testUserName = $this->module->grabFacebookTestUserName();
     // preconditions: #3 test user logged in on facebook
     $this->module->haveTestUserLoggedInOnFacebook();
     // go to our page with facebook login button
     $browserModule->amOnPage('/facebook');
     // check that yet we are not logged in with facebook
     $browserModule->see('You are not Connected.');
     // click on "Login with Facebook" button to start login with facebook
     $browserModule->click('Login with Facebook');
     // check that we are logged in with facebook
     $browserModule->see('Your User Object (/me)');
     $browserModule->see($testUserName);
     // cleanup
     unset(SuiteManager::$modules['PhpBrowser']);
     $browserModule->_after($this->makeTest());
     data::clean();
 }
 public function afterStep(\Codeception\Event\Step $e)
 {
     if (!$this->module) {
         return;
     }
     if ($error = $this->module->grabCookie('CODECEPTION_CODECOVERAGE_ERROR')) {
         throw new RemoteException($error);
     }
 }
Esempio n. 3
0
 public function testAjax()
 {
     $this->module->sendAjaxGetRequest('/info');
     $this->assertNotNull(data::get('ajax'));
     $this->module->sendAjaxPostRequest('/form/complex', array('show' => 'author'));
     $this->assertNotNull(data::get('ajax'));
     $post = data::get('form');
     $this->assertEquals('author', $post['show']);
 }
 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 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/2841
  */
 public function testSubmitFormDoesNotKeepGetParameters()
 {
     $this->module->amOnPage('/form/bug2841?stuff=other');
     $this->module->fillField('#texty', 'thingshjere');
     $this->module->click('#submit-registration');
     $this->assertEmpty(data::get('query'), 'Query string is not empty');
 }
Esempio n. 7
0
 public function testSwitchToIframe()
 {
     $this->module->amOnPage('/iframe');
     $this->module->switchToIframe('content');
     $this->module->see('Is that interesting?');
     $this->module->click('Ссылочка');
 }
Esempio n. 8
0
 /**
  * Initializes the module setting the properties values.
  * @return void
  */
 public function _initialize()
 {
     parent::_initialize();
     $this->loginUrl = str_replace('wp-admin', 'wp-login.php', $this->config['adminUrl']);
     $this->adminUrl = rtrim($this->config['adminUrl'], '/');
     $this->pluginsUrl = $this->adminUrl . '/plugins.php';
 }
Esempio n. 9
0
 public function testArrayFieldSubmitForm()
 {
     $this->module->amOnPage('/form/example17');
     $this->module->submitForm('form', ['FooBar' => ['bar' => 'booze'], 'Food' => ['beer' => ['yum' => ['yeah' => 'crunked']]]]);
     $data = data::get('form');
     $this->assertEquals('booze', $data['FooBar']['bar']);
     $this->assertEquals('crunked', $data['Food']['beer']['yum']['yeah']);
 }
Esempio n. 10
0
 /**
  * @issue https://github.com/Codeception/Codeception/issues/2234
  */
 public function testEmptyValueOfCookie()
 {
     //set cookie
     $this->module->amOnPage('/cookies2');
     $this->module->amOnPage('/unset-cookie');
     $this->module->seeResponseCodeIs(200);
     $this->module->dontSeeCookie('a');
 }
Esempio n. 11
0
 public function testSeeElementOnPage()
 {
     $this->module->amOnPage('/form/field');
     $this->module->seeElement('input[name=name]');
     $this->module->seeElement('descendant-or-self::input[@id="name"]');
     $this->module->dontSeeElement('#something-beyond');
     $this->module->dontSeeElement('descendant-or-self::input[@id="something-beyond"]');
 }
Esempio n. 12
0
 public function testSelectOptionTextSelector()
 {
     $this->module->amOnPage('/form/select_selectors');
     $this->module->selectOption('age', ['text' => '20']);
     $this->module->seeOptionIsSelected('age', '20');
     $this->module->selectOption('age', ['text' => '21']);
     $this->module->seeOptionIsSelected('age', '21');
 }
Esempio n. 13
0
 public function testFillFieldWithAmpersand()
 {
     $this->module->amOnPage('/form/field');
     $this->module->fillField('Name', 'this & that');
     $this->module->click('Submit');
     $form = data::get('form');
     $this->assertEquals('this & that', $form['name']);
 }
 /**
  * If we have a form with fields like
  * ```
  * <input type="file" name="foo" />
  * <input type="file" name="foo[bar]" />
  * ```
  * then only array variable will be used while simple variable will be ignored in php $_FILES
  * (eg $_FILES = [
  *                 foo => [
  *                     tmp_name => [
  *                         'bar' => 'asdf'
  *                     ],
  *                     //...
  *                ]
  *              ]
  * )
  * (notice there is no entry for file "foo", only for file "foo[bar]"
  * this will check if current element contains inner arrays within it's keys
  * so we can ignore element itself and only process inner files
  */
 public function testFormWithFilesInOnlyArray()
 {
     $this->shouldFail();
     $this->module->amOnPage('/form/example13');
     $this->module->attachFile('foo', 'app/avatar.jpg');
     $this->module->attachFile('foo[bar]', 'app/avatar.jpg');
     $this->module->click('Submit');
 }
Esempio n. 15
0
 public function testSubmitFormWithoutButton() {
     $this->module->amOnPage('/form/empty');
     $this->module->submitForm('form', array(
             'text' => 'Hello!'
     ));
     $form = data::get('form');
     $this->assertEquals('Hello!', $form['text']);
 }
Esempio n. 16
0
 public function testSubmitAdjacentForms()
 {
     $this->module->amOnPage('/form/submit_adjacentforms');
     $this->module->submitForm('#form-2', []);
     $data = data::get('form');
     $this->assertTrue(isset($data['second-field']));
     $this->assertFalse(isset($data['first-field']));
     $this->assertEquals('Killgore Trout', $data['second-field']);
 }
Esempio n. 17
0
 public function testLoadPageApi()
 {
     $this->module->_loadPage('POST', '/form/try', ['user' => 'davert']);
     $data = data::get('form');
     $this->assertEquals('davert', $data['user']);
     $this->module->see('Welcome to test app');
     $this->module->click('More info');
     $this->module->seeInCurrentUrl('/info');
 }
Esempio n. 18
0
 public function testMultipleCookies() {
     $this->module->amOnPage('/');
     $this->module->sendAjaxPostRequest('/cookies');
     $this->module->seeCookie('foo', 'bar1');
     $this->module->seeCookie('baz', 'bar2');
     $this->module->setCookie('foo', 'bar1');
     $this->module->setCookie('baz', 'bar2');
     $this->module->amOnPage('/cookies');
     $this->module->seeInCurrentUrl('info');
 }      
Esempio n. 19
0
 public function testFormWithFileSpecialCharNames()
 {
     $this->module->amOnPage('/form/example14');
     $this->module->attachFile('foo bar', 'app/avatar.jpg');
     $this->module->attachFile('foo.baz', 'app/avatar.jpg');
     $this->module->click('Submit');
     $this->assertNotEmpty(data::get('files'));
     $files = data::get('files');
     $this->assertNotEmpty($files);
     $this->assertArrayHasKey('foo_bar', $files);
     $this->assertArrayHasKey('foo_baz', $files);
 }
Esempio n. 20
0
 /**
  * @Issue https://github.com/Codeception/Codeception/issues/1585
  * @Issue https://github.com/Codeception/Codeception/issues/1602
  */
 public function testUnreachableField()
 {
     $this->module->amOnPage('/form/bug1585');
     $this->module->fillField('textarea[name="captions[]"]', 'test2');
     $this->module->fillField('items[1][]', 'test3');
     $this->module->fillField('input[name="users[]"]', 'davert');
     $this->module->attachFile('input[name="files[]"]', 'app/avatar.jpg');
     $this->module->click('Submit');
     $data = data::get('form');
     $this->assertContains('test3', $data['items'][1]);
     $this->assertContains('test2', $data['captions']);
     $this->assertContains('davert', $data['users']);
 }
Esempio n. 21
0
 public function testSelectAndCheckOptionSquareBracketNames()
 {
     $this->module->amOnPage('/form/names-sq-brackets');
     $this->module->selectOption('//input[@name="input_radio_name"]', '1');
     $this->module->selectOption('//input[@name="input_radio_name"]', '2');
     $this->module->checkOption('//input[@name="input_checkbox_name"]', '1');
     $this->module->checkOption('//input[@name="input_checkbox_name"]', '2');
     $this->module->checkOption('//input[@name="input[checkbox][name][]"]', '1');
     $this->module->checkOption('//input[@name="input[checkbox][name][]"]', '2');
     $this->module->checkOption('//input[@name="input[checkbox][name][]"]', '1');
     $this->module->selectOption('//select[@name="select_name"]', '1');
     $this->module->selectOption('//input[@name="input[radio][name][]"]', '1');
     $this->module->selectOption('//input[@name="input[radio][name][]"]', '2');
     $this->module->selectOption('//input[@name="input[radio][name][]"]', '1');
     $this->module->selectOption('//select[@name="select[name][]"]', '1');
 }
Esempio n. 22
0
 public function testGrabMultiple()
 {
     $this->module->amOnPage('/info');
     $arr = $this->module->grabMultiple('#grab-multiple a:first-child');
     $this->assertCount(1, $arr);
     $this->assertEquals('First', $arr[0]);
     $arr = $this->module->grabMultiple('#grab-multiple a');
     $this->assertCount(3, $arr);
     $this->assertEquals('First', $arr[0]);
     $this->assertEquals('Second', $arr[1]);
     $this->assertEquals('Third', $arr[2]);
     // href for WebDriver with selenium returns a full link, so testing with ID
     $arr = $this->module->grabMultiple('#grab-multiple a', 'id');
     $this->assertCount(3, $arr);
     $this->assertEquals('first-link', $arr[0]);
     $this->assertEquals('second-link', $arr[1]);
     $this->assertEquals('third-link', $arr[2]);
 }
Esempio n. 23
0
 public function testSetMultipleCookies()
 {
     $cookie_name_1 = 'test_cookie';
     $cookie_value_1 = 'this is a test';
     $this->module->setCookie($cookie_name_1, $cookie_value_1);
     $cookie_name_2 = '2_test_cookie';
     $cookie_value_2 = '2 this is a test';
     $this->module->setCookie($cookie_name_2, $cookie_value_2);
     $this->module->seeCookie($cookie_name_1);
     $this->module->seeCookie($cookie_name_2);
     $this->module->dontSeeCookie('evil_cookie');
     $cookie1 = $this->module->grabCookie($cookie_name_1);
     $this->assertEquals($cookie_value_1, $cookie1);
     $cookie2 = $this->module->grabCookie($cookie_name_2);
     $this->assertEquals($cookie_value_2, $cookie2);
     $this->module->resetCookie($cookie_name_1);
     $this->module->dontSeeCookie($cookie_name_1);
     $this->module->seeCookie($cookie_name_2);
     $this->module->resetCookie($cookie_name_2);
     $this->module->dontSeeCookie($cookie_name_2);
 }
Esempio n. 24
0
 /**
  * @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);
 }
Esempio n. 25
0
 public function testCanInspectResultOfPhpBrowserRequest()
 {
     $this->phpBrowser->amOnPage('/rest/user/');
     $this->module->seeResponseCodeIs(200);
     $this->module->seeResponseIsJson();
 }
Esempio n. 26
0
 public function testLinksWithNonLatin()
 {
     $this->module->amOnPage('/info');
     $this->module->seeLink('Ссылочка');
     $this->module->click('Ссылочка');
 }
Esempio n. 27
0
 public function testDontSeeElementOnPageFails()
 {
     $this->shouldFail();
     $this->module->amOnPage('/form/field');
     $this->module->dontSeeElement('descendant-or-self::input[@id="name"]');
 }
Esempio n. 28
0
 public function testFillFieldWithoutPage()
 {
     $this->setExpectedException("\\Codeception\\Exception\\TestRuntime");
     $this->module->fillField('#name', 'Nothing special');
 }
 public function testGrabFromCurrentUrl()
 {
     $this->module->sendGET('/rest/http-host/');
     $this->assertEquals('/rest/http-host/', $this->phpBrowser->grabFromCurrentUrl());
 }
Esempio n. 30
0
 public function testArrayField()
 {
     $this->module->amOnPage('/form/example17');
     $this->module->seeInField('input[name="FooBar[bar]"]', 'baz');
     $this->module->seeInField('input[name="Food[beer][yum][yeah]"]', 'mmhm');
 }