Skip to content
This repository has been archived by the owner on Sep 3, 2024. It is now read-only.

Commit

Permalink
requested changes and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
p-zielinski committed Jan 24, 2024
1 parent 3f2abe5 commit d9869f4
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 94 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ build/phplint.cache
/test-requirements.txt
/.env
/.idea/
/__tests__/_generated/
/__tests__/_output/
/__tests__/Support/
16 changes: 0 additions & 16 deletions __tests__/Acceptance.suite.yml

This file was deleted.

12 changes: 0 additions & 12 deletions __tests__/Functional.suite.yml

This file was deleted.

54 changes: 54 additions & 0 deletions __tests__/README_TESTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
## Tool:
We use `codeception` for testing. You shall have installed `codeception` via `composer` in order to run the tests.


## How to write tests:
All tests shall be in `__tests__/Unit/` folder. And shall be named as `*Test.php`. All test functions shall be named as `test*` (see example).

Import sdk:

```php
require_once(dirname(dirname(__DIR__)) . '/vendor/autoload.php');
```

Good practice is to use `_before` to configure sdks APIs:
```php

//example
protected function _before()
{
//load .env
$env = parse_ini_file('.env');

$config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setApiKey('X-App-Id', $env["X_APP_ID"]);
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setApiKey('X-App-Token', $env["X_APP_TOKEN"]);
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setHost($env["VOUCHERIFY_HOST"]);

$this->productsApiInstance = new OpenAPI\Client\Api\ProductsApi(
new GuzzleHttp\Client(),
$config
);
$this->campaignsApiInstance = new OpenAPI\Client\Api\CampaignsApi(
new GuzzleHttp\Client(),
$config
);
$this->redemptionsApiInstance = new OpenAPI\Client\Api\RedemptionsApi(
new GuzzleHttp\Client(),
$config
);
}

```

Test example:
```php
//example
public function testListRedemptions()
{
$this->redemptionsApiInstance->listRedemptions(1, 1);
}
```


## Environment variables:
`.env` file shall be in the root of the project and shall contain `X_APP_ID`, `X_APP_TOKEN` and `VOUCHERIFY_HOST` variables. Check `.env.example` for reference.
29 changes: 0 additions & 29 deletions __tests__/Support/AcceptanceTester.php

This file was deleted.

Empty file removed __tests__/Support/Data/.gitkeep
Empty file.
29 changes: 0 additions & 29 deletions __tests__/Support/FunctionalTester.php

This file was deleted.

2 changes: 0 additions & 2 deletions __tests__/Support/_generated/.gitignore

This file was deleted.

File renamed without changes.
2 changes: 0 additions & 2 deletions __tests__/_output/.gitignore

This file was deleted.

4 changes: 2 additions & 2 deletions codeception.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ support_namespace: Support
paths:
tests: __tests__
output: __tests__/_output
data: __tests__/Support/Data
support: __tests__/Support
data: __tests__/SupportData
support: __tests__
envs: .env
actor_suffix: Tester
extensions:
Expand Down
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
},
"require-dev": {
"codeception/codeception": "^5.0",
"codeception/module-phpbrowser": "*",
"codeception/module-asserts": "*"
},
"autoload": {
Expand All @@ -46,4 +45,4 @@
],
"phplint": "phplint"
}
}
}

0 comments on commit d9869f4

Please sign in to comment.