mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-11-26 16:52:04 +05:30
First commit of API tests
This commit is contained in:
parent
e43bdc837c
commit
d065549e95
18
tests/codecept/codeception.yml
Normal file
18
tests/codecept/codeception.yml
Normal file
@ -0,0 +1,18 @@
|
||||
paths:
|
||||
tests: tests
|
||||
log: tests/_log
|
||||
data: tests/_data
|
||||
helpers: tests/_helpers
|
||||
settings:
|
||||
bootstrap: _bootstrap.php
|
||||
suite_class: \PHPUnit_Framework_TestSuite
|
||||
colors: true
|
||||
memory_limit: 1024M
|
||||
log: true
|
||||
modules:
|
||||
config:
|
||||
Db:
|
||||
dsn: ''
|
||||
user: ''
|
||||
password: ''
|
||||
dump: tests/_data/dump.sql
|
2
tests/codecept/tests/_bootstrap.php
Normal file
2
tests/codecept/tests/_bootstrap.php
Normal file
@ -0,0 +1,2 @@
|
||||
<?php
|
||||
// This is global bootstrap for autoloading
|
8
tests/codecept/tests/_helpers/ApiHelper.php
Normal file
8
tests/codecept/tests/_helpers/ApiHelper.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
namespace Codeception\Module;
|
||||
|
||||
// here you can define custom functions for ApiGuy
|
||||
|
||||
class ApiHelper extends \Codeception\Module
|
||||
{
|
||||
}
|
8
tests/codecept/tests/api.suite.yml
Normal file
8
tests/codecept/tests/api.suite.yml
Normal file
@ -0,0 +1,8 @@
|
||||
class_name: ApiGuy
|
||||
modules:
|
||||
enabled: [PhpBrowser, REST, ApiHelper]
|
||||
config:
|
||||
PhpBrowser:
|
||||
url: http://localhost:8000/
|
||||
REST:
|
||||
url: http://localhost:8000/
|
2918
tests/codecept/tests/api/ApiGuy.php
Normal file
2918
tests/codecept/tests/api/ApiGuy.php
Normal file
File diff suppressed because it is too large
Load Diff
20
tests/codecept/tests/api/GetUsersAllFieldsCept.php
Normal file
20
tests/codecept/tests/api/GetUsersAllFieldsCept.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
$I = new ApiGuy($scenario);
|
||||
$I->wantTo('get all users with all fields');
|
||||
$I->sendGET('api.php/users?access_token=iamgod');
|
||||
$I->seeResponseCodeIs(200);
|
||||
$I->seeResponseIsJson();
|
||||
$I->seeResponseContainsJson([
|
||||
[
|
||||
'username' => 'alexbilbie',
|
||||
'name' => 'Alex Bilbie',
|
||||
'email' => 'hello@alexbilbie.com',
|
||||
'photo' => 'https://s.gravatar.com/avatar/14902eb1dac66b8458ebbb481d80f0a3'
|
||||
],
|
||||
[
|
||||
'username' => 'philsturgeon',
|
||||
'name' => 'Phil Sturgeon',
|
||||
'email' => 'email@philsturgeon.co.uk',
|
||||
'photo' => 'https://s.gravatar.com/avatar/14df293d6c5cd6f05996dfc606a6a951'
|
||||
]
|
||||
]);
|
18
tests/codecept/tests/api/GetUsersBasicEmailFieldsCept.php
Normal file
18
tests/codecept/tests/api/GetUsersBasicEmailFieldsCept.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
$I = new ApiGuy($scenario);
|
||||
$I->wantTo('get all users with all basic and email fields');
|
||||
$I->sendGET('api.php/users?access_token=iamphil');
|
||||
$I->seeResponseCodeIs(200);
|
||||
$I->seeResponseIsJson();
|
||||
$I->seeResponseContainsJson([
|
||||
[
|
||||
'username' => 'alexbilbie',
|
||||
'name' => 'Alex Bilbie',
|
||||
'email' => 'hello@alexbilbie.com'
|
||||
],
|
||||
[
|
||||
'username' => 'philsturgeon',
|
||||
'name' => 'Phil Sturgeon',
|
||||
'email' => 'email@philsturgeon.co.uk'
|
||||
]
|
||||
]);
|
18
tests/codecept/tests/api/GetUsersBasicPhotoFieldsCept.php
Normal file
18
tests/codecept/tests/api/GetUsersBasicPhotoFieldsCept.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
$I = new ApiGuy($scenario);
|
||||
$I->wantTo('get all users with basic and photo fields');
|
||||
$I->sendGET('api.php/users?access_token=iamalex');
|
||||
$I->seeResponseCodeIs(200);
|
||||
$I->seeResponseIsJson();
|
||||
$I->seeResponseContainsJson([
|
||||
[
|
||||
'username' => 'alexbilbie',
|
||||
'name' => 'Alex Bilbie',
|
||||
'photo' => 'https://s.gravatar.com/avatar/14902eb1dac66b8458ebbb481d80f0a3'
|
||||
],
|
||||
[
|
||||
'username' => 'philsturgeon',
|
||||
'name' => 'Phil Sturgeon',
|
||||
'photo' => 'https://s.gravatar.com/avatar/14df293d6c5cd6f05996dfc606a6a951'
|
||||
]
|
||||
]);
|
6
tests/codecept/tests/api/GetUsersInvalidTokenCept.php
Normal file
6
tests/codecept/tests/api/GetUsersInvalidTokenCept.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
$I = new ApiGuy($scenario);
|
||||
$I->wantTo('get all users with an invalid access token');
|
||||
$I->sendGET('api.php/users?access_token=foobar');
|
||||
$I->seeResponseCodeIs(401);
|
||||
$I->seeResponseIsJson();
|
6
tests/codecept/tests/api/GetUsersNoTokenCept.php
Normal file
6
tests/codecept/tests/api/GetUsersNoTokenCept.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
$I = new ApiGuy($scenario);
|
||||
$I->wantTo('get all users without an access token');
|
||||
$I->sendGET('api.php/users');
|
||||
$I->seeResponseCodeIs(400);
|
||||
$I->seeResponseIsJson();
|
2
tests/codecept/tests/api/_bootstrap.php
Normal file
2
tests/codecept/tests/api/_bootstrap.php
Normal file
@ -0,0 +1,2 @@
|
||||
<?php
|
||||
// Here you can initialize variables that will for your tests
|
Loading…
Reference in New Issue
Block a user