Skip to content

Support for Codeception 5 #51

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

strategy:
matrix:
php: [7.4, 8.0]
php: [8.0, 8.1]

steps:
- name: Checkout code
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@
"name": "Gintautas Miselis"
}
],
"minimum-stability": "RC",
"minimum-stability": "dev",
"require": {
"php": "^7.4 | ^8.0",
"php": "^8.0",
"ext-dom": "*",
"ext-json": "*",
"ext-mbstring": "*",
"codeception/codeception": "^4.1 | 4.*@dev",
"codeception/codeception": "^5.0.0-alpha1",
"symfony/browser-kit": "^4.4 | ^5.4 | ^6.0",
"symfony/dom-crawler": "^4.4 | ^5.4 | ^6.0"
},
"require-dev": {
"codeception/util-universalframework": "dev-master"
},
"conflict": {
"codeception/codeception": "<4.1"
"codeception/codeception": "<5.0"
},
"autoload": {
"classmap": [
Expand Down
70 changes: 35 additions & 35 deletions src/Codeception/Lib/InnerBrowser.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public function _after(TestInterface $test)
/**
* @return class-string
*/
public function _conflicts()
public function _conflicts(): string
{
return \Codeception\Lib\Interfaces\Web::class;
}
Expand Down Expand Up @@ -157,7 +157,7 @@ public function _request(
array $files = [],
array $server = [],
string $content = null
): string {
): ?string {
$this->clientRequest($method, $uri, $parameters, $files, $server, $content);
return $this->_getResponseContent();
}
Expand Down Expand Up @@ -319,7 +319,7 @@ private function getRunningClient(): AbstractBrowser
return $this->client;
}

public function _savePageSource($filename)
public function _savePageSource(string $filename): void
{
file_put_contents($filename, $this->_getResponseContent());
}
Expand Down Expand Up @@ -386,12 +386,12 @@ public function deleteHeader(string $name): void
unset($this->headers[$name]);
}

public function amOnPage($page)
public function amOnPage(string $page): void
{
$this->_loadPage('GET', $page);
}

