Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS has been phased out. To see alternatives please check here

Skip to content
Snippets Groups Projects
Verified Commit 676e326f authored by Bogdan BOCIOACA's avatar Bogdan BOCIOACA Committed by Pol Dellaiera
Browse files

test: init

parent 14ccf1b0
Branches
Tags
1 merge request!2tests: init
......@@ -4,3 +4,4 @@
/vendor
composer.lock
.php_cs.cache
.phpunit.result.cache
......@@ -24,7 +24,12 @@
"require-dev": {
"ecphp/php-conventions": "^1.0",
"guzzlehttp/guzzle": "^7.5",
"phpstan/phpstan-strict-rules": "^1.4"
"phpstan/phpstan-strict-rules": "^1.4",
"orchestra/testbench": "^8.22",
"nyholm/psr7": "^1.5",
"symfony/cache": "^6.2",
"symfony/psr-http-message-bridge": "^2.1"
},
"suggest": {},
"autoload": {
......@@ -32,6 +37,12 @@
"EcPhp\\LaravelEcas\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"EcPhp\\LaravelEcas\\Tests\\": "tests/",
"App\\": "vendor/orchestra/testbench-core/laravel/app"
}
},
"config": {
"allow-plugins": {
"phpstan/extension-installer": true,
......
<?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>
<?php
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
{
/**
* Register any application services.
*
* @return void
*/
public function register(): void
{
//
$this->app->bind(ClientInterface::class, function ($app, $params = [])
{
if (!empty($params) && isset($params['handler']))
{
return new Client(['handler'=>$params['handler']]);
}
return new Client();
});
$this->app->bind(Psr17Interface::class, function ($app)
{
$requestFactory = $responseFactory = $streamFactory = $uploadedFileFactory = $uriFactory = $serverRequestFactory = new Psr17Factory();
return new Psr17($requestFactory, $responseFactory, $streamFactory, $uploadedFileFactory, $uriFactory, $serverRequestFactory);
});
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot(): void
{
}
}
<?php
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;
abstract class TestCase extends OrchestraTestCase
{
/**
* Get application package providers.
*
* @param \Illuminate\Foundation\Application $app
* @return array
*/
protected function getPackageProviders($app)
{
$config = include \dirname(\dirname(__FILE__)) . '/vendor/ecphp/laravel-cas/src/publishers/config/laravel-cas.php';
config(['laravel-cas' => $config]);
return [
AppServiceProvider::class,
LaravelCasProvider::class,
LaravelEcasProvider::class,
];
}
}
<?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;
class CasInterfaceTest extends TestCase
{
private $response;
public function testIfEcas()
{
$casInterface = app()->make(CasInterface::class);
$this->assertInstanceOf(Ecas::class, $casInterface);
}
}
<?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;
class ProxyCallbackControllerTest extends TestCase
{
private $response;
public function setUp(): void
{
parent::setUp();
$this->response = $this->get(route('laravel-cas-proxy-callback'));
}
public function testIfNotFalse()
{
$this->assertNotFalse($this->response);
}
public function testIfXml()
{
$xml = '<?xml version="1.0" encoding="utf-8"?><proxySuccess xmlns="http://www.yale.edu/tp/casClient" />';
$this->assertEquals($xml, $this->response->getContent());
}
}
<?php
/*
|--------------------------------------------------------------------------
| 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());
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment