From f30858762490fcbc817a241c6376966619cef75e Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Tue, 19 Jan 2016 15:45:51 -0700 Subject: [PATCH 01/48] add SSL page variable and also force `include_host` if `absolute_urls: true` --- system/src/Grav/Common/Page/Page.php | 29 +++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index 916d99aca..9b96c83b1 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -87,6 +87,7 @@ class Page protected $last_modified; protected $home_route; protected $hide_home_route; + protected $ssl; /** * @var Page Unmodified (original) version of the page. Used for copying and moving the page. @@ -361,6 +362,9 @@ class Page if (isset($this->header->last_modified)) { $this->last_modified = (bool) $this->header->last_modified; } + if (isset($this->header->ssl)) { + $this->ssl = (bool) $this->header->ssl; + } } return $this->header; @@ -1118,6 +1122,15 @@ class Page return $this->routable && $this->published(); } + public function ssl($var = null) + { + if ($var !== null) { + $this->ssl = (bool) $var; + } + + return $this->ssl; + } + /** * Gets and Sets the process setup for this Page. This is multi-dimensional array that consists of * a simple array of arrays with the form array("markdown"=>true) for example @@ -1260,9 +1273,17 @@ class Page /** @var Pages $pages */ $pages = self::getGrav()['pages']; + /** @var Config $config */ + $config = self::getGrav()['config']; + /** @var Language $language */ $language = self::getGrav()['language']; + /** @var Uri $uri */ + $uri = self::getGrav()['uri']; + + $include_port = false; + // get pre-route if ($include_lang && $language->enabled()) { $pre_route = $language->getLanguageURLPrefix(); @@ -1270,6 +1291,11 @@ class Page $pre_route = ''; } + // add full route if configured to do so + if ($config->get('system.absolute_urls', false)) { + $include_host = true; + } + // get canonical route if requested if ($canonical) { $route = $pre_route . $this->routeCanonical(); @@ -1277,9 +1303,6 @@ class Page $route = $pre_route . $this->route(); } - /** @var Uri $uri */ - $uri = self::getGrav()['uri']; - $rootUrl = $uri->rootUrl($include_host) . $pages->base(); $url = $rootUrl.'/'.trim($route, '/') . $this->urlExtension(); From 4fa04f6eecf31388fc6aca99745b44cf65a794d0 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Tue, 19 Jan 2016 15:46:09 -0700 Subject: [PATCH 02/48] added `scheme` to URI --- system/src/Grav/Common/Uri.php | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/system/src/Grav/Common/Uri.php b/system/src/Grav/Common/Uri.php index bf16db18c..235e4c18d 100644 --- a/system/src/Grav/Common/Uri.php +++ b/system/src/Grav/Common/Uri.php @@ -15,6 +15,7 @@ class Uri public $url; + protected $scheme; protected $basename; protected $base; protected $root; @@ -35,12 +36,12 @@ class Uri */ public function __construct() { - $name = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'localhost'); - // Remove port from HTTP_HOST generated $name - $name = Utils::substrToString($name, ':'); + $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'localhost'); + // Remove port from HTTP_HOST generated $host + $host = Utils::substrToString($host, ':'); // Validate the hostname - $name = preg_match(Uri::HOSTNAME_REGEX, $name) ? $name : 'unknown'; + $host = preg_match(Uri::HOSTNAME_REGEX, $host) ? $host : 'unknown'; $port = isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : 80; $uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''; @@ -49,13 +50,13 @@ class Uri // set the base if (isset($_SERVER['HTTPS'])) { - $base = (strtolower(@$_SERVER['HTTPS']) == 'on') ? 'https://' : 'http://'; + $scheme = (strtolower(@$_SERVER['HTTPS']) == 'on') ? 'https://' : 'http://'; } else { - $base = 'http://'; + $scheme = 'http://'; } // add the sever name - $base .= $name; + $base = $scheme . $host; // check if userdir in the path and workaround PHP bug with PHP_SELF if (strpos($uri, '/~') !== false && strpos($_SERVER['PHP_SELF'], '/~') === false) { @@ -66,12 +67,13 @@ class Uri $address = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '::1'; // check for localhost variations - if ($name == 'localhost' || $address == '::1' || $address == '127.0.0.1') { + if ($host == 'localhost' || $address == '::1' || $address == '127.0.0.1') { $this->host = 'localhost'; } else { - $this->host = $name; + $this->host = $host; } + $this->scheme = $scheme; $this->port = $port; $this->base = $base; $this->uri = $uri; @@ -328,6 +330,16 @@ class Uri return $this->extension; } + /** + * Return the scheme of the URI + * + * @return String The scheme of the URI + */ + public function scheme() + { + return $this->scheme; + } + /** * Return the host of the URI * @@ -379,6 +391,7 @@ class Uri return $this->base; } + /** * Return root URL to the site. * From e801c8f44e02f6fcea9e5cb8e513b69982e08f45 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Tue, 19 Jan 2016 15:48:18 -0700 Subject: [PATCH 03/48] Added support for `absolute_urls: true` and page level ssl --- .../Common/Markdown/ParsedownGravTrait.php | 57 ++++++++++++++++++- 1 file changed, 54 insertions(+), 3 deletions(-) diff --git a/system/src/Grav/Common/Markdown/ParsedownGravTrait.php b/system/src/Grav/Common/Markdown/ParsedownGravTrait.php index 6617ab5a0..f65478573 100644 --- a/system/src/Grav/Common/Markdown/ParsedownGravTrait.php +++ b/system/src/Grav/Common/Markdown/ParsedownGravTrait.php @@ -320,12 +320,63 @@ trait ParsedownGravTrait unset ($url['query']); } + // set path to / if not set + if (empty($url['path'])) { + $url['path'] = '/'; + } + // if there is no scheme, the file is local and we'll need to convert that URL if (!isset($url['scheme']) && (count($url) > 0)) { - $excerpt['element']['attributes']['href'] = Uri::convertUrl($this->page, Uri::buildUrl($url), $type, true); - } else { - $excerpt['element']['attributes']['href'] = Uri::buildUrl($url); + $url['path'] = Uri::convertUrl($this->page, $url['path'], $type, true); } + + // if absolute urls enabled, add them + if (self::getGrav()['config']->get('system.absolute_urls', false)) { + $uri = self::getGrav()['uri']; + $url['scheme'] = str_replace('://', '', $uri->scheme()); + $url['host'] = $uri->host(); + + if ($uri->port() != 80 && $uri->port() != 443) { + $url['port'] = $uri->port(); + } + + // check if page exists for this route, and if so, check if it has SSL enabled + $pages = self::getGrav()['pages']; + $routes = $pages->routes(); + + // if this is an image, get the proper path + $url_bits = pathinfo($url['path']); + if (isset($url_bits['extension'])) { + $target_path = $url_bits['dirname']; + } else { + $target_path = $url['path']; + } + + // strip base from this path + $target_path = str_replace($uri->rootUrl(), '', $target_path); + + // set to / if root + if (empty($target_path)) { + $target_path = '/'; + } + + // look to see if this page exists and has ssl enabled + if (isset($routes[$target_path])) { + $target_page = $pages->get($routes[$target_path]); + if ($target_page) { + $ssl_enabled = $target_page->ssl(); + if (isset($ssl_enabled)) { + if ($ssl_enabled) { + $url['scheme'] = 'https'; + } else { + $url['scheme'] = 'http'; + } + } + } + } + } + + $excerpt['element']['attributes']['href'] = Uri::buildUrl($url); } return $excerpt; From af2e416ea1dcf2461cd699c7f946745b7ae92655 Mon Sep 17 00:00:00 2001 From: Tyler Cosgrove Date: Wed, 27 Jan 2016 13:25:42 -0500 Subject: [PATCH 04/48] Fix for #612 --- webserver-configs/web.config | 3 +++ 1 file changed, 3 insertions(+) diff --git a/webserver-configs/web.config b/webserver-configs/web.config index e09e94fb5..9ef3d88fd 100644 --- a/webserver-configs/web.config +++ b/webserver-configs/web.config @@ -52,4 +52,7 @@ + + + From 1494247c85afdb752d9fe3b571eee6d92ac13117 Mon Sep 17 00:00:00 2001 From: Flavio Copes Date: Fri, 29 Jan 2016 09:08:57 +0100 Subject: [PATCH 05/48] :white_check_mark: Tests code cleanup --- tests/unit/Grav/Common/AssetsTest.php | 378 +++++++--------- tests/unit/Grav/Common/BrowserTest.php | 14 +- tests/unit/Grav/Common/ComposerTest.php | 5 - tests/unit/Grav/Common/MarkdownTest.php | 4 - tests/unit/Grav/Common/UriTest.php | 553 +++++++++++------------- tests/unit/Grav/Common/UtilsTest.php | 17 +- 6 files changed, 422 insertions(+), 549 deletions(-) diff --git a/tests/unit/Grav/Common/AssetsTest.php b/tests/unit/Grav/Common/AssetsTest.php index 82f37ba22..a034a7518 100644 --- a/tests/unit/Grav/Common/AssetsTest.php +++ b/tests/unit/Grav/Common/AssetsTest.php @@ -7,41 +7,25 @@ use Codeception\Util\Fixtures; */ class AssetsTest extends \Codeception\TestCase\Test { - /** - * @var \UnitTester - */ - protected $tester; - protected function _before() { + $this->grav = Fixtures::get('grav'); + $this->assets = $this->grav['assets']; } protected function _after() { } - public function grav() - { - $grav = Fixtures::get('grav'); - return $grav; - } - - public function assets() - { - return $this->grav()['assets']; - } - public function testAddingAssets() { - $assets = $this->assets(); - //test add() - $assets->add('test.css'); + $this->assets->add('test.css'); - $css = $assets->css(); + $css = $this->assets->css(); $this->assertSame($css, '' . PHP_EOL); - $array = $assets->getCss(); + $array = $this->assets->getCss(); $this->assertSame(reset($array), [ 'asset' => '/test.css', 'priority' => 10, @@ -50,11 +34,11 @@ class AssetsTest extends \Codeception\TestCase\Test 'group' => 'head' ]); - $assets->add('test.js'); - $js = $assets->js(); + $this->assets->add('test.js'); + $js = $this->assets->js(); $this->assertSame($js, '' . PHP_EOL); - $array = $assets->getCss(); + $array = $this->assets->getCss(); $this->assertSame(reset($array), [ 'asset' => '/test.css', 'priority' => 10, @@ -64,12 +48,12 @@ class AssetsTest extends \Codeception\TestCase\Test ]); //test addCss(). Test adding asset to a separate group - $assets->reset(); - $assets->addCSS('test.css'); - $css = $assets->css(); + $this->assets->reset(); + $this->assets->addCSS('test.css'); + $css = $this->assets->css(); $this->assertSame($css, '' . PHP_EOL); - $array = $assets->getCss(); + $array = $this->assets->getCss(); $this->assertSame(reset($array), [ 'asset' => '/test.css', 'priority' => 10, @@ -79,12 +63,12 @@ class AssetsTest extends \Codeception\TestCase\Test ]); //test addJs() - $assets->reset(); - $assets->addJs('test.js'); - $js = $assets->js(); + $this->assets->reset(); + $this->assets->addJs('test.js'); + $js = $this->assets->js(); $this->assertSame($js, '' . PHP_EOL); - $array = $assets->getJs(); + $array = $this->assets->getJs(); $this->assertSame(reset($array), [ 'asset' => '/test.js', 'priority' => 10, @@ -95,14 +79,14 @@ class AssetsTest extends \Codeception\TestCase\Test ]); //Test CSS Groups - $assets->reset(); - $assets->addCSS('test.css', null, true, 'footer'); - $css = $assets->css(); + $this->assets->reset(); + $this->assets->addCSS('test.css', null, true, 'footer'); + $css = $this->assets->css(); $this->assertEmpty($css); - $css = $assets->css('footer'); + $css = $this->assets->css('footer'); $this->assertSame($css, '' . PHP_EOL); - $array = $assets->getCss(); + $array = $this->assets->getCss(); $this->assertSame(reset($array), [ 'asset' => '/test.css', 'priority' => 10, @@ -112,14 +96,14 @@ class AssetsTest extends \Codeception\TestCase\Test ]); //Test JS Groups - $assets->reset(); - $assets->addJs('test.js', null, true, null, 'footer'); - $js = $assets->js(); + $this->assets->reset(); + $this->assets->addJs('test.js', null, true, null, 'footer'); + $js = $this->assets->js(); $this->assertEmpty($js); - $js = $assets->js('footer'); + $js = $this->assets->js('footer'); $this->assertSame($js, '' . PHP_EOL); - $array = $assets->getJs(); + $array = $this->assets->getJs(); $this->assertSame(reset($array), [ 'asset' => '/test.js', 'priority' => 10, @@ -130,12 +114,12 @@ class AssetsTest extends \Codeception\TestCase\Test ]); //Test async / defer - $assets->reset(); - $assets->addJs('test.js', null, true, 'async', null); - $js = $assets->js(); + $this->assets->reset(); + $this->assets->addJs('test.js', null, true, 'async', null); + $js = $this->assets->js(); $this->assertSame($js, '' . PHP_EOL); - $array = $assets->getJs(); + $array = $this->assets->getJs(); $this->assertSame(reset($array), [ 'asset' => '/test.js', 'priority' => 10, @@ -145,12 +129,12 @@ class AssetsTest extends \Codeception\TestCase\Test 'group' => 'head' ]); - $assets->reset(); - $assets->addJs('test.js', null, true, 'defer', null); - $js = $assets->js(); + $this->assets->reset(); + $this->assets->addJs('test.js', null, true, 'defer', null); + $js = $this->assets->js(); $this->assertSame($js, '' . PHP_EOL); - $array = $assets->getJs(); + $array = $this->assets->getJs(); $this->assertSame(reset($array), [ 'asset' => '/test.js', 'priority' => 10, @@ -163,49 +147,45 @@ class AssetsTest extends \Codeception\TestCase\Test public function testAddingAssetPropertiesWithArray() { - $assets = $this->assets(); - //Test adding assets with object to define properties - $assets->reset(); - $assets->addJs('test.js', ['loading' => 'async']); - $js = $assets->js(); + $this->assets->reset(); + $this->assets->addJs('test.js', ['loading' => 'async']); + $js = $this->assets->js(); $this->assertSame($js, '' . PHP_EOL); - $assets->reset(); + $this->assets->reset(); } public function testAddingJSAssetPropertiesWithArrayFromCollection() { - $assets = $this->assets(); - //Test adding properties with array - $assets->reset(); - $assets->addJs('jquery', ['loading' => 'async']); - $js = $assets->js(); + $this->assets->reset(); + $this->assets->addJs('jquery', ['loading' => 'async']); + $js = $this->assets->js(); $this->assertSame($js, '' . PHP_EOL); //Test priority too - $assets->reset(); - $assets->addJs('jquery', ['loading' => 'async', 'priority' => 1]); - $assets->addJs('test.js', ['loading' => 'async', 'priority' => 2]); - $js = $assets->js(); + $this->assets->reset(); + $this->assets->addJs('jquery', ['loading' => 'async', 'priority' => 1]); + $this->assets->addJs('test.js', ['loading' => 'async', 'priority' => 2]); + $js = $this->assets->js(); $this->assertSame($js, '' . PHP_EOL . '' . PHP_EOL); //Test multiple groups - $assets->reset(); - $assets->addJs('jquery', ['loading' => 'async', 'priority' => 1, 'group' => 'footer']); - $assets->addJs('test.js', ['loading' => 'async', 'priority' => 2]); - $js = $assets->js(); + $this->assets->reset(); + $this->assets->addJs('jquery', ['loading' => 'async', 'priority' => 1, 'group' => 'footer']); + $this->assets->addJs('test.js', ['loading' => 'async', 'priority' => 2]); + $js = $this->assets->js(); $this->assertSame($js, '' . PHP_EOL); - $js = $assets->js('footer'); + $js = $this->assets->js('footer'); $this->assertSame($js, '' . PHP_EOL); //Test adding array of assets //Test priority too - $assets->reset(); - $assets->addJs(['jquery', 'test.js'], ['loading' => 'async']); - $js = $assets->js(); + $this->assets->reset(); + $this->assets->addJs(['jquery', 'test.js'], ['loading' => 'async']); + $js = $this->assets->js(); $this->assertSame($js, '' . PHP_EOL . '' . PHP_EOL); @@ -213,64 +193,60 @@ class AssetsTest extends \Codeception\TestCase\Test public function testAddingCSSAssetPropertiesWithArrayFromCollection() { - $assets = $this->assets(); - - $assets->registerCollection('test', ['/system/assets/whoops.css']); + $this->assets->registerCollection('test', ['/system/assets/whoops.css']); //Test priority too - $assets->reset(); - $assets->addCss('test', ['priority' => 1]); - $assets->addCss('test.css', ['priority' => 2]); - $css = $assets->css(); + $this->assets->reset(); + $this->assets->addCss('test', ['priority' => 1]); + $this->assets->addCss('test.css', ['priority' => 2]); + $css = $this->assets->css(); $this->assertSame($css, '' . PHP_EOL . '' . PHP_EOL); //Test multiple groups - $assets->reset(); - $assets->addCss('test', ['priority' => 1, 'group' => 'footer']); - $assets->addCss('test.css', ['priority' => 2]); - $css = $assets->css(); + $this->assets->reset(); + $this->assets->addCss('test', ['priority' => 1, 'group' => 'footer']); + $this->assets->addCss('test.css', ['priority' => 2]); + $css = $this->assets->css(); $this->assertSame($css, '' . PHP_EOL); - $css = $assets->css('footer'); + $css = $this->assets->css('footer'); $this->assertSame($css, '' . PHP_EOL); //Test adding array of assets //Test priority too - $assets->reset(); - $assets->addCss(['test', 'test.css'], ['loading' => 'async']); - $css = $assets->css(); + $this->assets->reset(); + $this->assets->addCss(['test', 'test.css'], ['loading' => 'async']); + $css = $this->assets->css(); $this->assertSame($css, '' . PHP_EOL . '' . PHP_EOL); } public function testPriorityOfAssets() { - $assets = $this->assets(); + $this->assets->reset(); + $this->assets->add('test.css'); + $this->assets->add('test-after.css'); - $assets->reset(); - $assets->add('test.css'); - $assets->add('test-after.css'); - - $css = $assets->css(); + $css = $this->assets->css(); $this->assertSame($css, '' . PHP_EOL . '' . PHP_EOL); //---------------- - $assets->reset(); - $assets->add('test-after.css', 1); - $assets->add('test.css', 2); + $this->assets->reset(); + $this->assets->add('test-after.css', 1); + $this->assets->add('test.css', 2); - $css = $assets->css(); + $css = $this->assets->css(); $this->assertSame($css, '' . PHP_EOL . '' . PHP_EOL); //---------------- - $assets->reset(); - $assets->add('test-after.css', 1); - $assets->add('test.css', 2); - $assets->add('test-before.css', 3); + $this->assets->reset(); + $this->assets->add('test-after.css', 1); + $this->assets->add('test.css', 2); + $this->assets->add('test-before.css', 3); - $css = $assets->css(); + $css = $this->assets->css(); $this->assertSame($css, '' . PHP_EOL . '' . PHP_EOL . '' . PHP_EOL); @@ -278,196 +254,172 @@ class AssetsTest extends \Codeception\TestCase\Test public function testPipeline() { - $assets = $this->assets(); - - $assets->reset(); + $this->assets->reset(); //File not existing. Pipeline searches for that file without reaching it. Output is empty. - $assets->add('test.css', null, true); - $assets->setCssPipeline(true); - $css = $assets->css(); + $this->assets->add('test.css', null, true); + $this->assets->setCssPipeline(true); + $css = $this->assets->css(); $this->assertSame($css, ''); //Add a core Grav CSS file, which is found. Pipeline will now return a file - $assets->add('/system/assets/debugger.css', null, true); - $css = $assets->css(); + $this->assets->add('/system/assets/debugger.css', null, true); + $css = $this->assets->css(); $this->assertContains('', $css); } public function testAddAsyncJs() { - $assets = $this->assets(); - - $assets->reset(); - $assets->addAsyncJs('jquery'); - $js = $assets->js(); + $this->assets->reset(); + $this->assets->addAsyncJs('jquery'); + $js = $this->assets->js(); $this->assertSame($js, '' . PHP_EOL); } public function testAddDeferJs() { - $assets = $this->assets(); - - $assets->reset(); - $assets->addDeferJs('jquery'); - $js = $assets->js(); + $this->assets->reset(); + $this->assets->addDeferJs('jquery'); + $js = $this->assets->js(); $this->assertSame($js, '' . PHP_EOL); } public function testAddInlineCss() { - $assets = $this->assets(); - - $assets->reset(); - $assets->addInlineCss('body { color: black }'); - $css = $assets->css(); + $this->assets->reset(); + $this->assets->addInlineCss('body { color: black }'); + $css = $this->assets->css(); $this->assertSame($css, PHP_EOL. '' . PHP_EOL); } public function testAddInlineJs() { - $assets = $this->assets(); - - $assets->reset(); - $assets->addInlineJs('alert("test")'); - $js = $assets->js(); + $this->assets->reset(); + $this->assets->addInlineJs('alert("test")'); + $js = $this->assets->js(); $this->assertSame($js, PHP_EOL . '' . PHP_EOL); } public function testGetCollections() { - $assets = $this->assets(); - - $this->assertTrue(is_array($assets->getCollections())); - $this->assertTrue(in_array('jquery', array_keys($assets->getCollections()))); - $this->assertTrue(in_array('system://assets/jquery/jquery-2.x.min.js', $assets->getCollections())); + $this->assertTrue(is_array($this->assets->getCollections())); + $this->assertTrue(in_array('jquery', array_keys($this->assets->getCollections()))); + $this->assertTrue(in_array('system://assets/jquery/jquery-2.x.min.js', $this->assets->getCollections())); } public function testExists() { - $assets = $this->assets(); - - $this->assertTrue($assets->exists('jquery')); - $this->assertFalse($assets->exists('another-unexisting-library')); + $this->assertTrue($this->assets->exists('jquery')); + $this->assertFalse($this->assets->exists('another-unexisting-library')); } public function testRegisterCollection() { - $assets = $this->assets(); - - $assets->registerCollection('debugger', ['/system/assets/debugger.css']); - $this->assertTrue($assets->exists('debugger')); - $this->assertTrue(in_array('debugger', array_keys($assets->getCollections()))); + $this->assets->registerCollection('debugger', ['/system/assets/debugger.css']); + $this->assertTrue($this->assets->exists('debugger')); + $this->assertTrue(in_array('debugger', array_keys($this->assets->getCollections()))); } public function testReset() { - $assets = $this->assets(); + $this->assets->addInlineJs('alert("test")'); + $this->assets->reset(); + $this->assertTrue(count($this->assets->js()) == 0); - $assets->addInlineJs('alert("test")'); - $assets->reset(); - $this->assertTrue(count($assets->js()) == 0); + $this->assets->addAsyncJs('jquery'); + $this->assets->reset(); - $assets->addAsyncJs('jquery'); - $assets->reset(); + $this->assertTrue(count($this->assets->js()) == 0); - $this->assertTrue(count($assets->js()) == 0); + $this->assets->addInlineCss('body { color: black }'); + $this->assets->reset(); - $assets->addInlineCss('body { color: black }'); - $assets->reset(); + $this->assertTrue(count($this->assets->css()) == 0); - $this->assertTrue(count($assets->css()) == 0); + $this->assets->add('/system/assets/debugger.css', null, true); + $this->assets->reset(); - $assets->add('/system/assets/debugger.css', null, true); - $assets->reset(); - - $this->assertTrue(count($assets->css()) == 0); + $this->assertTrue(count($this->assets->css()) == 0); } public function testResetJs() { - $assets = $this->assets(); + $this->assets->addInlineJs('alert("test")'); + $this->assets->resetJs(); + $this->assertTrue(count($this->assets->js()) == 0); - $assets->addInlineJs('alert("test")'); - $assets->resetJs(); - $this->assertTrue(count($assets->js()) == 0); + $this->assets->addAsyncJs('jquery'); + $this->assets->resetJs(); - $assets->addAsyncJs('jquery'); - $assets->resetJs(); - - $this->assertTrue(count($assets->js()) == 0); + $this->assertTrue(count($this->assets->js()) == 0); } public function testResetCss() { - $assets = $this->assets(); + $this->assertTrue(count($this->assets->js()) == 0); - $this->assertTrue(count($assets->js()) == 0); + $this->assets->addInlineCss('body { color: black }'); + $this->assets->resetCss(); - $assets->addInlineCss('body { color: black }'); - $assets->resetCss(); + $this->assertTrue(count($this->assets->css()) == 0); - $this->assertTrue(count($assets->css()) == 0); + $this->assets->add('/system/assets/debugger.css', null, true); + $this->assets->resetCss(); - $assets->add('/system/assets/debugger.css', null, true); - $assets->resetCss(); - - $this->assertTrue(count($assets->css()) == 0); + $this->assertTrue(count($this->assets->css()) == 0); } public function testAddDirCss() { - $assets = $this->assets(); - $assets->reset(); - $assets->addDirCss('/system'); + $this->assets->addDirCss('/system'); - $this->assertTrue(is_array($assets->getCss())); - $this->assertTrue(count($assets->getCss()) > 0); - $this->assertTrue(is_array($assets->getJs())); - $this->assertTrue(count($assets->getJs()) == 0); + $this->assertTrue(is_array($this->assets->getCss())); + $this->assertTrue(count($this->assets->getCss()) > 0); + $this->assertTrue(is_array($this->assets->getJs())); + $this->assertTrue(count($this->assets->getJs()) == 0); - $assets->reset(); - $assets->addDirCss('/system/assets'); + $this->assets->reset(); + $this->assets->addDirCss('/system/assets'); - $this->assertTrue(is_array($assets->getCss())); - $this->assertTrue(count($assets->getCss()) > 0); - $this->assertTrue(is_array($assets->getJs())); - $this->assertTrue(count($assets->getJs()) == 0); + $this->assertTrue(is_array($this->assets->getCss())); + $this->assertTrue(count($this->assets->getCss()) > 0); + $this->assertTrue(is_array($this->assets->getJs())); + $this->assertTrue(count($this->assets->getJs()) == 0); - $assets->reset(); - $assets->addDirJs('/system'); + $this->assets->reset(); + $this->assets->addDirJs('/system'); - $this->assertTrue(is_array($assets->getCss())); - $this->assertTrue(count($assets->getCss()) == 0); - $this->assertTrue(is_array($assets->getJs())); - $this->assertTrue(count($assets->getJs()) > 0); + $this->assertTrue(is_array($this->assets->getCss())); + $this->assertTrue(count($this->assets->getCss()) == 0); + $this->assertTrue(is_array($this->assets->getJs())); + $this->assertTrue(count($this->assets->getJs()) > 0); - $assets->reset(); - $assets->addDirJs('/system/assets'); + $this->assets->reset(); + $this->assets->addDirJs('/system/assets'); - $this->assertTrue(is_array($assets->getCss())); - $this->assertTrue(count($assets->getCss()) == 0); - $this->assertTrue(is_array($assets->getJs())); - $this->assertTrue(count($assets->getJs()) > 0); + $this->assertTrue(is_array($this->assets->getCss())); + $this->assertTrue(count($this->assets->getCss()) == 0); + $this->assertTrue(is_array($this->assets->getJs())); + $this->assertTrue(count($this->assets->getJs()) > 0); - $assets->reset(); - $assets->addDir('/system/assets'); + $this->assets->reset(); + $this->assets->addDir('/system/assets'); - $this->assertTrue(is_array($assets->getCss())); - $this->assertTrue(count($assets->getCss()) > 0); - $this->assertTrue(is_array($assets->getJs())); - $this->assertTrue(count($assets->getJs()) > 0); + $this->assertTrue(is_array($this->assets->getCss())); + $this->assertTrue(count($this->assets->getCss()) > 0); + $this->assertTrue(is_array($this->assets->getJs())); + $this->assertTrue(count($this->assets->getJs()) > 0); //Use streams - $assets->reset(); - $assets->addDir('system://assets'); + $this->assets->reset(); + $this->assets->addDir('system://assets'); - $this->assertTrue(is_array($assets->getCss())); - $this->assertTrue(count($assets->getCss()) > 0); - $this->assertTrue(is_array($assets->getJs())); - $this->assertTrue(count($assets->getJs()) > 0); + $this->assertTrue(is_array($this->assets->getCss())); + $this->assertTrue(count($this->assets->getCss()) > 0); + $this->assertTrue(is_array($this->assets->getJs())); + $this->assertTrue(count($this->assets->getJs()) > 0); } } diff --git a/tests/unit/Grav/Common/BrowserTest.php b/tests/unit/Grav/Common/BrowserTest.php index c91a31bb9..1825c93b1 100644 --- a/tests/unit/Grav/Common/BrowserTest.php +++ b/tests/unit/Grav/Common/BrowserTest.php @@ -4,24 +4,16 @@ use Codeception\Util\Fixtures; class BrowserTest extends \Codeception\TestCase\Test { - /** - * @var \UnitTester - */ - protected $tester; - protected function _before() { + $this->grav = Fixtures::get('grav'); + $this->assets = $this->grav['assets']; } protected function _after() { } - public function grav() - { - return Fixtures::get('grav'); - } - public function testGetBrowser() { /* Already covered by PhpUserAgent tests */ } public function testGetPlatform() { /* Already covered by PhpUserAgent tests */ } public function testGetLongVersion() { /* Already covered by PhpUserAgent tests */ } @@ -32,7 +24,7 @@ class BrowserTest extends \Codeception\TestCase\Test //Already Partially covered by PhpUserAgent tests //Make sure it recognizes the test as not human - $this->assertFalse($this->grav()['browser']->isHuman()); + $this->assertFalse($this->grav['browser']->isHuman()); } } diff --git a/tests/unit/Grav/Common/ComposerTest.php b/tests/unit/Grav/Common/ComposerTest.php index 4823c377c..da64b667f 100644 --- a/tests/unit/Grav/Common/ComposerTest.php +++ b/tests/unit/Grav/Common/ComposerTest.php @@ -5,11 +5,6 @@ use Grav\Common\Composer; class ComposerTest extends \Codeception\TestCase\Test { - /** - * @var \UnitTester - */ - protected $tester; - protected function _before() { } diff --git a/tests/unit/Grav/Common/MarkdownTest.php b/tests/unit/Grav/Common/MarkdownTest.php index 9b08c5169..d14d30cb1 100644 --- a/tests/unit/Grav/Common/MarkdownTest.php +++ b/tests/unit/Grav/Common/MarkdownTest.php @@ -7,10 +7,6 @@ use Codeception\Util\Fixtures; */ class MarkdownTest extends \Codeception\TestCase\Test { - /** - * @var \UnitTester - */ - protected $tester; protected $parsedown; protected function _before() diff --git a/tests/unit/Grav/Common/UriTest.php b/tests/unit/Grav/Common/UriTest.php index 94c2f6c88..ed75871e2 100644 --- a/tests/unit/Grav/Common/UriTest.php +++ b/tests/unit/Grav/Common/UriTest.php @@ -6,410 +6,361 @@ use Grav\Common\Utils; class UriTest extends \Codeception\TestCase\Test { - /** - * @var \UnitTester - */ - protected $tester; - protected function _before() { + $this->grav = Fixtures::get('grav'); + $this->uri = $this->grav['uri']; } protected function _after() { } - public function grav() - { - return Fixtures::get('grav'); - } - - public function getURI() - { - return $this->grav()['uri']; - } - public function testValidatingHostname() { - $uri = $this->getURI(); + $this->assertTrue($this->uri->validateHostname('localhost') == 1); + $this->assertTrue($this->uri->validateHostname('google.com') == 1); + $this->assertTrue($this->uri->validateHostname('google.it') == 1); + $this->assertTrue($this->uri->validateHostname('goog.le') == 1); + $this->assertTrue($this->uri->validateHostname('goog.wine') == 1); + $this->assertTrue($this->uri->validateHostname('goog.localhost') == 1); - $this->assertTrue($uri->validateHostname('localhost') == 1); - $this->assertTrue($uri->validateHostname('google.com') == 1); - $this->assertTrue($uri->validateHostname('google.it') == 1); - $this->assertTrue($uri->validateHostname('goog.le') == 1); - $this->assertTrue($uri->validateHostname('goog.wine') == 1); - $this->assertTrue($uri->validateHostname('goog.localhost') == 1); - - $this->assertFalse($uri->validateHostname('localhost:80') == 1); - $this->assertFalse($uri->validateHostname('http://localhost') == 1); - $this->assertFalse($uri->validateHostname('localhost!') == 1); + $this->assertFalse($this->uri->validateHostname('localhost:80') == 1); + $this->assertFalse($this->uri->validateHostname('http://localhost') == 1); + $this->assertFalse($this->uri->validateHostname('localhost!') == 1); } public function testInitializingUris() { - $uri = $this->getURI(); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper')->init(); + $this->assertTrue($this->uri->params() == null); + $this->assertTrue($this->uri->query() == ''); - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper')->init(); - $this->assertTrue($uri->params() == null); - $this->assertTrue($uri->query() == ''); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx')->init(); + $this->assertFalse($this->uri->params() == null); + $this->assertTrue($this->uri->query() == ''); - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx')->init(); - $this->assertFalse($uri->params() == null); - $this->assertTrue($uri->query() == ''); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x')->init(); - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x')->init(); + $this->assertTrue($this->uri->params() == null); + $this->assertTrue($this->uri->query() != ''); + $this->assertTrue($this->uri->query() == 'test=x'); + $this->assertTrue($this->uri->port() == '8080'); - $this->assertTrue($uri->params() == null); - $this->assertTrue($uri->query() != ''); - $this->assertTrue($uri->query() == 'test=x'); - $this->assertTrue($uri->port() == '8080'); + $this->uri->initializeWithURL('http://localhost:80/grav/it/ueper?test=x')->init(); + $this->assertTrue($this->uri->port() == '80'); - $uri->initializeWithURL('http://localhost:80/grav/it/ueper?test=x')->init(); - $this->assertTrue($uri->port() == '80'); + $this->uri->initializeWithURL('http://localhost/grav/it/ueper?test=x')->init(); + $this->assertTrue($this->uri->port() == '80'); - $uri->initializeWithURL('http://localhost/grav/it/ueper?test=x')->init(); - $this->assertTrue($uri->port() == '80'); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper')->init(); + $this->assertTrue($this->uri->params() == null); - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper')->init(); - $this->assertTrue($uri->params() == null); - - $uri->initializeWithURL('http://grav/grav/it/ueper')->init(); - $this->assertTrue($uri->params() == null); + $this->uri->initializeWithURL('http://grav/grav/it/ueper')->init(); + $this->assertTrue($this->uri->params() == null); } public function testPaths() { - $uri = $this->getURI(); - - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper')->init(); - $this->assertSame($uri->paths(), ['grav', 'it', 'ueper']); - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx')->init(); - $this->assertSame($uri->paths(), ['grav', 'it']); - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x')->init(); - $this->assertSame($uri->paths(), ['grav', 'it', 'ueper']); - $uri->initializeWithURL('http://localhost:8080/a/b/c/d')->init(); - $this->assertSame($uri->paths(), ['a', 'b', 'c', 'd']); - $uri->initializeWithURL('http://localhost:8080/a/b/c/d/e/f/a/b/c/d/e/f/a/b/c/d/e/f')->init(); - $this->assertSame($uri->paths(), ['a', 'b', 'c', 'd', 'e', 'f', 'a', 'b', 'c', 'd', 'e', 'f', 'a', 'b', 'c', 'd', 'e', 'f']); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper')->init(); + $this->assertSame($this->uri->paths(), ['grav', 'it', 'ueper']); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx')->init(); + $this->assertSame($this->uri->paths(), ['grav', 'it']); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x')->init(); + $this->assertSame($this->uri->paths(), ['grav', 'it', 'ueper']); + $this->uri->initializeWithURL('http://localhost:8080/a/b/c/d')->init(); + $this->assertSame($this->uri->paths(), ['a', 'b', 'c', 'd']); + $this->uri->initializeWithURL('http://localhost:8080/a/b/c/d/e/f/a/b/c/d/e/f/a/b/c/d/e/f')->init(); + $this->assertSame($this->uri->paths(), ['a', 'b', 'c', 'd', 'e', 'f', 'a', 'b', 'c', 'd', 'e', 'f', 'a', 'b', 'c', 'd', 'e', 'f']); } public function testRoute() { - $uri = $this->getURI(); - - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper')->init(); - $this->assertSame($uri->route(), '/grav/it/ueper'); - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx')->init(); - $this->assertSame($uri->route(), '/grav/it'); - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x')->init(); - $this->assertSame($uri->route(), '/grav/it/ueper'); - $uri->initializeWithURL('http://localhost:8080/a/b/c/d')->init(); - $this->assertSame($uri->route(), '/a/b/c/d'); - $uri->initializeWithURL('http://localhost:8080/a/b/c/d/e/f/a/b/c/d/e/f/a/b/c/d/e/f')->init(); - $this->assertSame($uri->route(), '/a/b/c/d/e/f/a/b/c/d/e/f/a/b/c/d/e/f'); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper')->init(); + $this->assertSame($this->uri->route(), '/grav/it/ueper'); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx')->init(); + $this->assertSame($this->uri->route(), '/grav/it'); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x')->init(); + $this->assertSame($this->uri->route(), '/grav/it/ueper'); + $this->uri->initializeWithURL('http://localhost:8080/a/b/c/d')->init(); + $this->assertSame($this->uri->route(), '/a/b/c/d'); + $this->uri->initializeWithURL('http://localhost:8080/a/b/c/d/e/f/a/b/c/d/e/f/a/b/c/d/e/f')->init(); + $this->assertSame($this->uri->route(), '/a/b/c/d/e/f/a/b/c/d/e/f/a/b/c/d/e/f'); } public function testQuery() { - $uri = $this->getURI(); - - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper')->init(); - $this->assertSame($uri->query(), ''); - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx')->init(); - $this->assertSame($uri->query(), ''); - $this->assertSame($uri->query('id'), null); - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x')->init(); - $this->assertSame($uri->query(), 'test=x'); - $this->assertSame($uri->query('id'), null); - $this->assertSame($uri->query('test'), 'x'); - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y')->init(); - $this->assertSame($uri->query(), 'test=x&test2=y'); - $this->assertSame($uri->query('id'), null); - $this->assertSame($uri->query('test'), 'x'); - $this->assertSame($uri->query('test2'), 'y'); - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y')->init(); - $this->assertSame($uri->query(), 'test=x&test2=y&test3=x&test4=y'); - $this->assertSame($uri->query('id'), null); - $this->assertSame($uri->query('test'), 'x'); - $this->assertSame($uri->query('test2'), 'y'); - $this->assertSame($uri->query('test4'), 'y'); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper')->init(); + $this->assertSame($this->uri->query(), ''); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx')->init(); + $this->assertSame($this->uri->query(), ''); + $this->assertSame($this->uri->query('id'), null); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x')->init(); + $this->assertSame($this->uri->query(), 'test=x'); + $this->assertSame($this->uri->query('id'), null); + $this->assertSame($this->uri->query('test'), 'x'); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y')->init(); + $this->assertSame($this->uri->query(), 'test=x&test2=y'); + $this->assertSame($this->uri->query('id'), null); + $this->assertSame($this->uri->query('test'), 'x'); + $this->assertSame($this->uri->query('test2'), 'y'); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y')->init(); + $this->assertSame($this->uri->query(), 'test=x&test2=y&test3=x&test4=y'); + $this->assertSame($this->uri->query('id'), null); + $this->assertSame($this->uri->query('test'), 'x'); + $this->assertSame($this->uri->query('test2'), 'y'); + $this->assertSame($this->uri->query('test4'), 'y'); //Test all after the ? is encoded in the query - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y/test')->init(); - $this->assertSame($uri->query(), 'test=x&test2=y&test3=x&test4=y%2Ftest'); - $this->assertSame($uri->query('id'), null); - $this->assertSame($uri->query('test'), 'x'); - $this->assertSame($uri->query('test2'), 'y'); - $this->assertSame($uri->query('test4'), 'y/test'); - $uri->initializeWithURL('http://localhost:8080/a/b/c/d')->init(); - $this->assertSame($uri->query(), ''); - $this->assertSame($uri->query('id'), null); - $uri->initializeWithURL('http://localhost:8080/a/b/c/d/e/f/a/b/c/d/e/f/a/b/c/d/e/f')->init(); - $this->assertSame($uri->query(), ''); - $this->assertSame($uri->query('id'), null); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y/test')->init(); + $this->assertSame($this->uri->query(), 'test=x&test2=y&test3=x&test4=y%2Ftest'); + $this->assertSame($this->uri->query('id'), null); + $this->assertSame($this->uri->query('test'), 'x'); + $this->assertSame($this->uri->query('test2'), 'y'); + $this->assertSame($this->uri->query('test4'), 'y/test'); + $this->uri->initializeWithURL('http://localhost:8080/a/b/c/d')->init(); + $this->assertSame($this->uri->query(), ''); + $this->assertSame($this->uri->query('id'), null); + $this->uri->initializeWithURL('http://localhost:8080/a/b/c/d/e/f/a/b/c/d/e/f/a/b/c/d/e/f')->init(); + $this->assertSame($this->uri->query(), ''); + $this->assertSame($this->uri->query('id'), null); } public function testParams() { - $uri = $this->getURI(); - - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper')->init(); - $this->assertSame($uri->params(), null); - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx')->init(); - $this->assertSame($uri->params(), '/ueper:xxx'); - $this->assertSame($uri->params('ueper'), '/ueper:xxx'); - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx/test:yyy')->init(); - $this->assertSame($uri->params(), '/ueper:xxx/test:yyy'); - $this->assertSame($uri->params('ueper'), '/ueper:xxx'); - $this->assertSame($uri->params('test'), '/test:yyy'); - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x')->init(); - $this->assertSame($uri->params(), null); - $this->assertSame($uri->params('ueper'), null); - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y')->init(); - $this->assertSame($uri->params(), null); - $this->assertSame($uri->params('ueper'), null); - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y')->init(); - $this->assertSame($uri->params(), null); - $this->assertSame($uri->params('ueper'), null); - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y/test')->init(); - $this->assertSame($uri->params(), null); - $this->assertSame($uri->params('ueper'), null); - $uri->initializeWithURL('http://localhost:8080/a/b/c/d')->init(); - $this->assertSame($uri->params(), null); - $this->assertSame($uri->params('ueper'), null); - $uri->initializeWithURL('http://localhost:8080/a/b/c/d/e/f/a/b/c/d/e/f/a/b/c/d/e/f')->init(); - $this->assertSame($uri->params(), null); - $this->assertSame($uri->params('ueper'), null); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper')->init(); + $this->assertSame($this->uri->params(), null); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx')->init(); + $this->assertSame($this->uri->params(), '/ueper:xxx'); + $this->assertSame($this->uri->params('ueper'), '/ueper:xxx'); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx/test:yyy')->init(); + $this->assertSame($this->uri->params(), '/ueper:xxx/test:yyy'); + $this->assertSame($this->uri->params('ueper'), '/ueper:xxx'); + $this->assertSame($this->uri->params('test'), '/test:yyy'); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x')->init(); + $this->assertSame($this->uri->params(), null); + $this->assertSame($this->uri->params('ueper'), null); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y')->init(); + $this->assertSame($this->uri->params(), null); + $this->assertSame($this->uri->params('ueper'), null); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y')->init(); + $this->assertSame($this->uri->params(), null); + $this->assertSame($this->uri->params('ueper'), null); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y/test')->init(); + $this->assertSame($this->uri->params(), null); + $this->assertSame($this->uri->params('ueper'), null); + $this->uri->initializeWithURL('http://localhost:8080/a/b/c/d')->init(); + $this->assertSame($this->uri->params(), null); + $this->assertSame($this->uri->params('ueper'), null); + $this->uri->initializeWithURL('http://localhost:8080/a/b/c/d/e/f/a/b/c/d/e/f/a/b/c/d/e/f')->init(); + $this->assertSame($this->uri->params(), null); + $this->assertSame($this->uri->params('ueper'), null); } public function testParam() { - $uri = $this->getURI(); - - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx')->init(); - $this->assertSame($uri->param('ueper'), 'xxx'); - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx/test:yyy')->init(); - $this->assertSame($uri->param('ueper'), 'xxx'); - $this->assertSame($uri->param('test'), 'yyy'); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx')->init(); + $this->assertSame($this->uri->param('ueper'), 'xxx'); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx/test:yyy')->init(); + $this->assertSame($this->uri->param('ueper'), 'xxx'); + $this->assertSame($this->uri->param('test'), 'yyy'); } public function testUrl() { - $uri = $this->getURI(); - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper')->init(); - $this->assertSame($uri->url(), '/grav/it/ueper'); - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx')->init(); - $this->assertSame($uri->url(), '/grav/it'); - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx/test:yyy')->init(); - $this->assertSame($uri->url(), '/grav/it'); - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x')->init(); - $this->assertSame($uri->url(), '/grav/it/ueper'); - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y')->init(); - $this->assertSame($uri->url(), '/grav/it/ueper'); - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y')->init(); - $this->assertSame($uri->url(), '/grav/it/ueper'); - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y/test')->init(); - $this->assertSame($uri->url(), '/grav/it/ueper'); - $uri->initializeWithURL('http://localhost:8080/a/b/c/d')->init(); - $this->assertSame($uri->url(), '/a/b/c/d'); - $uri->initializeWithURL('http://localhost:8080/a/b/c/d/e/f/a/b/c/d/e/f/a/b/c/d/e/f')->init(); - $this->assertSame($uri->url(), '/a/b/c/d/e/f/a/b/c/d/e/f/a/b/c/d/e/f'); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper')->init(); + $this->assertSame($this->uri->url(), '/grav/it/ueper'); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx')->init(); + $this->assertSame($this->uri->url(), '/grav/it'); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx/test:yyy')->init(); + $this->assertSame($this->uri->url(), '/grav/it'); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x')->init(); + $this->assertSame($this->uri->url(), '/grav/it/ueper'); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y')->init(); + $this->assertSame($this->uri->url(), '/grav/it/ueper'); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y')->init(); + $this->assertSame($this->uri->url(), '/grav/it/ueper'); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y/test')->init(); + $this->assertSame($this->uri->url(), '/grav/it/ueper'); + $this->uri->initializeWithURL('http://localhost:8080/a/b/c/d')->init(); + $this->assertSame($this->uri->url(), '/a/b/c/d'); + $this->uri->initializeWithURL('http://localhost:8080/a/b/c/d/e/f/a/b/c/d/e/f/a/b/c/d/e/f')->init(); + $this->assertSame($this->uri->url(), '/a/b/c/d/e/f/a/b/c/d/e/f/a/b/c/d/e/f'); } public function testPath() { - $uri = $this->getURI(); - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper')->init(); - $this->assertSame($uri->path(), '/grav/it/ueper'); - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx')->init(); - $this->assertSame($uri->path(), '/grav/it'); - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx/test:yyy')->init(); - $this->assertSame($uri->path(), '/grav/it'); - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x')->init(); - $this->assertSame($uri->path(), '/grav/it/ueper'); - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y')->init(); - $this->assertSame($uri->path(), '/grav/it/ueper'); - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y')->init(); - $this->assertSame($uri->path(), '/grav/it/ueper'); - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y/test')->init(); - $this->assertSame($uri->path(), '/grav/it/ueper'); - $uri->initializeWithURL('http://localhost:8080/a/b/c/d')->init(); - $this->assertSame($uri->path(), '/a/b/c/d'); - $uri->initializeWithURL('http://localhost:8080/a/b/c/d/e/f/a/b/c/d/e/f/a/b/c/d/e/f')->init(); - $this->assertSame($uri->path(), '/a/b/c/d/e/f/a/b/c/d/e/f/a/b/c/d/e/f'); - $uri->initializeWithURL('http://localhost/')->init(); - $this->assertSame($uri->path(), '/'); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper')->init(); + $this->assertSame($this->uri->path(), '/grav/it/ueper'); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx')->init(); + $this->assertSame($this->uri->path(), '/grav/it'); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx/test:yyy')->init(); + $this->assertSame($this->uri->path(), '/grav/it'); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x')->init(); + $this->assertSame($this->uri->path(), '/grav/it/ueper'); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y')->init(); + $this->assertSame($this->uri->path(), '/grav/it/ueper'); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y')->init(); + $this->assertSame($this->uri->path(), '/grav/it/ueper'); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y/test')->init(); + $this->assertSame($this->uri->path(), '/grav/it/ueper'); + $this->uri->initializeWithURL('http://localhost:8080/a/b/c/d')->init(); + $this->assertSame($this->uri->path(), '/a/b/c/d'); + $this->uri->initializeWithURL('http://localhost:8080/a/b/c/d/e/f/a/b/c/d/e/f/a/b/c/d/e/f')->init(); + $this->assertSame($this->uri->path(), '/a/b/c/d/e/f/a/b/c/d/e/f/a/b/c/d/e/f'); + $this->uri->initializeWithURL('http://localhost/')->init(); + $this->assertSame($this->uri->path(), '/'); } public function testExtension() { - $uri = $this->getURI(); - $uri->initializeWithURL('http://localhost/a-page')->init(); - $this->assertSame($uri->extension(), null); - $uri->initializeWithURL('http://localhost/a-page')->init(); - $this->assertSame($uri->extension('x'), 'x'); - $uri->initializeWithURL('http://localhost/a-page.html')->init(); - $this->assertSame($uri->extension(), 'html'); - $uri->initializeWithURL('http://localhost/a-page.xml')->init(); - $this->assertSame($uri->extension(), 'xml'); - $uri->initializeWithURL('http://localhost/a-page.foo')->init(); - $this->assertSame($uri->extension(), 'foo'); + $this->uri->initializeWithURL('http://localhost/a-page')->init(); + $this->assertSame($this->uri->extension(), null); + $this->uri->initializeWithURL('http://localhost/a-page')->init(); + $this->assertSame($this->uri->extension('x'), 'x'); + $this->uri->initializeWithURL('http://localhost/a-page.html')->init(); + $this->assertSame($this->uri->extension(), 'html'); + $this->uri->initializeWithURL('http://localhost/a-page.xml')->init(); + $this->assertSame($this->uri->extension(), 'xml'); + $this->uri->initializeWithURL('http://localhost/a-page.foo')->init(); + $this->assertSame($this->uri->extension(), 'foo'); } public function testHost() { - $uri = $this->getURI(); - $address = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '::1'; - if ($uri->host() == 'localhost' || $address == '::1' || $address == '127.0.0.1') { + if ($this->uri->host() == 'localhost' || $address == '::1' || $address == '127.0.0.1') { $address = 'localhost'; } - $uri->initializeWithURL('http://localhost/a-page')->init(); - $this->assertSame($uri->host(), $address); - $uri->initializeWithURL('http://localhost/')->init(); - $this->assertSame($uri->host(), $address); + $this->uri->initializeWithURL('http://localhost/a-page')->init(); + $this->assertSame($this->uri->host(), $address); + $this->uri->initializeWithURL('http://localhost/')->init(); + $this->assertSame($this->uri->host(), $address); //Host is set to localhost when running from local - $uri->initializeWithURL('http://google.com/')->init(); - $this->assertSame($uri->host(), $address); + $this->uri->initializeWithURL('http://google.com/')->init(); + $this->assertSame($this->uri->host(), $address); } public function testPort() { - $uri = $this->getURI(); - $uri->initializeWithURL('http://localhost/a-page')->init(); - $this->assertSame($uri->port(), '80'); - $uri->initializeWithURL('http://localhost:8080/a-page')->init(); - $this->assertSame($uri->port(), 8080); - $uri->initializeWithURL('http://localhost:443/a-page')->init(); - $this->assertSame($uri->port(), 443); - $uri->initializeWithURL('https://localhost/a-page')->init(); - $this->assertSame($uri->port(), '80'); + $this->uri->initializeWithURL('http://localhost/a-page')->init(); + $this->assertSame($this->uri->port(), '80'); + $this->uri->initializeWithURL('http://localhost:8080/a-page')->init(); + $this->assertSame($this->uri->port(), 8080); + $this->uri->initializeWithURL('http://localhost:443/a-page')->init(); + $this->assertSame($this->uri->port(), 443); + $this->uri->initializeWithURL('https://localhost/a-page')->init(); + $this->assertSame($this->uri->port(), '80'); } public function testEnvironment() { - $uri = $this->getURI(); - $address = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '::1'; - if ($uri->host() == 'localhost' || $address == '::1' || $address == '127.0.0.1') { + if ($this->uri->host() == 'localhost' || $address == '::1' || $address == '127.0.0.1') { $address = 'localhost'; } - $uri->initializeWithURL('http://localhost/a-page')->init(); - $this->assertSame($uri->environment(), $address); - $uri->initializeWithURL('http://localhost:8080/a-page')->init(); - $this->assertSame($uri->environment(), $address); - $uri->initializeWithURL('http://foobar.it:443/a-page')->init(); - $this->assertSame($uri->environment(), $address); - $uri->initializeWithURL('https://google.com/a-page')->init(); - $this->assertSame($uri->environment(), $address); + $this->uri->initializeWithURL('http://localhost/a-page')->init(); + $this->assertSame($this->uri->environment(), $address); + $this->uri->initializeWithURL('http://localhost:8080/a-page')->init(); + $this->assertSame($this->uri->environment(), $address); + $this->uri->initializeWithURL('http://foobar.it:443/a-page')->init(); + $this->assertSame($this->uri->environment(), $address); + $this->uri->initializeWithURL('https://google.com/a-page')->init(); + $this->assertSame($this->uri->environment(), $address); } public function testBasename() { - $uri = $this->getURI(); - - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper')->init(); - $this->assertSame($uri->basename(), 'ueper'); - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx')->init(); - $this->assertSame($uri->basename(), 'it'); - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx/test:yyy')->init(); - $this->assertSame($uri->basename(), 'it'); - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x')->init(); - $this->assertSame($uri->basename(), 'ueper'); - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y')->init(); - $this->assertSame($uri->basename(), 'ueper'); - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y')->init(); - $this->assertSame($uri->basename(), 'ueper'); - $uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y/test')->init(); - $this->assertSame($uri->basename(), 'ueper'); - $uri->initializeWithURL('http://localhost:8080/a/b/c/d')->init(); - $this->assertSame($uri->basename(), 'd'); - $uri->initializeWithURL('http://localhost:8080/a/b/c/d/e/f/a/b/c/d/e/f/a/b/c/d/e/f')->init(); - $this->assertSame($uri->basename(), 'f'); - $uri->initializeWithURL('http://localhost/')->init(); - $this->assertSame($uri->basename(), ''); - $uri->initializeWithURL('http://localhost/test.xml')->init(); - $this->assertSame($uri->basename(), 'test.xml'); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper')->init(); + $this->assertSame($this->uri->basename(), 'ueper'); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx')->init(); + $this->assertSame($this->uri->basename(), 'it'); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx/test:yyy')->init(); + $this->assertSame($this->uri->basename(), 'it'); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x')->init(); + $this->assertSame($this->uri->basename(), 'ueper'); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y')->init(); + $this->assertSame($this->uri->basename(), 'ueper'); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y')->init(); + $this->assertSame($this->uri->basename(), 'ueper'); + $this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y/test')->init(); + $this->assertSame($this->uri->basename(), 'ueper'); + $this->uri->initializeWithURL('http://localhost:8080/a/b/c/d')->init(); + $this->assertSame($this->uri->basename(), 'd'); + $this->uri->initializeWithURL('http://localhost:8080/a/b/c/d/e/f/a/b/c/d/e/f/a/b/c/d/e/f')->init(); + $this->assertSame($this->uri->basename(), 'f'); + $this->uri->initializeWithURL('http://localhost/')->init(); + $this->assertSame($this->uri->basename(), ''); + $this->uri->initializeWithURL('http://localhost/test.xml')->init(); + $this->assertSame($this->uri->basename(), 'test.xml'); } public function testBase() { - $uri = $this->getURI(); - - $uri->initializeWithURL('http://localhost/a-page')->init(); - $this->assertSame($uri->base(), 'http://localhost'); - $uri->initializeWithURL('http://localhost:8080/a-page')->init(); - $this->assertSame($uri->base(), 'http://localhost:8080'); - $uri->initializeWithURL('http://foobar.it:80/a-page')->init(); - $this->assertSame($uri->base(), 'http://foobar.it'); - $uri->initializeWithURL('https://google.com/a-page')->init(); - $this->assertSame($uri->base(), 'http://google.com'); + $this->uri->initializeWithURL('http://localhost/a-page')->init(); + $this->assertSame($this->uri->base(), 'http://localhost'); + $this->uri->initializeWithURL('http://localhost:8080/a-page')->init(); + $this->assertSame($this->uri->base(), 'http://localhost:8080'); + $this->uri->initializeWithURL('http://foobar.it:80/a-page')->init(); + $this->assertSame($this->uri->base(), 'http://foobar.it'); + $this->uri->initializeWithURL('https://google.com/a-page')->init(); + $this->assertSame($this->uri->base(), 'http://google.com'); } public function testRootUrl() { - $uri = $this->getURI(); - //Without explicitly adding the root path via `initializeWithUrlAndRootPath`, //tests always default to the base empty root path - $uri->initializeWithURL('http://localhost/a-page')->init(); - $this->assertSame($uri->rootUrl(true), 'http://localhost'); - $uri->initializeWithURL('http://localhost:8080/a-page')->init(); - $this->assertSame($uri->rootUrl(true), 'http://localhost:8080'); - $uri->initializeWithURL('http://foobar.it:80/a-page')->init(); - $this->assertSame($uri->rootUrl(true), 'http://foobar.it'); - $uri->initializeWithURL('https://google.com/a-page/xxx')->init(); - $this->assertSame($uri->rootUrl(true), 'http://google.com'); + $this->uri->initializeWithURL('http://localhost/a-page')->init(); + $this->assertSame($this->uri->rootUrl(true), 'http://localhost'); + $this->uri->initializeWithURL('http://localhost:8080/a-page')->init(); + $this->assertSame($this->uri->rootUrl(true), 'http://localhost:8080'); + $this->uri->initializeWithURL('http://foobar.it:80/a-page')->init(); + $this->assertSame($this->uri->rootUrl(true), 'http://foobar.it'); + $this->uri->initializeWithURL('https://google.com/a-page/xxx')->init(); + $this->assertSame($this->uri->rootUrl(true), 'http://google.com'); - $uri->initializeWithUrlAndRootPath('https://localhost/grav/page-foo', '/grav')->init(); - $this->assertSame($uri->rootUrl(), '/grav'); - $this->assertSame($uri->rootUrl(true), 'http://localhost/grav'); + $this->uri->initializeWithUrlAndRootPath('https://localhost/grav/page-foo', '/grav')->init(); + $this->assertSame($this->uri->rootUrl(), '/grav'); + $this->assertSame($this->uri->rootUrl(true), 'http://localhost/grav'); } public function testCurrentPage() { - $uri = $this->getURI(); - - $uri->initializeWithURL('http://localhost/foo/page:test')->init(); - $this->assertSame($uri->currentPage(), 'test'); - $uri->initializeWithURL('http://localhost:8080/a-page')->init(); - $this->assertSame($uri->currentPage(), 1); - $uri->initializeWithURL('http://localhost:8080/a-page/page:2')->init(); - $this->assertSame($uri->currentPage(), '2'); - $uri->initializeWithURL('http://localhost:8080/a-page/page:x')->init(); - $this->assertSame($uri->currentPage(), 'x'); - $uri->initializeWithURL('http://localhost:8080/a-page/page:')->init(); - $this->assertSame($uri->currentPage(), ''); + $this->uri->initializeWithURL('http://localhost/foo/page:test')->init(); + $this->assertSame($this->uri->currentPage(), 'test'); + $this->uri->initializeWithURL('http://localhost:8080/a-page')->init(); + $this->assertSame($this->uri->currentPage(), 1); + $this->uri->initializeWithURL('http://localhost:8080/a-page/page:2')->init(); + $this->assertSame($this->uri->currentPage(), '2'); + $this->uri->initializeWithURL('http://localhost:8080/a-page/page:x')->init(); + $this->assertSame($this->uri->currentPage(), 'x'); + $this->uri->initializeWithURL('http://localhost:8080/a-page/page:')->init(); + $this->assertSame($this->uri->currentPage(), ''); } public function testReferrer() { - $uri = $this->getURI(); - - $uri->initializeWithURL('http://localhost/foo/page:test')->init(); - $this->assertSame($uri->referrer(), '/foo'); - $uri->initializeWithURL('http://localhost/foo/bar/page:test')->init(); - $this->assertSame($uri->referrer(), '/foo/bar'); + $this->uri->initializeWithURL('http://localhost/foo/page:test')->init(); + $this->assertSame($this->uri->referrer(), '/foo'); + $this->uri->initializeWithURL('http://localhost/foo/bar/page:test')->init(); + $this->assertSame($this->uri->referrer(), '/foo/bar'); } public function testIp() { - $uri = $this->getURI(); - - $uri->initializeWithURL('http://localhost/foo/page:test')->init(); - $this->assertSame($uri->ip(), 'UNKNOWN'); + $this->uri->initializeWithURL('http://localhost/foo/page:test')->init(); + $this->assertSame($this->uri->ip(), 'UNKNOWN'); } public function testIsExternal() { - $uri = $this->getURI(); - - $uri->initializeWithURL('http://localhost/')->init(); - $this->assertFalse($uri->isExternal('/test')); - $this->assertFalse($uri->isExternal('/foo/bar')); - $this->assertTrue($uri->isExternal('http://localhost/test')); - $this->assertTrue($uri->isExternal('http://google.it/test')); + $this->uri->initializeWithURL('http://localhost/')->init(); + $this->assertFalse($this->uri->isExternal('/test')); + $this->assertFalse($this->uri->isExternal('/foo/bar')); + $this->assertTrue($this->uri->isExternal('http://localhost/test')); + $this->assertTrue($this->uri->isExternal('http://google.it/test')); } public function testBuildUrl() @@ -447,11 +398,9 @@ class UriTest extends \Codeception\TestCase\Test $this->assertStringStartsWith($url, Uri::addNonce($url, 'test-action')); $this->assertStringStartsWith($url . '/nonce:', Uri::addNonce($url, 'test-action')); - $uri = $this->getURI(); - - $uri->initializeWithURL(Uri::addNonce($url, 'test-action'))->init(); - $this->assertTrue(is_string($uri->param('nonce'))); - $this->assertSame($uri->param('nonce'), Utils::getNonce('test-action')); + $this->uri->initializeWithURL(Uri::addNonce($url, 'test-action'))->init(); + $this->assertTrue(is_string($this->uri->param('nonce'))); + $this->assertSame($this->uri->param('nonce'), Utils::getNonce('test-action')); } } diff --git a/tests/unit/Grav/Common/UtilsTest.php b/tests/unit/Grav/Common/UtilsTest.php index 6db1e6b0d..57786e952 100644 --- a/tests/unit/Grav/Common/UtilsTest.php +++ b/tests/unit/Grav/Common/UtilsTest.php @@ -5,25 +5,15 @@ use Grav\Common\Utils; class UtilsTest extends \Codeception\TestCase\Test { - /** - * @var \UnitTester - */ - protected $tester; - protected function _before() { + $this->grav = Fixtures::get('grav'); } protected function _after() { } - public function grav() - { - $grav = Fixtures::get('grav'); - return $grav; - } - public function testStartsWith() { $this->assertTrue(Utils::startsWith('english', 'en')); @@ -84,12 +74,11 @@ class UtilsTest extends \Codeception\TestCase\Test public function testDateFormats() { - $grav = $this->grav(); $dateFormats = Utils::dateFormats(); $this->assertTrue(is_array($dateFormats)); $this->assertContainsOnly('string', $dateFormats); - $default_format = $grav['config']->get('system.pages.dateformat.default'); + $default_format = $this->grav['config']->get('system.pages.dateformat.default'); if ($default_format !== null) { $this->assertTrue(isset($dateFormats[$default_format])); @@ -193,7 +182,7 @@ class UtilsTest extends \Codeception\TestCase\Test public function testPathPrefixedByLangCode() { - $languagesEnabled = $this->grav()['config']->get('system.languages.supported', []); + $languagesEnabled = $this->grav['config']->get('system.languages.supported', []); $arrayOfLanguages = ['en', 'de', 'it', 'es', 'dk', 'el']; $languagesNotEnabled = array_diff($arrayOfLanguages, $languagesEnabled); $oneLanguageNotEnabled = reset($languagesNotEnabled); From c307f63e1ff5508f7d0e5eca9644544c2a5ef5ea Mon Sep 17 00:00:00 2001 From: Flavio Copes Date: Fri, 29 Jan 2016 09:54:14 +0100 Subject: [PATCH 06/48] :white_check_mark: Cleanup tests --- tests/unit/Grav/Common/AssetsTest.php | 82 +++++++++++++++---------- tests/unit/Grav/Common/BrowserTest.php | 27 ++++++-- tests/unit/Grav/Common/MarkdownTest.php | 48 +++++++++------ tests/unit/Grav/Common/UriTest.php | 31 +++++++--- tests/unit/Grav/Common/UtilsTest.php | 36 +++++++---- 5 files changed, 146 insertions(+), 78 deletions(-) diff --git a/tests/unit/Grav/Common/AssetsTest.php b/tests/unit/Grav/Common/AssetsTest.php index a034a7518..353835f2b 100644 --- a/tests/unit/Grav/Common/AssetsTest.php +++ b/tests/unit/Grav/Common/AssetsTest.php @@ -1,12 +1,20 @@ grav = Fixtures::get('grav'); @@ -27,11 +35,11 @@ class AssetsTest extends \Codeception\TestCase\Test $array = $this->assets->getCss(); $this->assertSame(reset($array), [ - 'asset' => '/test.css', + 'asset' => '/test.css', 'priority' => 10, - 'order' => 0, + 'order' => 0, 'pipeline' => true, - 'group' => 'head' + 'group' => 'head' ]); $this->assets->add('test.js'); @@ -40,11 +48,11 @@ class AssetsTest extends \Codeception\TestCase\Test $array = $this->assets->getCss(); $this->assertSame(reset($array), [ - 'asset' => '/test.css', + 'asset' => '/test.css', 'priority' => 10, - 'order' => 0, + 'order' => 0, 'pipeline' => true, - 'group' => 'head' + 'group' => 'head' ]); //test addCss(). Test adding asset to a separate group @@ -55,11 +63,11 @@ class AssetsTest extends \Codeception\TestCase\Test $array = $this->assets->getCss(); $this->assertSame(reset($array), [ - 'asset' => '/test.css', + 'asset' => '/test.css', 'priority' => 10, - 'order' => 0, + 'order' => 0, 'pipeline' => true, - 'group' => 'head' + 'group' => 'head' ]); //test addJs() @@ -70,12 +78,12 @@ class AssetsTest extends \Codeception\TestCase\Test $array = $this->assets->getJs(); $this->assertSame(reset($array), [ - 'asset' => '/test.js', + 'asset' => '/test.js', 'priority' => 10, - 'order' => 0, + 'order' => 0, 'pipeline' => true, - 'loading' => '', - 'group' => 'head' + 'loading' => '', + 'group' => 'head' ]); //Test CSS Groups @@ -88,11 +96,11 @@ class AssetsTest extends \Codeception\TestCase\Test $array = $this->assets->getCss(); $this->assertSame(reset($array), [ - 'asset' => '/test.css', + 'asset' => '/test.css', 'priority' => 10, - 'order' => 0, + 'order' => 0, 'pipeline' => true, - 'group' => 'footer' + 'group' => 'footer' ]); //Test JS Groups @@ -105,12 +113,12 @@ class AssetsTest extends \Codeception\TestCase\Test $array = $this->assets->getJs(); $this->assertSame(reset($array), [ - 'asset' => '/test.js', + 'asset' => '/test.js', 'priority' => 10, - 'order' => 0, + 'order' => 0, 'pipeline' => true, - 'loading' => '', - 'group' => 'footer' + 'loading' => '', + 'group' => 'footer' ]); //Test async / defer @@ -121,12 +129,12 @@ class AssetsTest extends \Codeception\TestCase\Test $array = $this->assets->getJs(); $this->assertSame(reset($array), [ - 'asset' => '/test.js', + 'asset' => '/test.js', 'priority' => 10, - 'order' => 0, + 'order' => 0, 'pipeline' => true, - 'loading' => 'async', - 'group' => 'head' + 'loading' => 'async', + 'group' => 'head' ]); $this->assets->reset(); @@ -136,12 +144,12 @@ class AssetsTest extends \Codeception\TestCase\Test $array = $this->assets->getJs(); $this->assertSame(reset($array), [ - 'asset' => '/test.js', + 'asset' => '/test.js', 'priority' => 10, - 'order' => 0, + 'order' => 0, 'pipeline' => true, - 'loading' => 'defer', - 'group' => 'head' + 'loading' => 'defer', + 'group' => 'head' ]); } @@ -162,7 +170,8 @@ class AssetsTest extends \Codeception\TestCase\Test $this->assets->reset(); $this->assets->addJs('jquery', ['loading' => 'async']); $js = $this->assets->js(); - $this->assertSame($js, '' . PHP_EOL); + $this->assertSame($js, + '' . PHP_EOL); //Test priority too $this->assets->reset(); @@ -179,7 +188,8 @@ class AssetsTest extends \Codeception\TestCase\Test $js = $this->assets->js(); $this->assertSame($js, '' . PHP_EOL); $js = $this->assets->js('footer'); - $this->assertSame($js, '' . PHP_EOL); + $this->assertSame($js, + '' . PHP_EOL); //Test adding array of assets //Test priority too @@ -187,7 +197,8 @@ class AssetsTest extends \Codeception\TestCase\Test $this->assets->addJs(['jquery', 'test.js'], ['loading' => 'async']); $js = $this->assets->js(); - $this->assertSame($js, '' . PHP_EOL . + $this->assertSame($js, + '' . PHP_EOL . '' . PHP_EOL); } @@ -274,7 +285,8 @@ class AssetsTest extends \Codeception\TestCase\Test $this->assets->reset(); $this->assets->addAsyncJs('jquery'); $js = $this->assets->js(); - $this->assertSame($js, '' . PHP_EOL); + $this->assertSame($js, + '' . PHP_EOL); } public function testAddDeferJs() @@ -282,7 +294,8 @@ class AssetsTest extends \Codeception\TestCase\Test $this->assets->reset(); $this->assets->addDeferJs('jquery'); $js = $this->assets->js(); - $this->assertSame($js, '' . PHP_EOL); + $this->assertSame($js, + '' . PHP_EOL); } public function testAddInlineCss() @@ -290,7 +303,8 @@ class AssetsTest extends \Codeception\TestCase\Test $this->assets->reset(); $this->assets->addInlineCss('body { color: black }'); $css = $this->assets->css(); - $this->assertSame($css, PHP_EOL. '' . PHP_EOL); + $this->assertSame($css, + PHP_EOL . '' . PHP_EOL); } public function testAddInlineJs() diff --git a/tests/unit/Grav/Common/BrowserTest.php b/tests/unit/Grav/Common/BrowserTest.php index 1825c93b1..e5aca9923 100644 --- a/tests/unit/Grav/Common/BrowserTest.php +++ b/tests/unit/Grav/Common/BrowserTest.php @@ -1,23 +1,40 @@ grav = Fixtures::get('grav'); - $this->assets = $this->grav['assets']; } protected function _after() { } - public function testGetBrowser() { /* Already covered by PhpUserAgent tests */ } - public function testGetPlatform() { /* Already covered by PhpUserAgent tests */ } - public function testGetLongVersion() { /* Already covered by PhpUserAgent tests */ } - public function testGetVersion() { /* Already covered by PhpUserAgent tests */ } + public function testGetBrowser() + { /* Already covered by PhpUserAgent tests */ + } + + public function testGetPlatform() + { /* Already covered by PhpUserAgent tests */ + } + + public function testGetLongVersion() + { /* Already covered by PhpUserAgent tests */ + } + + public function testGetVersion() + { /* Already covered by PhpUserAgent tests */ + } public function testIsHuman() { diff --git a/tests/unit/Grav/Common/MarkdownTest.php b/tests/unit/Grav/Common/MarkdownTest.php index d14d30cb1..ba8890aa6 100644 --- a/tests/unit/Grav/Common/MarkdownTest.php +++ b/tests/unit/Grav/Common/MarkdownTest.php @@ -1,22 +1,29 @@ grav = Fixtures::get('grav'); + $defaults = [ - 'extra' => false, + 'extra' => false, 'auto_line_breaks' => false, - 'auto_url_links' => false, - 'escape_markup' => false, - 'special_chars' => ['>' => 'gt', '<' => 'lt'], + 'auto_url_links' => false, + 'escape_markup' => false, + 'special_chars' => ['>' => 'gt', '<' => 'lt'], ]; $page = new \Grav\Common\Page\Page(); @@ -27,24 +34,26 @@ class MarkdownTest extends \Codeception\TestCase\Test { } - public function grav() - { - $grav = Fixtures::get('grav'); - return $grav; - } - + /** + * @param $string + * + * @return mixed + */ public function stripLeadingWhitespace($string) { return preg_replace('/^\s*(.*)/', '', $string); } - public function testMarkdownSpecialProtocols() { - $this->assertSame($this->parsedown->text('[mailto](mailto:user@domain.com)'), '

