OXDEV-3559 Add codeception tests

Cette révision appartient à :
Florian Engelhardt 2020-07-09 21:20:22 +02:00
Parent cfb85dacad
révision 8c4b19b495
Signature inconnue de Gitea
ID de la clé GPG: 39B8DAD75A95B500
9 fichiers modifiés avec 157 ajouts et 0 suppressions

Voir le fichier

@ -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 externe Fichier normal
Voir le fichier

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

Voir le fichier

@ -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
*/
}

Voir le fichier

@ -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__');
}
}

Voir le fichier

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

Voir le fichier

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

Voir le fichier

@ -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 Fichier normal
Voir le fichier

@ -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 Fichier normal
Voir le fichier

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