8
0

OXDEV-3559 Add codeception tests

Dieser Commit ist enthalten in:
Florian Engelhardt 2020-07-09 21:20:22 +02:00
Ursprung cfb85dacad
Commit 8c4b19b495
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 39B8DAD75A95B500
9 geänderte Dateien mit 157 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,38 @@
<?php
/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/
declare(strict_types=1);
namespace __Vendor__\GraphQL\__Package__\Tests\Codeception\Acceptance;
use __Vendor__\GraphQL\__Package__\Tests\Codeception\AcceptanceTester;
class CategoryQueryCest
{
public function testFetchSingleCategoryById(AcceptanceTester $I): void
{
$I->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'
]
]
]);
}
}

2
tests/Codeception/_output/.gitignore vendored Normale Datei
Datei anzeigen

@ -0,0 +1,2 @@
*
!.gitignore

Datei anzeigen

@ -0,0 +1,35 @@
<?php
/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/
declare(strict_types=1);
namespace __Vendor__\GraphQL\__Package__\Tests\Codeception;
/**
* Inherited Methods
*
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
*
* @SuppressWarnings(PHPMD)
*/
class AcceptanceTester extends \Codeception\Actor
{
use _generated\AcceptanceTesterActions;
/*
* Define custom actions here
*/
}

Datei anzeigen

@ -0,0 +1,23 @@
<?php
/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/
declare(strict_types=1);
namespace __Vendor__\GraphQL\__Package__\Tests\Codeception\Helper;
use OxidEsales\Facts\Facts;
// here you can define custom actions
// all public methods declared in helper class will be available in $I
class Acceptance extends \Codeception\Module
{
public function _beforeSuite($settings = []) {
exec((new Facts())->getShopRootPath() . '/bin/oe-console oe:module:activate oe/graphql-base');
exec((new Facts())->getShopRootPath() . '/bin/oe-console oe:module:activate __PackageFull__');
}
}

Datei anzeigen

@ -0,0 +1,2 @@
*
!.gitignore

Datei anzeigen

@ -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

Datei anzeigen

@ -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

16
tests/Codeception/params.php Normale Datei
Datei anzeigen

@ -0,0 +1,16 @@
<?php
/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/
declare(strict_types=1);
use OxidEsales\Facts\Facts;
$facts = new Facts();
return [
'SHOP_URL' => $facts->getShopUrl(),
];

21
tests/codeception.yml Normale Datei
Datei anzeigen

@ -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