-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(tests): refactor acceptance tests
- Loading branch information
1 parent
adf188b
commit 6bb021e
Showing
5 changed files
with
176 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the package dmind/cookieman. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Dmind\Cookieman\Tests\Acceptance\Frontend; | ||
|
||
use Codeception\Exception\ModuleException; | ||
use Dmind\Cookieman\Tests\Acceptance\Support\AcceptanceTester; | ||
use Dmind\Cookieman\Tests\Acceptance\Support\Constants; | ||
use Exception; | ||
|
||
/** | ||
* Tests clicking through some frontend pages | ||
*/ | ||
class JavaScriptApiCest | ||
{ | ||
/** | ||
* @param AcceptanceTester $I | ||
* @throws ModuleException | ||
* @throws Exception | ||
*/ | ||
public function onScriptLoadedEventHandler(AcceptanceTester $I) | ||
{ | ||
$I->amOnPage(Constants::PATH_root); | ||
$I->setCookie( | ||
Constants::COOKIENAME, | ||
$this->cookieValueForGroups( | ||
[Constants::GROUP_keyMandatory, Constants::GROUP_keyTestgroup] | ||
) | ||
); | ||
$I->reloadPage(); | ||
|
||
// test onScriptLoaded() (once as a callback and once when already loaded) | ||
foreach ([0, 1] as $iScript) { | ||
$onScriptLoadedArgs = [Constants::TRACKINGOBJECT_inTestgroupWith2Scripts, $iScript]; | ||
$I->executeJS( | ||
Constants::JS_onScriptLoaded, | ||
$onScriptLoadedArgs | ||
); | ||
$I->waitForText($onScriptLoadedArgs[0] . ':' . $onScriptLoadedArgs[1] . ' loaded'); | ||
} | ||
} | ||
|
||
/** | ||
* @param array $groupKeys | ||
* @return string | ||
*/ | ||
protected function cookieValueForGroups(array $groupKeys) | ||
{ | ||
return implode(Constants::COOKIE_separator, $groupKeys); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.