Skip to content

Commit eca9e8a

Browse files
committed
Add basic tests
1 parent 94a43a1 commit eca9e8a

File tree

4 files changed

+105
-1
lines changed

4 files changed

+105
-1
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
!empty
22
vendor/
3-
plugins/
3+
plugins/
4+
composer.lock

phpunit.xml.dist

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit
3+
backupGlobals="false"
4+
backupStaticAttributes="false"
5+
colors="true"
6+
processIsolation="false"
7+
stopOnFailure="false"
8+
syntaxCheck="false"
9+
bootstrap="./tests/bootstrap.php"
10+
>
11+
12+
<testsuites>
13+
<testsuite name="OAuth Server Test Suite">
14+
<directory>./tests/TestCase</directory>
15+
</testsuite>
16+
</testsuites>
17+
18+
<!-- Setup a listener for fixtures -->
19+
<listeners>
20+
<listener
21+
class="\Cake\TestSuite\Fixture\FixtureInjector"
22+
file="./vendor/cakephp/cakephp/src/TestSuite/Fixture/FixtureInjector.php">
23+
<arguments>
24+
<object class="\Cake\TestSuite\Fixture\FixtureManager"/>
25+
</arguments>
26+
</listener>
27+
</listeners>
28+
29+
<!-- Prevent coverage reports from looking in tests and vendors -->
30+
<filter>
31+
<blacklist>
32+
<directory suffix=".php">./vendor/</directory>
33+
<directory suffix=".ctp">./vendor/</directory>
34+
35+
<directory suffix=".php">./tests/</directory>
36+
<directory suffix=".ctp">./tests/</directory>
37+
</blacklist>
38+
</filter>
39+
40+
</phpunit>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
namespace OAuth\Test\TestCase\Auth;
3+
4+
use Cake\TestSuite\TestCase;
5+
6+
class OAuthAuthenticateTest extends TestCase {
7+
8+
}

tests/bootstrap.php

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
use Cake\Core\Configure;
3+
use Cake\Core\Plugin;
4+
use Cake\Datasource\ConnectionManager;
5+
6+
$findRoot = function ($root) {
7+
do {
8+
$lastRoot = $root;
9+
$root = dirname($root);
10+
if (is_dir($root . '/vendor/cakephp/cakephp')) {
11+
return $root;
12+
}
13+
} while ($root !== $lastRoot);
14+
throw new Exception('Cannot find the root of the application, unable to run tests');
15+
};
16+
$root = $findRoot(__FILE__);
17+
unset($findRoot);
18+
chdir($root);
19+
require_once 'vendor/cakephp/cakephp/src/basics.php';
20+
require_once 'vendor/autoload.php';
21+
define('ROOT', $root . DS . 'tests' . DS . 'test_app' . DS);
22+
define('APP', ROOT . 'App' . DS);
23+
define('TMP', sys_get_temp_dir() . DS);
24+
Configure::write('debug', true);
25+
Configure::write('App', [
26+
'namespace' => 'App',
27+
'paths' => [
28+
'plugins' => [ROOT . 'Plugin' . DS],
29+
'templates' => [ROOT . 'App' . DS . 'Template' . DS]
30+
]
31+
]);
32+
Cake\Cache\Cache::config([
33+
'_cake_core_' => [
34+
'engine' => 'File',
35+
'prefix' => 'cake_core_',
36+
'serialize' => true,
37+
'path' => '/tmp',
38+
],
39+
'_cake_model_' => [
40+
'engine' => 'File',
41+
'prefix' => 'cake_model_',
42+
'serialize' => true,
43+
'path' => '/tmp',
44+
]
45+
]);
46+
if (!getenv('db_dsn')) {
47+
putenv('db_dsn=sqlite:///:memory:');
48+
}
49+
if (!getenv('DB')) {
50+
putenv('DB=sqlite');
51+
}
52+
ConnectionManager::config('test', ['url' => getenv('db_dsn')]);
53+
Plugin::load('OAuth', [
54+
'path' => dirname(dirname(__FILE__)) . DS,
55+
]);

0 commit comments

Comments
 (0)