mailto

'); - $this->assertSame($this->parsedown->text('[xmpp](xmpp:xyx@domain.com)'), '

xmpp

'); - $this->assertSame($this->parsedown->text('[tel](tel:123-555-12345)'), '

tel

'); - $this->assertSame($this->parsedown->text('[sms](sms:123-555-12345)'), '

sms

'); + $this->assertSame($this->parsedown->text('[mailto](mailto:user@domain.com)'), + '

mailto

'); + $this->assertSame($this->parsedown->text('[xmpp](xmpp:xyx@domain.com)'), + '

xmpp

'); + $this->assertSame($this->parsedown->text('[tel](tel:123-555-12345)'), + '

tel

'); + $this->assertSame($this->parsedown->text('[sms](sms:123-555-12345)'), + '

sms

'); } public function testMarkdownReferenceLinks() @@ -55,7 +64,8 @@ class MarkdownTest extends \Codeception\TestCase\Test $sample = '[absolute link][r_absolute] [r_absolute]: /blog/focus-and-blur#blah'; - $this->assertSame($this->parsedown->text($sample), '

absolute link

'); + $this->assertSame($this->parsedown->text($sample), + '

absolute link

'); $sample = '[external link][r_external] [r_external]: http://www.cnn.com'; @@ -64,7 +74,9 @@ class MarkdownTest extends \Codeception\TestCase\Test public function testMarkdownExternalLinks() { - $this->assertSame($this->parsedown->text('[cnn.com](http://www.cnn.com)'), '

