TestsForBrowsers.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. require_once 'TestsForWeb.php';
  3. /**
  4. * Author: davert
  5. * Date: 13.01.12
  6. *
  7. * Class TestsForMink
  8. * Description:
  9. *
  10. */
  11. abstract class TestsForBrowsers extends TestsForWeb
  12. {
  13. public function testAmOnSubdomain()
  14. {
  15. $this->module->_reconfigure(array('url' => 'http://google.com'));
  16. $this->module->amOnSubdomain('user');
  17. $this->assertEquals('http://user.google.com', $this->module->_getUrl());
  18. $this->module->_reconfigure(array('url' => 'http://www.google.com'));
  19. $this->module->amOnSubdomain('user');
  20. $this->assertEquals('http://user.google.com', $this->module->_getUrl());
  21. }
  22. public function testOpenAbsoluteUrls()
  23. {
  24. $this->module->amOnUrl('http://localhost:8000/');
  25. $this->module->see('Welcome to test app!', 'h1');
  26. $this->module->amOnUrl('http://127.0.0.1:8000/info');
  27. $this->module->see('Information', 'h1');
  28. $this->module->amOnPage('/form/empty');
  29. $this->module->seeCurrentUrlEquals('/form/empty');
  30. $this->assertEquals('http://127.0.0.1:8000', $this->module->_getUrl(), 'Host has changed');
  31. }
  32. public function testHeadersRedirect()
  33. {
  34. $this->module->amOnPage('/redirect');
  35. $this->module->seeInCurrentUrl('info');
  36. }
  37. /*
  38. * https://github.com/Codeception/Codeception/issues/1510
  39. */
  40. public function testSiteRootRelativePathsForBasePathWithSubdir()
  41. {
  42. $this->module->_reconfigure(array('url' => 'http://localhost:8000/form'));
  43. $this->module->amOnPage('/relative_siteroot');
  44. $this->module->seeInCurrentUrl('/form/relative_siteroot');
  45. $this->module->submitForm('form', array(
  46. 'test' => 'value'
  47. ));
  48. $this->module->dontSeeInCurrentUrl('form/form/');
  49. $this->module->amOnPage('relative_siteroot');
  50. $this->module->click('Click me');
  51. $this->module->dontSeeInCurrentUrl('form/form/');
  52. }
  53. public function testOpenPageException()
  54. {
  55. $this->setExpectedException('Codeception\Exception\ModuleException');
  56. $this->module->see('Hello');
  57. }
  58. }