From 8c4b19b495c18670e511f383306648d070bfcfd6 Mon Sep 17 00:00:00 2001 From: Florian Engelhardt Date: Thu, 9 Jul 2020 21:20:22 +0200 Subject: [PATCH] OXDEV-3559 Add codeception tests --- .../Acceptance/CategoryQueryCest.php | 38 +++++++++++++++++++ tests/Codeception/_output/.gitignore | 2 + .../Codeception/_support/AcceptanceTester.php | 35 +++++++++++++++++ .../_support/Helper/Acceptance.php | 23 +++++++++++ .../_support/_generated/.gitignore | 2 + tests/Codeception/acceptance.suite.yml | 10 +++++ tests/Codeception/codeception.yml | 10 +++++ tests/Codeception/params.php | 16 ++++++++ tests/codeception.yml | 21 ++++++++++ 9 files changed, 157 insertions(+) create mode 100644 tests/Codeception/Acceptance/CategoryQueryCest.php create mode 100644 tests/Codeception/_output/.gitignore create mode 100644 tests/Codeception/_support/AcceptanceTester.php create mode 100644 tests/Codeception/_support/Helper/Acceptance.php create mode 100644 tests/Codeception/_support/_generated/.gitignore create mode 100644 tests/Codeception/acceptance.suite.yml create mode 100644 tests/Codeception/codeception.yml create mode 100644 tests/Codeception/params.php create mode 100644 tests/codeception.yml diff --git a/tests/Codeception/Acceptance/CategoryQueryCest.php b/tests/Codeception/Acceptance/CategoryQueryCest.php new file mode 100644 index 0000000..5e56ed3 --- /dev/null +++ b/tests/Codeception/Acceptance/CategoryQueryCest.php @@ -0,0 +1,38 @@ +haveHTTPHeader('Content-Type', 'application/json'); + $I->sendPOST('/widget.php?cl=graphql', [ + 'query' => 'query { + category (id: "943a9ba3050e78b443c16e043ae60ef3") { + id + title + } + }' + ]); + $I->seeResponseCodeIs(\Codeception\Util\HttpCode::OK); + $I->seeResponseIsJson(); + $I->seeResponseContainsJson([ + 'data' => [ + 'category' => [ + 'id' => '943a9ba3050e78b443c16e043ae60ef3', + 'title' => 'Kiteboarding' + ] + ] + ]); + } +} diff --git a/tests/Codeception/_output/.gitignore b/tests/Codeception/_output/.gitignore new file mode 100644 index 0000000..c96a04f --- /dev/null +++ b/tests/Codeception/_output/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/tests/Codeception/_support/AcceptanceTester.php b/tests/Codeception/_support/AcceptanceTester.php new file mode 100644 index 0000000..45bfa95 --- /dev/null +++ b/tests/Codeception/_support/AcceptanceTester.php @@ -0,0 +1,35 @@ +getShopRootPath() . '/bin/oe-console oe:module:activate oe/graphql-base'); + exec((new Facts())->getShopRootPath() . '/bin/oe-console oe:module:activate __PackageFull__'); + } +} diff --git a/tests/Codeception/_support/_generated/.gitignore b/tests/Codeception/_support/_generated/.gitignore new file mode 100644 index 0000000..c96a04f --- /dev/null +++ b/tests/Codeception/_support/_generated/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/tests/Codeception/acceptance.suite.yml b/tests/Codeception/acceptance.suite.yml new file mode 100644 index 0000000..70603ba --- /dev/null +++ b/tests/Codeception/acceptance.suite.yml @@ -0,0 +1,10 @@ +# suite config +actor: AcceptanceTester +path: Acceptance +modules: + enabled: + - \__Vendor__\GraphQL\__Package__\Tests\Codeception\Helper\Acceptance + - REST: + url: '%SHOP_URL%' + depends: PhpBrowser + part: Json diff --git a/tests/Codeception/codeception.yml b/tests/Codeception/codeception.yml new file mode 100644 index 0000000..f0446cc --- /dev/null +++ b/tests/Codeception/codeception.yml @@ -0,0 +1,10 @@ +paths: + tests: tests + output: tests/_output + data: tests/_data + support: tests/_support + envs: tests/_envs +actor_suffix: Tester +extensions: + enabled: + - Codeception\Extension\RunFailed diff --git a/tests/Codeception/params.php b/tests/Codeception/params.php new file mode 100644 index 0000000..42f1ec2 --- /dev/null +++ b/tests/Codeception/params.php @@ -0,0 +1,16 @@ + $facts->getShopUrl(), +]; diff --git a/tests/codeception.yml b/tests/codeception.yml new file mode 100644 index 0000000..32f7b6c --- /dev/null +++ b/tests/codeception.yml @@ -0,0 +1,21 @@ +namespace: __Vendor__\GraphQL\__Package__\Tests\Codeception + +params: + - Codeception/params.php + +paths: + tests: Codeception + output: Codeception/_output + data: Codeception/_data + support: Codeception/_support + envs: Codeception/_envs + actor_suffix: Tester + +settings: + colors: true + log: true + shuffle: true + +extensions: + enabled: + - Codeception\Extension\RunFailed