cnn.com

'); - $this->assertSame($this->parsedown->text('[google.com](https://www.google.com)'), '

google.com

'); + $this->assertSame($this->parsedown->text('[cnn.com](http://www.cnn.com)'), + '

cnn.com

'); + $this->assertSame($this->parsedown->text('[google.com](https://www.google.com)'), + '

google.com

'); } } diff --git a/tests/unit/Grav/Common/UriTest.php b/tests/unit/Grav/Common/UriTest.php index ed75871e2..1236ceba5 100644 --- a/tests/unit/Grav/Common/UriTest.php +++ b/tests/unit/Grav/Common/UriTest.php @@ -1,11 +1,21 @@ grav = Fixtures::get('grav'); @@ -71,7 +81,8 @@ class UriTest extends \Codeception\TestCase\Test $this->uri->initializeWithURL('http://localhost:8080/a/b/c/d')->init(); $this->assertSame($this->uri->paths(), ['a', 'b', 'c', 'd']); $this->uri->initializeWithURL('http://localhost:8080/a/b/c/d/e/f/a/b/c/d/e/f/a/b/c/d/e/f')->init(); - $this->assertSame($this->uri->paths(), ['a', 'b', 'c', 'd', 'e', 'f', 'a', 'b', 'c', 'd', 'e', 'f', 'a', 'b', 'c', 'd', 'e', 'f']); + $this->assertSame($this->uri->paths(), + ['a', 'b', 'c', 'd', 'e', 'f', 'a', 'b', 'c', 'd', 'e', 'f', 'a', 'b', 'c', 'd', 'e', 'f']); } public function testRoute() @@ -367,20 +378,20 @@ class UriTest extends \Codeception\TestCase\Test { $parsed_url = [ 'scheme' => 'http', - 'host' => 'localhost', - 'port' => '8080', + 'host' => 'localhost', + 'port' => '8080', ]; $this->assertSame(Uri::buildUrl($parsed_url), 'http://localhost:8080'); $parsed_url = [ - 'scheme' => 'http', - 'host' => 'localhost', - 'port' => '8080', - 'user' => 'foo', - 'pass' => 'bar', - 'path' => '/test', - 'query' => 'x=2', + 'scheme' => 'http', + 'host' => 'localhost', + 'port' => '8080', + 'user' => 'foo', + 'pass' => 'bar', + 'path' => '/test', + 'query' => 'x=2', 'fragment' => 'xxx', ]; diff --git a/tests/unit/Grav/Common/UtilsTest.php b/tests/unit/Grav/Common/UtilsTest.php index 57786e952..c6dbec24e 100644 --- a/tests/unit/Grav/Common/UtilsTest.php +++ b/tests/unit/Grav/Common/UtilsTest.php @@ -1,10 +1,17 @@ grav = Fixtures::get('grav'); @@ -19,12 +26,14 @@ class UtilsTest extends \Codeception\TestCase\Test $this->assertTrue(Utils::startsWith('english', 'en')); $this->assertTrue(Utils::startsWith('English', 'En')); $this->assertTrue(Utils::startsWith('ENGLISH', 'EN')); - $this->assertTrue(Utils::startsWith('ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH', 'EN')); + $this->assertTrue(Utils::startsWith('ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH', + 'EN')); $this->assertFalse(Utils::startsWith('english', 'En')); $this->assertFalse(Utils::startsWith('English', 'EN')); $this->assertFalse(Utils::startsWith('ENGLISH', 'en')); - $this->assertFalse(Utils::startsWith('ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH', 'e')); + $this->assertFalse(Utils::startsWith('ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH', + 'e')); } public function testEndsWith() @@ -32,12 +41,14 @@ class UtilsTest extends \Codeception\TestCase\Test $this->assertTrue(Utils::endsWith('english', 'sh')); $this->assertTrue(Utils::endsWith('EngliSh', 'Sh')); $this->assertTrue(Utils::endsWith('ENGLISH', 'SH')); - $this->assertTrue(Utils::endsWith('ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH', 'ENGLISH')); + $this->assertTrue(Utils::endsWith('ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH', + 'ENGLISH')); $this->assertFalse(Utils::endsWith('english', 'de')); $this->assertFalse(Utils::endsWith('EngliSh', 'sh')); $this->assertFalse(Utils::endsWith('ENGLISH', 'Sh')); - $this->assertFalse(Utils::endsWith('ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH', 'DEUSTCH')); + $this->assertFalse(Utils::endsWith('ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH', + 'DEUSTCH')); } public function testContains() @@ -45,11 +56,14 @@ class UtilsTest extends \Codeception\TestCase\Test $this->assertTrue(Utils::contains('english', 'nglis')); $this->assertTrue(Utils::contains('EngliSh', 'gliSh')); $this->assertTrue(Utils::contains('ENGLISH', 'ENGLI')); - $this->assertTrue(Utils::contains('ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH', 'ENGLISH')); + $this->assertTrue(Utils::contains('ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH', + 'ENGLISH')); - $this->assertFalse(Utils::contains('EngliSh', 'GLI')); $this->assertFalse(Utils::contains('EngliSh', 'English')); + $this->assertFalse(Utils::contains('EngliSh', 'GLI')); + $this->assertFalse(Utils::contains('EngliSh', 'English')); $this->assertFalse(Utils::contains('ENGLISH', 'SCH')); - $this->assertFalse(Utils::contains('ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH', 'DEUSTCH')); + $this->assertFalse(Utils::contains('ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH', + 'DEUSTCH')); } public function testSubstrToString() @@ -166,13 +180,13 @@ class UtilsTest extends \Codeception\TestCase\Test public function testArrayFilterRecursive() { $array = [ - 'test' => '', + 'test' => '', 'test2' => 'test2' ]; - $array = Utils::arrayFilterRecursive($array, function($k, $v) { - return !(is_null($v) || $v === ''); - }); + $array = Utils::arrayFilterRecursive($array, function ($k, $v) { + return !(is_null($v) || $v === ''); + }); $this->assertContainsOnly('string', $array); $this->assertFalse(isset($array['test'])); From aa4fb96b8b60271f4cb281b726647681c32c0e6f Mon Sep 17 00:00:00 2001 From: Flavio Copes Date: Fri, 29 Jan 2016 15:35:50 +0100 Subject: [PATCH 07/48] Drop generated files, ignored --- .../_generated/AcceptanceTesterActions.php | 2172 ----------------- .../_generated/FunctionalTesterActions.php | 18 - .../_support/_generated/UnitTesterActions.php | 348 --- 3 files changed, 2538 deletions(-) delete mode 100644 tests/_support/_generated/AcceptanceTesterActions.php delete mode 100644 tests/_support/_generated/FunctionalTesterActions.php delete mode 100644 tests/_support/_generated/UnitTesterActions.php diff --git a/tests/_support/_generated/AcceptanceTesterActions.php b/tests/_support/_generated/AcceptanceTesterActions.php deleted file mode 100644 index 06a32674a..000000000 --- a/tests/_support/_generated/AcceptanceTesterActions.php +++ /dev/null @@ -1,2172 +0,0 @@ -setHeader('X-Requested-With', 'Codeception'); - * $I->amOnPage('test-headers.php'); - * ?> - * ``` - * - * @param string $name the name of the request header - * @param string $value the value to set it to for subsequent - * requests - * @see \Codeception\Module\PhpBrowser::setHeader() - */ - public function setHeader($name, $value) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('setHeader', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Deletes the header with the passed name. Subsequent requests - * will not have the deleted header in its request. - * - * Example: - * ```php - * setHeader('X-Requested-With', 'Codeception'); - * $I->amOnPage('test-headers.php'); - * // ... - * $I->deleteHeader('X-Requested-With'); - * $I->amOnPage('some-other-page.php'); - * ?> - * ``` - * - * @param string $name the name of the header to delete. - * @see \Codeception\Module\PhpBrowser::deleteHeader() - */ - public function deleteHeader($name) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('deleteHeader', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Authenticates user for HTTP_AUTH - * - * @param $username - * @param $password - * @see \Codeception\Module\PhpBrowser::amHttpAuthenticated() - */ - public function amHttpAuthenticated($username, $password) { - return $this->getScenario()->runStep(new \Codeception\Step\Condition('amHttpAuthenticated', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Open web page at the given absolute URL and sets its hostname as the base host. - * - * ``` php - * amOnUrl('http://codeception.com'); - * $I->amOnPage('/quickstart'); // moves to http://codeception.com/quickstart - * ?> - * ``` - * @see \Codeception\Module\PhpBrowser::amOnUrl() - */ - public function amOnUrl($url) { - return $this->getScenario()->runStep(new \Codeception\Step\Condition('amOnUrl', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Changes the subdomain for the 'url' configuration parameter. - * Does not open a page; use `amOnPage` for that. - * - * ``` php - * amOnSubdomain('user'); - * $I->amOnPage('/'); - * // moves to http://user.mysite.com/ - * ?> - * ``` - * - * @param $subdomain - * - * @return mixed - * @see \Codeception\Module\PhpBrowser::amOnSubdomain() - */ - public function amOnSubdomain($subdomain) { - return $this->getScenario()->runStep(new \Codeception\Step\Condition('amOnSubdomain', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Low-level API method. - * If Codeception commands are not enough, use [Guzzle HTTP Client](http://guzzlephp.org/) methods directly - * - * Example: - * - * ``` php - * executeInGuzzle(function (\GuzzleHttp\Client $client) { - * $client->get('/get', ['query' => ['foo' => 'bar']]); - * }); - * ?> - * ``` - * - * It is not recommended to use this command on a regular basis. - * If Codeception lacks important Guzzle Client methods, implement them and submit patches. - * - * @param callable $function - * @see \Codeception\Module\PhpBrowser::executeInGuzzle() - */ - public function executeInGuzzle($function) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('executeInGuzzle', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Opens the page for the given relative URI. - * - * ``` php - * amOnPage('/'); - * // opens /register page - * $I->amOnPage('/register'); - * ``` - * - * @param $page - * @see \Codeception\Lib\InnerBrowser::amOnPage() - */ - public function amOnPage($page) { - return $this->getScenario()->runStep(new \Codeception\Step\Condition('amOnPage', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Perform a click on a link or a button, given by a locator. - * If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string. - * For buttons, the "value" attribute, "name" attribute, and inner text are searched. - * For links, the link text is searched. - * For images, the "alt" attribute and inner text of any parent links are searched. - * - * The second parameter is a context (CSS or XPath locator) to narrow the search. - * - * Note that if the locator matches a button of type `submit`, the form will be submitted. - * - * ``` php - * click('Logout'); - * // button of form - * $I->click('Submit'); - * // CSS button - * $I->click('#form input[type=submit]'); - * // XPath - * $I->click('//form/*[@type=submit]'); - * // link in context - * $I->click('Logout', '#nav'); - * // using strict locator - * $I->click(['link' => 'Login']); - * ?> - * ``` - * - * @param $link - * @param $context - * @see \Codeception\Lib\InnerBrowser::click() - */ - public function click($link, $context = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('click', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current page contains the given string (case insensitive). - * - * You can specify a specific HTML element (via CSS or XPath) as the second - * parameter to only search within that element. - * - * ``` php - * see('Logout'); // I can suppose user is logged in - * $I->see('Sign Up', 'h1'); // I can suppose it's a signup page - * $I->see('Sign Up', '//body/h1'); // with XPath - * ``` - * - * Note that the search is done after stripping all HTML tags from the body, - * so `$I->see('strong')` will return true for strings like: - * - * - `

I am Stronger than thou

` - * - `` - * - * But will *not* be true for strings like: - * - * - `Home` - * - `
Home` - * - `` - * - * For checking the raw source code, use `seeInSource()`. - * - * @param $text - * @param null $selector - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::see() - */ - public function canSee($text, $selector = null) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('see', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current page contains the given string (case insensitive). - * - * You can specify a specific HTML element (via CSS or XPath) as the second - * parameter to only search within that element. - * - * ``` php - * see('Logout'); // I can suppose user is logged in - * $I->see('Sign Up', 'h1'); // I can suppose it's a signup page - * $I->see('Sign Up', '//body/h1'); // with XPath - * ``` - * - * Note that the search is done after stripping all HTML tags from the body, - * so `$I->see('strong')` will return true for strings like: - * - * - `

I am Stronger than thou

` - * - `` - * - * But will *not* be true for strings like: - * - * - `Home` - * - `
Home` - * - `` - * - * For checking the raw source code, use `seeInSource()`. - * - * @param $text - * @param null $selector - * @see \Codeception\Lib\InnerBrowser::see() - */ - public function see($text, $selector = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('see', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current page doesn't contain the text specified (case insensitive). - * Give a locator as the second parameter to match a specific region. - * - * ```php - * dontSee('Login'); // I can suppose user is already logged in - * $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page - * $I->dontSee('Sign Up','//body/h1'); // with XPath - * ``` - * - * Note that the search is done after stripping all HTML tags from the body, - * so `$I->dontSee('strong')` will fail on strings like: - * - * - `

I am Stronger than thou

` - * - `` - * - * But will ignore strings like: - * - * - `Home` - * - `
Home` - * - `` - * - * For checking the raw source code, use `seeInSource()`. - * - * @param $text - * @param null $selector - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSee() - */ - public function cantSee($text, $selector = null) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSee', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current page doesn't contain the text specified (case insensitive). - * Give a locator as the second parameter to match a specific region. - * - * ```php - * dontSee('Login'); // I can suppose user is already logged in - * $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page - * $I->dontSee('Sign Up','//body/h1'); // with XPath - * ``` - * - * Note that the search is done after stripping all HTML tags from the body, - * so `$I->dontSee('strong')` will fail on strings like: - * - * - `

I am Stronger than thou

` - * - `` - * - * But will ignore strings like: - * - * - `Home` - * - `
Home` - * - `` - * - * For checking the raw source code, use `seeInSource()`. - * - * @param $text - * @param null $selector - * @see \Codeception\Lib\InnerBrowser::dontSee() - */ - public function dontSee($text, $selector = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSee', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current page contains the given string in its - * raw source code. - * - * ``` php - * seeInSource('

Green eggs & ham

'); - * ``` - * - * @param $raw - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeInSource() - */ - public function canSeeInSource($raw) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInSource', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current page contains the given string in its - * raw source code. - * - * ``` php - * seeInSource('

Green eggs & ham

'); - * ``` - * - * @param $raw - * @see \Codeception\Lib\InnerBrowser::seeInSource() - */ - public function seeInSource($raw) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInSource', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current page contains the given string in its - * raw source code. - * - * ```php - * dontSeeInSource('

Green eggs & ham

'); - * ``` - * - * @param $raw - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSeeInSource() - */ - public function cantSeeInSource($raw) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInSource', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current page contains the given string in its - * raw source code. - * - * ```php - * dontSeeInSource('

Green eggs & ham

'); - * ``` - * - * @param $raw - * @see \Codeception\Lib\InnerBrowser::dontSeeInSource() - */ - public function dontSeeInSource($raw) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInSource', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that there's a link with the specified text. - * Give a full URL as the second parameter to match links with that exact URL. - * - * ``` php - * seeLink('Logout'); // matches Logout - * $I->seeLink('Logout','/logout'); // matches Logout - * ?> - * ``` - * - * @param $text - * @param null $url - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeLink() - */ - public function canSeeLink($text, $url = null) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeLink', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that there's a link with the specified text. - * Give a full URL as the second parameter to match links with that exact URL. - * - * ``` php - * seeLink('Logout'); // matches Logout - * $I->seeLink('Logout','/logout'); // matches Logout - * ?> - * ``` - * - * @param $text - * @param null $url - * @see \Codeception\Lib\InnerBrowser::seeLink() - */ - public function seeLink($text, $url = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeLink', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the page doesn't contain a link with the given string. - * If the second parameter is given, only links with a matching "href" attribute will be checked. - * - * ``` php - * dontSeeLink('Logout'); // I suppose user is not logged in - * $I->dontSeeLink('Checkout now', '/store/cart.php'); - * ?> - * ``` - * - * @param $text - * @param null $url - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSeeLink() - */ - public function cantSeeLink($text, $url = null) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeLink', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the page doesn't contain a link with the given string. - * If the second parameter is given, only links with a matching "href" attribute will be checked. - * - * ``` php - * dontSeeLink('Logout'); // I suppose user is not logged in - * $I->dontSeeLink('Checkout now', '/store/cart.php'); - * ?> - * ``` - * - * @param $text - * @param null $url - * @see \Codeception\Lib\InnerBrowser::dontSeeLink() - */ - public function dontSeeLink($text, $url = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeLink', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that current URI contains the given string. - * - * ``` php - * seeInCurrentUrl('home'); - * // to match: /users/1 - * $I->seeInCurrentUrl('/users/'); - * ?> - * ``` - * - * @param $uri - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeInCurrentUrl() - */ - public function canSeeInCurrentUrl($uri) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInCurrentUrl', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that current URI contains the given string. - * - * ``` php - * seeInCurrentUrl('home'); - * // to match: /users/1 - * $I->seeInCurrentUrl('/users/'); - * ?> - * ``` - * - * @param $uri - * @see \Codeception\Lib\InnerBrowser::seeInCurrentUrl() - */ - public function seeInCurrentUrl($uri) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInCurrentUrl', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current URI doesn't contain the given string. - * - * ``` php - * dontSeeInCurrentUrl('/users/'); - * ?> - * ``` - * - * @param $uri - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSeeInCurrentUrl() - */ - public function cantSeeInCurrentUrl($uri) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInCurrentUrl', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current URI doesn't contain the given string. - * - * ``` php - * dontSeeInCurrentUrl('/users/'); - * ?> - * ``` - * - * @param $uri - * @see \Codeception\Lib\InnerBrowser::dontSeeInCurrentUrl() - */ - public function dontSeeInCurrentUrl($uri) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInCurrentUrl', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current URL is equal to the given string. - * Unlike `seeInCurrentUrl`, this only matches the full URL. - * - * ``` php - * seeCurrentUrlEquals('/'); - * ?> - * ``` - * - * @param $uri - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlEquals() - */ - public function canSeeCurrentUrlEquals($uri) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCurrentUrlEquals', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current URL is equal to the given string. - * Unlike `seeInCurrentUrl`, this only matches the full URL. - * - * ``` php - * seeCurrentUrlEquals('/'); - * ?> - * ``` - * - * @param $uri - * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlEquals() - */ - public function seeCurrentUrlEquals($uri) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCurrentUrlEquals', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current URL doesn't equal the given string. - * Unlike `dontSeeInCurrentUrl`, this only matches the full URL. - * - * ``` php - * dontSeeCurrentUrlEquals('/'); - * ?> - * ``` - * - * @param $uri - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlEquals() - */ - public function cantSeeCurrentUrlEquals($uri) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCurrentUrlEquals', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current URL doesn't equal the given string. - * Unlike `dontSeeInCurrentUrl`, this only matches the full URL. - * - * ``` php - * dontSeeCurrentUrlEquals('/'); - * ?> - * ``` - * - * @param $uri - * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlEquals() - */ - public function dontSeeCurrentUrlEquals($uri) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeCurrentUrlEquals', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current URL matches the given regular expression. - * - * ``` php - * seeCurrentUrlMatches('~$/users/(\d+)~'); - * ?> - * ``` - * - * @param $uri - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlMatches() - */ - public function canSeeCurrentUrlMatches($uri) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCurrentUrlMatches', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current URL matches the given regular expression. - * - * ``` php - * seeCurrentUrlMatches('~$/users/(\d+)~'); - * ?> - * ``` - * - * @param $uri - * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlMatches() - */ - public function seeCurrentUrlMatches($uri) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCurrentUrlMatches', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that current url doesn't match the given regular expression. - * - * ``` php - * dontSeeCurrentUrlMatches('~$/users/(\d+)~'); - * ?> - * ``` - * - * @param $uri - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlMatches() - */ - public function cantSeeCurrentUrlMatches($uri) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCurrentUrlMatches', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that current url doesn't match the given regular expression. - * - * ``` php - * dontSeeCurrentUrlMatches('~$/users/(\d+)~'); - * ?> - * ``` - * - * @param $uri - * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlMatches() - */ - public function dontSeeCurrentUrlMatches($uri) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeCurrentUrlMatches', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Executes the given regular expression against the current URI and returns the first match. - * If no parameters are provided, the full URI is returned. - * - * ``` php - * grabFromCurrentUrl('~$/user/(\d+)/~'); - * $uri = $I->grabFromCurrentUrl(); - * ?> - * ``` - * - * @param null $uri - * - * @return mixed - * @see \Codeception\Lib\InnerBrowser::grabFromCurrentUrl() - */ - public function grabFromCurrentUrl($uri = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('grabFromCurrentUrl', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the specified checkbox is checked. - * - * ``` php - * seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms - * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user agreed to terms, If there is only one checkbox in form. - * $I->seeCheckboxIsChecked('//form/input[@type=checkbox and @name=agree]'); - * ?> - * ``` - * - * @param $checkbox - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeCheckboxIsChecked() - */ - public function canSeeCheckboxIsChecked($checkbox) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCheckboxIsChecked', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the specified checkbox is checked. - * - * ``` php - * seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms - * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user agreed to terms, If there is only one checkbox in form. - * $I->seeCheckboxIsChecked('//form/input[@type=checkbox and @name=agree]'); - * ?> - * ``` - * - * @param $checkbox - * @see \Codeception\Lib\InnerBrowser::seeCheckboxIsChecked() - */ - public function seeCheckboxIsChecked($checkbox) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCheckboxIsChecked', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Check that the specified checkbox is unchecked. - * - * ``` php - * dontSeeCheckboxIsChecked('#agree'); // I suppose user didn't agree to terms - * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user didn't check the first checkbox in form. - * ?> - * ``` - * - * @param $checkbox - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSeeCheckboxIsChecked() - */ - public function cantSeeCheckboxIsChecked($checkbox) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCheckboxIsChecked', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Check that the specified checkbox is unchecked. - * - * ``` php - * dontSeeCheckboxIsChecked('#agree'); // I suppose user didn't agree to terms - * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user didn't check the first checkbox in form. - * ?> - * ``` - * - * @param $checkbox - * @see \Codeception\Lib\InnerBrowser::dontSeeCheckboxIsChecked() - */ - public function dontSeeCheckboxIsChecked($checkbox) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeCheckboxIsChecked', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the given input field or textarea contains the given value. - * For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath. - * - * ``` php - * seeInField('Body','Type your comment here'); - * $I->seeInField('form textarea[name=body]','Type your comment here'); - * $I->seeInField('form input[type=hidden]','hidden_value'); - * $I->seeInField('#searchform input','Search'); - * $I->seeInField('//form/*[@name=search]','Search'); - * $I->seeInField(['name' => 'search'], 'Search'); - * ?> - * ``` - * - * @param $field - * @param $value - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeInField() - */ - public function canSeeInField($field, $value) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInField', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the given input field or textarea contains the given value. - * For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath. - * - * ``` php - * seeInField('Body','Type your comment here'); - * $I->seeInField('form textarea[name=body]','Type your comment here'); - * $I->seeInField('form input[type=hidden]','hidden_value'); - * $I->seeInField('#searchform input','Search'); - * $I->seeInField('//form/*[@name=search]','Search'); - * $I->seeInField(['name' => 'search'], 'Search'); - * ?> - * ``` - * - * @param $field - * @param $value - * @see \Codeception\Lib\InnerBrowser::seeInField() - */ - public function seeInField($field, $value) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInField', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that an input field or textarea doesn't contain the given value. - * For fuzzy locators, the field is matched by label text, CSS and XPath. - * - * ``` php - * dontSeeInField('Body','Type your comment here'); - * $I->dontSeeInField('form textarea[name=body]','Type your comment here'); - * $I->dontSeeInField('form input[type=hidden]','hidden_value'); - * $I->dontSeeInField('#searchform input','Search'); - * $I->dontSeeInField('//form/*[@name=search]','Search'); - * $I->dontSeeInField(['name' => 'search'], 'Search'); - * ?> - * ``` - * - * @param $field - * @param $value - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSeeInField() - */ - public function cantSeeInField($field, $value) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInField', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that an input field or textarea doesn't contain the given value. - * For fuzzy locators, the field is matched by label text, CSS and XPath. - * - * ``` php - * dontSeeInField('Body','Type your comment here'); - * $I->dontSeeInField('form textarea[name=body]','Type your comment here'); - * $I->dontSeeInField('form input[type=hidden]','hidden_value'); - * $I->dontSeeInField('#searchform input','Search'); - * $I->dontSeeInField('//form/*[@name=search]','Search'); - * $I->dontSeeInField(['name' => 'search'], 'Search'); - * ?> - * ``` - * - * @param $field - * @param $value - * @see \Codeception\Lib\InnerBrowser::dontSeeInField() - */ - public function dontSeeInField($field, $value) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInField', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks if the array of form parameters (name => value) are set on the form matched with the - * passed selector. - * - * ``` php - * seeInFormFields('form[name=myform]', [ - * 'input1' => 'value', - * 'input2' => 'other value', - * ]); - * ?> - * ``` - * - * For multi-select elements, or to check values of multiple elements with the same name, an - * array may be passed: - * - * ``` php - * seeInFormFields('.form-class', [ - * 'multiselect' => [ - * 'value1', - * 'value2', - * ], - * 'checkbox[]' => [ - * 'a checked value', - * 'another checked value', - * ], - * ]); - * ?> - * ``` - * - * Additionally, checkbox values can be checked with a boolean. - * - * ``` php - * seeInFormFields('#form-id', [ - * 'checkbox1' => true, // passes if checked - * 'checkbox2' => false, // passes if unchecked - * ]); - * ?> - * ``` - * - * Pair this with submitForm for quick testing magic. - * - * ``` php - * 'value', - * 'field2' => 'another value', - * 'checkbox1' => true, - * // ... - * ]; - * $I->submitForm('//form[@id=my-form]', $form, 'submitButton'); - * // $I->amOnPage('/path/to/form-page') may be needed - * $I->seeInFormFields('//form[@id=my-form]', $form); - * ?> - * ``` - * - * @param $formSelector - * @param $params - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeInFormFields() - */ - public function canSeeInFormFields($formSelector, $params) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInFormFields', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks if the array of form parameters (name => value) are set on the form matched with the - * passed selector. - * - * ``` php - * seeInFormFields('form[name=myform]', [ - * 'input1' => 'value', - * 'input2' => 'other value', - * ]); - * ?> - * ``` - * - * For multi-select elements, or to check values of multiple elements with the same name, an - * array may be passed: - * - * ``` php - * seeInFormFields('.form-class', [ - * 'multiselect' => [ - * 'value1', - * 'value2', - * ], - * 'checkbox[]' => [ - * 'a checked value', - * 'another checked value', - * ], - * ]); - * ?> - * ``` - * - * Additionally, checkbox values can be checked with a boolean. - * - * ``` php - * seeInFormFields('#form-id', [ - * 'checkbox1' => true, // passes if checked - * 'checkbox2' => false, // passes if unchecked - * ]); - * ?> - * ``` - * - * Pair this with submitForm for quick testing magic. - * - * ``` php - * 'value', - * 'field2' => 'another value', - * 'checkbox1' => true, - * // ... - * ]; - * $I->submitForm('//form[@id=my-form]', $form, 'submitButton'); - * // $I->amOnPage('/path/to/form-page') may be needed - * $I->seeInFormFields('//form[@id=my-form]', $form); - * ?> - * ``` - * - * @param $formSelector - * @param $params - * @see \Codeception\Lib\InnerBrowser::seeInFormFields() - */ - public function seeInFormFields($formSelector, $params) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInFormFields', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks if the array of form parameters (name => value) are not set on the form matched with - * the passed selector. - * - * ``` php - * dontSeeInFormFields('form[name=myform]', [ - * 'input1' => 'non-existent value', - * 'input2' => 'other non-existent value', - * ]); - * ?> - * ``` - * - * To check that an element hasn't been assigned any one of many values, an array can be passed - * as the value: - * - * ``` php - * dontSeeInFormFields('.form-class', [ - * 'fieldName' => [ - * 'This value shouldn\'t be set', - * 'And this value shouldn\'t be set', - * ], - * ]); - * ?> - * ``` - * - * Additionally, checkbox values can be checked with a boolean. - * - * ``` php - * dontSeeInFormFields('#form-id', [ - * 'checkbox1' => true, // fails if checked - * 'checkbox2' => false, // fails if unchecked - * ]); - * ?> - * ``` - * - * @param $formSelector - * @param $params - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSeeInFormFields() - */ - public function cantSeeInFormFields($formSelector, $params) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInFormFields', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks if the array of form parameters (name => value) are not set on the form matched with - * the passed selector. - * - * ``` php - * dontSeeInFormFields('form[name=myform]', [ - * 'input1' => 'non-existent value', - * 'input2' => 'other non-existent value', - * ]); - * ?> - * ``` - * - * To check that an element hasn't been assigned any one of many values, an array can be passed - * as the value: - * - * ``` php - * dontSeeInFormFields('.form-class', [ - * 'fieldName' => [ - * 'This value shouldn\'t be set', - * 'And this value shouldn\'t be set', - * ], - * ]); - * ?> - * ``` - * - * Additionally, checkbox values can be checked with a boolean. - * - * ``` php - * dontSeeInFormFields('#form-id', [ - * 'checkbox1' => true, // fails if checked - * 'checkbox2' => false, // fails if unchecked - * ]); - * ?> - * ``` - * - * @param $formSelector - * @param $params - * @see \Codeception\Lib\InnerBrowser::dontSeeInFormFields() - */ - public function dontSeeInFormFields($formSelector, $params) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInFormFields', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Submits the given form on the page, optionally with the given form - * values. Give the form fields values as an array. - * - * Although this function can be used as a short-hand version of - * `fillField()`, `selectOption()`, `click()` etc. it has some important - * differences: - * - * * Only field *names* may be used, not CSS/XPath selectors nor field labels - * * If a field is sent to this function that does *not* exist on the page, - * it will silently be added to the HTTP request. This is helpful for testing - * some types of forms, but be aware that you will *not* get an exception - * like you would if you called `fillField()` or `selectOption()` with - * a missing field. - * - * Fields that are not provided will be filled by their values from the page, - * or from any previous calls to `fillField()`, `selectOption()` etc. - * You don't need to click the 'Submit' button afterwards. - * This command itself triggers the request to form's action. - * - * You can optionally specify which button's value to include - * in the request with the last parameter (as an alternative to - * explicitly setting its value in the second parameter), as - * button values are not otherwise included in the request. - * - * Examples: - * - * ``` php - * submitForm('#login', [ - * 'login' => 'davert', - * 'password' => '123456' - * ]); - * // or - * $I->submitForm('#login', [ - * 'login' => 'davert', - * 'password' => '123456' - * ], 'submitButtonName'); - * - * ``` - * - * For example, given this sample "Sign Up" form: - * - * ``` html - *
- * Login: - *
- * Password: - *
- * Do you agree to our terms? - *
- * Select pricing plan: - * - * - *
- * ``` - * - * You could write the following to submit it: - * - * ``` php - * submitForm( - * '#userForm', - * [ - * 'user' => [ - * 'login' => 'Davert', - * 'password' => '123456', - * 'agree' => true - * ] - * ], - * 'submitButton' - * ); - * ``` - * Note that "2" will be the submitted value for the "plan" field, as it is - * the selected option. - * - * You can also emulate a JavaScript submission by not specifying any - * buttons in the third parameter to submitForm. - * - * ```php - * submitForm( - * '#userForm', - * [ - * 'user' => [ - * 'login' => 'Davert', - * 'password' => '123456', - * 'agree' => true - * ] - * ] - * ); - * ``` - * - * This function works well when paired with `seeInFormFields()` - * for quickly testing CRUD interfaces and form validation logic. - * - * ``` php - * 'value', - * 'field2' => 'another value', - * 'checkbox1' => true, - * // ... - * ]; - * $I->submitForm('#my-form', $form, 'submitButton'); - * // $I->amOnPage('/path/to/form-page') may be needed - * $I->seeInFormFields('#my-form', $form); - * ``` - * - * Parameter values can be set to arrays for multiple input fields - * of the same name, or multi-select combo boxes. For checkboxes, - * you can use either the string value or boolean `true`/`false` which will - * be replaced by the checkbox's value in the DOM. - * - * ``` php - * submitForm('#my-form', [ - * 'field1' => 'value', - * 'checkbox' => [ - * 'value of first checkbox', - * 'value of second checkbox', - * ], - * 'otherCheckboxes' => [ - * true, - * false, - * false - * ], - * 'multiselect' => [ - * 'first option value', - * 'second option value' - * ] - * ]); - * ``` - * - * Mixing string and boolean values for a checkbox's value is not supported - * and may produce unexpected results. - * - * Field names ending in `[]` must be passed without the trailing square - * bracket characters, and must contain an array for its value. This allows - * submitting multiple values with the same name, consider: - * - * ```php - * submitForm('#my-form', [ - * 'field[]' => 'value', - * 'field[]' => 'another value', // 'field[]' is already a defined key - * ]); - * ``` - * - * The solution is to pass an array value: - * - * ```php - * submitForm('#my-form', [ - * 'field' => [ - * 'value', - * 'another value', - * ] - * ]); - * ``` - * - * @param $selector - * @param $params - * @param $button - * @see \Codeception\Lib\InnerBrowser::submitForm() - */ - public function submitForm($selector, $params, $button = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('submitForm', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Fills a text field or textarea with the given string. - * - * ``` php - * fillField("//input[@type='text']", "Hello World!"); - * $I->fillField(['name' => 'email'], 'jon@mail.com'); - * ?> - * ``` - * - * @param $field - * @param $value - * @see \Codeception\Lib\InnerBrowser::fillField() - */ - public function fillField($field, $value) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('fillField', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Selects an option in a select tag or in radio button group. - * - * ``` php - * selectOption('form select[name=account]', 'Premium'); - * $I->selectOption('form input[name=payment]', 'Monthly'); - * $I->selectOption('//form/select[@name=account]', 'Monthly'); - * ?> - * ``` - * - * Provide an array for the second argument to select multiple options: - * - * ``` php - * selectOption('Which OS do you use?', array('Windows','Linux')); - * ?> - * ``` - * - * @param $select - * @param $option - * @see \Codeception\Lib\InnerBrowser::selectOption() - */ - public function selectOption($select, $option) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('selectOption', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Ticks a checkbox. For radio buttons, use the `selectOption` method instead. - * - * ``` php - * checkOption('#agree'); - * ?> - * ``` - * - * @param $option - * @see \Codeception\Lib\InnerBrowser::checkOption() - */ - public function checkOption($option) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('checkOption', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Unticks a checkbox. - * - * ``` php - * uncheckOption('#notify'); - * ?> - * ``` - * - * @param $option - * @see \Codeception\Lib\InnerBrowser::uncheckOption() - */ - public function uncheckOption($option) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('uncheckOption', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Attaches a file relative to the Codeception data directory to the given file upload field. - * - * ``` php - * attachFile('input[@type="file"]', 'prices.xls'); - * ?> - * ``` - * - * @param $field - * @param $filename - * @see \Codeception\Lib\InnerBrowser::attachFile() - */ - public function attachFile($field, $filename) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('attachFile', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * If your page triggers an ajax request, you can perform it manually. - * This action sends a GET ajax request with specified params. - * - * See ->sendAjaxPostRequest for examples. - * - * @param $uri - * @param $params - * @see \Codeception\Lib\InnerBrowser::sendAjaxGetRequest() - */ - public function sendAjaxGetRequest($uri, $params = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('sendAjaxGetRequest', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * If your page triggers an ajax request, you can perform it manually. - * This action sends a POST ajax request with specified params. - * Additional params can be passed as array. - * - * Example: - * - * Imagine that by clicking checkbox you trigger ajax request which updates user settings. - * We emulate that click by running this ajax request manually. - * - * ``` php - * sendAjaxPostRequest('/updateSettings', array('notifications' => true)); // POST - * $I->sendAjaxGetRequest('/updateSettings', array('notifications' => true)); // GET - * - * ``` - * - * @param $uri - * @param $params - * @see \Codeception\Lib\InnerBrowser::sendAjaxPostRequest() - */ - public function sendAjaxPostRequest($uri, $params = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('sendAjaxPostRequest', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * If your page triggers an ajax request, you can perform it manually. - * This action sends an ajax request with specified method and params. - * - * Example: - * - * You need to perform an ajax request specifying the HTTP method. - * - * ``` php - * sendAjaxRequest('PUT', '/posts/7', array('title' => 'new title')); - * - * ``` - * - * @param $method - * @param $uri - * @param $params - * @see \Codeception\Lib\InnerBrowser::sendAjaxRequest() - */ - public function sendAjaxRequest($method, $uri, $params = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('sendAjaxRequest', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Finds and returns the text contents of the given element. - * If a fuzzy locator is used, the element is found using CSS, XPath, and by matching the full page source by regular expression. - * - * ``` php - * grabTextFrom('h1'); - * $heading = $I->grabTextFrom('descendant-or-self::h1'); - * $value = $I->grabTextFrom('~ - * ``` - * - * @param $cssOrXPathOrRegex - * - * @return mixed - * @see \Codeception\Lib\InnerBrowser::grabTextFrom() - */ - public function grabTextFrom($cssOrXPathOrRegex) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('grabTextFrom', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Grabs the value of the given attribute value from the given element. - * Fails if element is not found. - * - * ``` php - * grabAttributeFrom('#tooltip', 'title'); - * ?> - * ``` - * - * - * @param $cssOrXpath - * @param $attribute - * - * @return mixed - * @see \Codeception\Lib\InnerBrowser::grabAttributeFrom() - */ - public function grabAttributeFrom($cssOrXpath, $attribute) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('grabAttributeFrom', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Grabs either the text content, or attribute values, of nodes - * matched by $cssOrXpath and returns them as an array. - * - * ```html - * First - * Second - * Third - * ``` - * - * ```php - * grabMultiple('a'); - * - * // would return ['#first', '#second', '#third'] - * $aLinks = $I->grabMultiple('a', 'href'); - * ?> - * ``` - * - * @param $cssOrXpath - * @param $attribute - * @return string[] - * @see \Codeception\Lib\InnerBrowser::grabMultiple() - */ - public function grabMultiple($cssOrXpath, $attribute = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('grabMultiple', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param $field - * - * @return array|mixed|null|string - * @see \Codeception\Lib\InnerBrowser::grabValueFrom() - */ - public function grabValueFrom($field) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('grabValueFrom', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Sets a cookie with the given name and value. - * You can set additional cookie params like `domain`, `path`, `expires`, `secure` in array passed as last argument. - * - * ``` php - * setCookie('PHPSESSID', 'el4ukv0kqbvoirg7nkp4dncpk3'); - * ?> - * ``` - * - * @param $name - * @param $val - * @param array $params - * - * @return mixed - * @see \Codeception\Lib\InnerBrowser::setCookie() - */ - public function setCookie($name, $val, $params = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('setCookie', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Grabs a cookie value. - * You can set additional cookie params like `domain`, `path` in array passed as last argument. - * - * @param $cookie - * - * @param array $params - * @return mixed - * @see \Codeception\Lib\InnerBrowser::grabCookie() - */ - public function grabCookie($cookie, $params = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('grabCookie', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that a cookie with the given name is set. - * You can set additional cookie params like `domain`, `path` as array passed in last argument. - * - * ``` php - * seeCookie('PHPSESSID'); - * ?> - * ``` - * - * @param $cookie - * @param array $params - * @return mixed - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeCookie() - */ - public function canSeeCookie($cookie, $params = null) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCookie', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that a cookie with the given name is set. - * You can set additional cookie params like `domain`, `path` as array passed in last argument. - * - * ``` php - * seeCookie('PHPSESSID'); - * ?> - * ``` - * - * @param $cookie - * @param array $params - * @return mixed - * @see \Codeception\Lib\InnerBrowser::seeCookie() - */ - public function seeCookie($cookie, $params = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCookie', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that there isn't a cookie with the given name. - * You can set additional cookie params like `domain`, `path` as array passed in last argument. - * - * @param $cookie - * - * @param array $params - * @return mixed - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSeeCookie() - */ - public function cantSeeCookie($cookie, $params = null) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCookie', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that there isn't a cookie with the given name. - * You can set additional cookie params like `domain`, `path` as array passed in last argument. - * - * @param $cookie - * - * @param array $params - * @return mixed - * @see \Codeception\Lib\InnerBrowser::dontSeeCookie() - */ - public function dontSeeCookie($cookie, $params = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeCookie', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Unsets cookie with the given name. - * You can set additional cookie params like `domain`, `path` in array passed as last argument. - * - * @param $cookie - * - * @param array $params - * @return mixed - * @see \Codeception\Lib\InnerBrowser::resetCookie() - */ - public function resetCookie($name, $params = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('resetCookie', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the given element exists on the page and is visible. - * You can also specify expected attributes of this element. - * - * ``` php - * seeElement('.error'); - * $I->seeElement('//form/input[1]'); - * $I->seeElement('input', ['name' => 'login']); - * $I->seeElement('input', ['value' => '123456']); - * - * // strict locator in first arg, attributes in second - * $I->seeElement(['css' => 'form input'], ['name' => 'login']); - * ?> - * ``` - * - * @param $selector - * @param array $attributes - * @return - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeElement() - */ - public function canSeeElement($selector, $attributes = null) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeElement', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the given element exists on the page and is visible. - * You can also specify expected attributes of this element. - * - * ``` php - * seeElement('.error'); - * $I->seeElement('//form/input[1]'); - * $I->seeElement('input', ['name' => 'login']); - * $I->seeElement('input', ['value' => '123456']); - * - * // strict locator in first arg, attributes in second - * $I->seeElement(['css' => 'form input'], ['name' => 'login']); - * ?> - * ``` - * - * @param $selector - * @param array $attributes - * @return - * @see \Codeception\Lib\InnerBrowser::seeElement() - */ - public function seeElement($selector, $attributes = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeElement', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the given element is invisible or not present on the page. - * You can also specify expected attributes of this element. - * - * ``` php - * dontSeeElement('.error'); - * $I->dontSeeElement('//form/input[1]'); - * $I->dontSeeElement('input', ['name' => 'login']); - * $I->dontSeeElement('input', ['value' => '123456']); - * ?> - * ``` - * - * @param $selector - * @param array $attributes - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSeeElement() - */ - public function cantSeeElement($selector, $attributes = null) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeElement', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the given element is invisible or not present on the page. - * You can also specify expected attributes of this element. - * - * ``` php - * dontSeeElement('.error'); - * $I->dontSeeElement('//form/input[1]'); - * $I->dontSeeElement('input', ['name' => 'login']); - * $I->dontSeeElement('input', ['value' => '123456']); - * ?> - * ``` - * - * @param $selector - * @param array $attributes - * @see \Codeception\Lib\InnerBrowser::dontSeeElement() - */ - public function dontSeeElement($selector, $attributes = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeElement', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that there are a certain number of elements matched by the given locator on the page. - * - * ``` php - * seeNumberOfElements('tr', 10); - * $I->seeNumberOfElements('tr', [0,10]); //between 0 and 10 elements - * ?> - * ``` - * @param $selector - * @param mixed $expected : - * - string: strict number - * - array: range of numbers [0,10] - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeNumberOfElements() - */ - public function canSeeNumberOfElements($selector, $expected) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeNumberOfElements', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that there are a certain number of elements matched by the given locator on the page. - * - * ``` php - * seeNumberOfElements('tr', 10); - * $I->seeNumberOfElements('tr', [0,10]); //between 0 and 10 elements - * ?> - * ``` - * @param $selector - * @param mixed $expected : - * - string: strict number - * - array: range of numbers [0,10] - * @see \Codeception\Lib\InnerBrowser::seeNumberOfElements() - */ - public function seeNumberOfElements($selector, $expected) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeNumberOfElements', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the given option is selected. - * - * ``` php - * seeOptionIsSelected('#form input[name=payment]', 'Visa'); - * ?> - * ``` - * - * @param $selector - * @param $optionText - * - * @return mixed - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeOptionIsSelected() - */ - public function canSeeOptionIsSelected($selector, $optionText) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeOptionIsSelected', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the given option is selected. - * - * ``` php - * seeOptionIsSelected('#form input[name=payment]', 'Visa'); - * ?> - * ``` - * - * @param $selector - * @param $optionText - * - * @return mixed - * @see \Codeception\Lib\InnerBrowser::seeOptionIsSelected() - */ - public function seeOptionIsSelected($selector, $optionText) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeOptionIsSelected', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the given option is not selected. - * - * ``` php - * dontSeeOptionIsSelected('#form input[name=payment]', 'Visa'); - * ?> - * ``` - * - * @param $selector - * @param $optionText - * - * @return mixed - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSeeOptionIsSelected() - */ - public function cantSeeOptionIsSelected($selector, $optionText) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeOptionIsSelected', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the given option is not selected. - * - * ``` php - * dontSeeOptionIsSelected('#form input[name=payment]', 'Visa'); - * ?> - * ``` - * - * @param $selector - * @param $optionText - * - * @return mixed - * @see \Codeception\Lib\InnerBrowser::dontSeeOptionIsSelected() - */ - public function dontSeeOptionIsSelected($selector, $optionText) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeOptionIsSelected', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that current page has 404 response status code. - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seePageNotFound() - */ - public function canSeePageNotFound() { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seePageNotFound', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that current page has 404 response status code. - * @see \Codeception\Lib\InnerBrowser::seePageNotFound() - */ - public function seePageNotFound() { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seePageNotFound', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that response code is equal to value provided. - * - * @param $code - * - * @return mixed - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeResponseCodeIs() - */ - public function canSeeResponseCodeIs($code) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeResponseCodeIs', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that response code is equal to value provided. - * - * @param $code - * - * @return mixed - * @see \Codeception\Lib\InnerBrowser::seeResponseCodeIs() - */ - public function seeResponseCodeIs($code) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeResponseCodeIs', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the page title contains the given string. - * - * ``` php - * seeInTitle('Blog - Post #1'); - * ?> - * ``` - * - * @param $title - * - * @return mixed - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeInTitle() - */ - public function canSeeInTitle($title) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInTitle', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the page title contains the given string. - * - * ``` php - * seeInTitle('Blog - Post #1'); - * ?> - * ``` - * - * @param $title - * - * @return mixed - * @see \Codeception\Lib\InnerBrowser::seeInTitle() - */ - public function seeInTitle($title) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInTitle', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the page title does not contain the given string. - * - * @param $title - * - * @return mixed - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSeeInTitle() - */ - public function cantSeeInTitle($title) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInTitle', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the page title does not contain the given string. - * - * @param $title - * - * @return mixed - * @see \Codeception\Lib\InnerBrowser::dontSeeInTitle() - */ - public function dontSeeInTitle($title) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInTitle', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Switch to iframe or frame on the page. - * - * Example: - * ``` html - *