OXDEV-3559 Add codeception tests

This commit is contained in:
Florian Engelhardt 2020-07-09 21:20:22 +02:00
bovenliggende cfb85dacad
commit 8c4b19b495
Geen bekende sleutel gevonden voor deze handtekening in de database
GPG sleutel-ID: 39B8DAD75A95B500
9 gewijzigde bestanden met toevoegingen van 157 en 0 verwijderingen

Bestand weergeven

@ -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 Normal file
Bestand weergeven

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

Bestand weergeven

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

Bestand weergeven

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

Bestand weergeven

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

Bestand weergeven

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

Bestand weergeven

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

Bestand weergeven

@ -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 Normal file
Bestand weergeven

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