-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'unit_tests' into 'main'
tests: init See merge request ecphp/laravel-ecas!2
- Loading branch information
Showing
11 changed files
with
266 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
/vendor | ||
composer.lock | ||
.php_cs.cache | ||
.phpunit.result.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd" | ||
bootstrap="tests/bootstrap.php" | ||
colors="true" | ||
> | ||
<testsuites> | ||
|
||
<testsuite name="LaravelCas"> | ||
<directory suffix="Test.php">./tests</directory> | ||
</testsuite> | ||
|
||
</testsuites> | ||
<coverage/> | ||
<php> | ||
<server name="APP_ENV" value="testing"/> | ||
<server name="APP_KEY" value="O2lsv1gg9Guol7e4BlrxbCmM3aY5jzJt"/> | ||
<server name="BCRYPT_ROUNDS" value="4"/> | ||
<server name="CACHE_DRIVER" value="array"/> | ||
<!-- <server name="DB_CONNECTION" value="sqlite"/> --> | ||
<!-- <server name="DB_DATABASE" value=":memory:"/> --> | ||
<server name="MAIL_MAILER" value="array"/> | ||
<server name="QUEUE_CONNECTION" value="sync"/> | ||
<server name="SESSION_DRIVER" value="array"/> | ||
<server name="TELESCOPE_ENABLED" value="false"/> | ||
</php> | ||
<source> | ||
<include> | ||
<directory suffix=".php">./app</directory> | ||
</include> | ||
</source> | ||
</phpunit> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
/** | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
* | ||
* @see https://github.com/ecphp | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace EcPhp\LaravelEcas\Tests\Providers; | ||
|
||
use GuzzleHttp\Client; | ||
// use Illuminate\Support\ServiceProvider; | ||
use loophp\psr17\Psr17; | ||
use loophp\psr17\Psr17Interface; | ||
use Nyholm\Psr7\Factory\Psr17Factory; | ||
use Orchestra\Workbench\WorkbenchServiceProvider as ServiceProvider; | ||
use Psr\Http\Client\ClientInterface; | ||
|
||
class LaravelCasProvider extends ServiceProvider | ||
{ | ||
/** | ||
* Bootstrap any application services. | ||
*/ | ||
public function boot(): void {} | ||
|
||
/** | ||
* Register any application services. | ||
*/ | ||
public function register(): void | ||
{ | ||
$this->app->bind(ClientInterface::class, static function ($app, $params = []) { | ||
if (!empty($params) && isset($params['handler'])) { | ||
return new Client(['handler' => $params['handler']]); | ||
} | ||
|
||
return new Client(); | ||
}); | ||
$this->app->bind(Psr17Interface::class, static function ($app) { | ||
$requestFactory = $responseFactory = $streamFactory = $uploadedFileFactory = $uriFactory = $serverRequestFactory = new Psr17Factory(); | ||
|
||
return new Psr17($requestFactory, $responseFactory, $streamFactory, $uploadedFileFactory, $uriFactory, $serverRequestFactory); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
/** | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
* | ||
* @see https://github.com/ecphp | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace EcPhp\LaravelEcas\Tests; | ||
|
||
use EcPhp\LaravelCas\Providers\AppServiceProvider; | ||
use EcPhp\LaravelEcas\Providers\LaravelEcasProvider; | ||
use EcPhp\LaravelEcas\Tests\Providers\LaravelCasProvider; | ||
use Orchestra\Testbench\TestCase as OrchestraTestCase; | ||
|
||
use function dirname; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
abstract class TestCase extends OrchestraTestCase | ||
{ | ||
/** | ||
* Get application package providers. | ||
* | ||
* @param \Illuminate\Foundation\Application $app | ||
* | ||
* @return array | ||
*/ | ||
protected function getPackageProviders($app) | ||
{ | ||
$config = include dirname(__DIR__) . '/vendor/ecphp/laravel-cas/src/publishers/config/laravel-cas.php'; | ||
config(['laravel-cas' => $config]); | ||
|
||
return [ | ||
AppServiceProvider::class, | ||
LaravelCasProvider::class, | ||
LaravelEcasProvider::class, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
/** | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
* | ||
* @see https://github.com/ecphp | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Unit; | ||
|
||
use EcPhp\CasLib\Contract\CasInterface; | ||
use EcPhp\Ecas\Ecas; | ||
use EcPhp\LaravelEcas\Tests\TestCase; | ||
|
||
/** | ||
* @internal | ||
* | ||
* @coversNothing | ||
*/ | ||
final class CasInterfaceTest extends TestCase | ||
{ | ||
private $response; | ||
|
||
public function testIfEcas() | ||
{ | ||
$casInterface = app()->make(CasInterface::class); | ||
self::assertInstanceOf(Ecas::class, $casInterface); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
/** | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
* | ||
* @see https://github.com/ecphp | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Unit; | ||
|
||
use EcPhp\LaravelEcas\Tests\TestCase; | ||
|
||
/** | ||
* @internal | ||
* | ||
* @coversNothing | ||
*/ | ||
final class ProxyCallBackControllerTest extends TestCase | ||
{ | ||
private $response; | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
$this->response = $this->get(route('laravel-cas-proxy-callback')); | ||
} | ||
|
||
public function testIfNotFalse() | ||
{ | ||
self::assertNotFalse($this->response); | ||
} | ||
|
||
public function testIfXml() | ||
{ | ||
$xml = '<?xml version="1.0" encoding="utf-8"?><proxySuccess xmlns="http://www.yale.edu/tp/casClient" />'; | ||
self::assertEquals($xml, $this->response->getContent()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
/** | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
* | ||
* @see https://github.com/ecphp | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Register The Composer Auto Loader | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Composer provides a convenient, automatically generated class loader | ||
| for our application. We just need to utilize it! We'll require it | ||
| into the script here so that we do not have to worry about the | ||
| loading of any our classes "manually". Feels great to relax. | ||
| | ||
*/ | ||
|
||
require __DIR__ . '/../vendor/autoload.php'; | ||
// require __DIR__ . '/helpers.php'; | ||
// require __DIR__ . '/../src/Helpers/helpers.php'; | ||
|
||
use Carbon\Carbon; | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Set The Default Timezone | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Here we will set the default timezone for PHP. PHP is notoriously mean | ||
| if the timezone is not explicitly set. This will be used by each of | ||
| the PHP date and date-time functions throughout the application. | ||
| | ||
*/ | ||
|
||
date_default_timezone_set('UTC'); | ||
|
||
Carbon::setTestNow(Carbon::now()); |