public function click($link, $context = null)
public function click($link, $context = null): void
{
if ($context) {
$this->crawler = $this->match($context);
Expand Down Expand Up @@ -530,7 +530,7 @@ private function retrieveBaseUrl(): string
return $this->getAbsoluteUrlFor($baseUrl);
}

public function see($text, $selector = null)
public function see(string $text, $selector = null): void
{
if (!$selector) {
$this->assertPageContains($text);
Expand All @@ -541,7 +541,7 @@ public function see($text, $selector = null)
$this->assertDomContains($nodes, $this->stringifySelector($selector), $text);
}

public function dontSee($text, $selector = null)
public function dontSee(string $text, $selector = null): void
{
if (!$selector) {
$this->assertPageNotContains($text);
Expand All @@ -552,17 +552,17 @@ public function dontSee($text, $selector = null)
$this->assertDomNotContains($nodes, $this->stringifySelector($selector), $text);
}

public function seeInSource($raw)
public function seeInSource(string $raw): void
{
$this->assertPageSourceContains($raw);
}

public function dontSeeInSource($raw)
public function dontSeeInSource(string $raw): void
{
$this->assertPageSourceNotContains($raw);
}

public function seeLink($text, $url = null)
public function seeLink(string $text, string $url = null): void
{
$crawler = $this->getCrawler()->selectLink($text);
if ($crawler->count() === 0) {
Expand All @@ -579,7 +579,7 @@ public function seeLink($text, $url = null)
$this->assertTrue(true);
}

public function dontSeeLink($text, $url = null)
public function dontSeeLink(string $text, string $url = ''): void
{
$crawler = $this->getCrawler()->selectLink($text);
if (!$url && $crawler->count() > 0) {
Expand All @@ -603,32 +603,32 @@ public function _getCurrentUri(): string
return Uri::retrieveUri($this->getRunningClient()->getHistory()->current()->getUri());
}

public function seeInCurrentUrl($uri)
public function seeInCurrentUrl(string $uri): void
{
$this->assertStringContainsString($uri, $this->_getCurrentUri());
}

public function dontSeeInCurrentUrl($uri)
public function dontSeeInCurrentUrl(string $uri): void
{
$this->assertStringNotContainsString($uri, $this->_getCurrentUri());
}

public function seeCurrentUrlEquals($uri)
public function seeCurrentUrlEquals(string $uri): void
{
$this->assertSame(rtrim($uri, '/'), rtrim($this->_getCurrentUri(), '/'));
}

public function dontSeeCurrentUrlEquals($uri)
public function dontSeeCurrentUrlEquals(string $uri): void
{
$this->assertNotSame(rtrim($uri, '/'), rtrim($this->_getCurrentUri(), '/'));
}

public function seeCurrentUrlMatches($uri)
public function seeCurrentUrlMatches(string $uri): void
{
$this->assertRegExp($uri, $this->_getCurrentUri());
}

public function dontSeeCurrentUrlMatches($uri)
public function dontSeeCurrentUrlMatches(string $uri): void
{
$this->assertNotRegExp($uri, $this->_getCurrentUri());
}
Expand All @@ -652,36 +652,36 @@ public function grabFromCurrentUrl($uri = null)
return $matches[1];
}

public function seeCheckboxIsChecked($checkbox)
public function seeCheckboxIsChecked($checkbox): void
{
$checkboxes = $this->getFieldsByLabelOrCss($checkbox);
$this->assertDomContains($checkboxes->filter('input[checked=checked]'), 'checkbox');
}

public function dontSeeCheckboxIsChecked($checkbox)
public function dontSeeCheckboxIsChecked(string $checkbox): void
{
$checkboxes = $this->getFieldsByLabelOrCss($checkbox);
$this->assertSame(0, $checkboxes->filter('input[checked=checked]')->count());
}

public function seeInField($field, $value)
public function seeInField($field, $value): void
{
$nodes = $this->getFieldsByLabelOrCss($field);
$this->assert($this->proceedSeeInField($nodes, $value));
}

public function dontSeeInField($field, $value)
public function dontSeeInField($field, $value): void
{
$nodes = $this->getFieldsByLabelOrCss($field);
$this->assertNot($this->proceedSeeInField($nodes, $value));
}

public function seeInFormFields($formSelector, array $params)
public function seeInFormFields($formSelector, array $params): void
{
$this->proceedSeeInFormFields($formSelector, $params, false);
}

public function dontSeeInFormFields($formSelector, array $params)
public function dontSeeInFormFields($formSelector, array $params): void
{
$this->proceedSeeInFormFields($formSelector, $params, true);
}
Expand Down Expand Up @@ -944,7 +944,7 @@ protected function proceedSubmitForm(Crawler $frmCrawl, array $params, string $b
$this->forms = [];
}

public function submitForm($selector, array $params, $button = null)
public function submitForm($selector, array $params, string $button = null): void
{
$form = $this->match($selector)->first();
if (count($form) === 0) {
Expand Down Expand Up @@ -1125,7 +1125,7 @@ protected function getFormValuesFor(SymfonyForm $form): array
return $values;
}

public function fillField($field, $value)
public function fillField($field, $value): void
{
$value = (string) $value;
$input = $this->getFieldByLabelOrCss($field);
Expand Down Expand Up @@ -1189,7 +1189,7 @@ protected function getFieldByLabelOrCss($field): SymfonyCrawler
return $input->first();
}

public function selectOption($select, $option)
public function selectOption($select, $option): void
{
$field = $this->getFieldByLabelOrCss($select);
$form = $this->getFormFor($field);
Expand Down Expand Up @@ -1229,7 +1229,7 @@ public function selectOption($select, $option)
return;
}

$formField->select($this->matchOption($field, $option));
$formField->select((string) $this->matchOption($field, $option));
}

/**
Expand Down Expand Up @@ -1267,12 +1267,12 @@ protected function matchOption(Crawler $field, $option)
return $option;
}

public function checkOption($option)
public function checkOption($option): void
{
$this->proceedCheckOption($option)->tick();
}

public function uncheckOption($option)
public function uncheckOption($option): void
{
$this->proceedCheckOption($option)->untick();
}
Expand All @@ -1299,7 +1299,7 @@ protected function proceedCheckOption($option): ChoiceFormField
return $formField;
}

public function attachFile($field, $filename)
public function attachFile($field, string $filename): void
{
$form = $this->getFormFor($field = $this->getFieldByLabelOrCss($field));
$filePath = codecept_data_dir() . $filename;
Expand Down Expand Up @@ -1379,7 +1379,7 @@ protected function debugResponse($url): void
$this->debugSection('Response Headers', $this->getRunningClient()->getInternalResponse()->getHeaders());
}

public function makeHtmlSnapshot($name = null)
public function makeHtmlSnapshot(string $name = null): void
{
if (empty($name)) {
$name = uniqid(date("Y-m-d_H-i-s_"), true);
Expand Down Expand Up @@ -1499,7 +1499,7 @@ public function grabAttributeFrom($cssOrXpath, $attribute)
return $nodes->first()->attr($attribute);
}

public function grabMultiple($cssOrXpath, $attribute = null)
public function grabMultiple($cssOrXpath, string $attribute = null): array
{
$result = [];
$nodes = $this->match($cssOrXpath);
Expand Down Expand Up @@ -1584,7 +1584,7 @@ public function grabCookie($cookie, $params = [])
* @throws ModuleException if no page was opened.
* @return string Current page source code.
*/
public function grabPageSource()
public function grabPageSource(): string
{
return $this->_getResponseContent();
}
Expand Down Expand Up @@ -1619,7 +1619,7 @@ private function stringifySelector($selector): string
return $selector;
}

public function seeElement($selector, $attributes = [])
public function seeElement($selector, array $attributes = []): void
{
$nodes = $this->match($selector);
$selector = $this->stringifySelector($selector);
Expand All @@ -1631,7 +1631,7 @@ public function seeElement($selector, $attributes = [])
$this->assertDomContains($nodes, $selector);
}

public function dontSeeElement($selector, $attributes = [])
public function dontSeeElement($selector, array $attributes = []): void
{
$nodes = $this->match($selector);
$selector = $this->stringifySelector($selector);
Expand Down