mirror of
https://github.com/CachetHQ/Cachet.git
synced 2025-01-29 02:57:48 +01:00
Update tests a little
This commit is contained in:
parent
2dd8199816
commit
06d4964a84
@ -33,6 +33,8 @@ class AppServiceProvider extends ServiceProvider
|
||||
* Boot the service provider.
|
||||
*
|
||||
* @param \AltThree\Bus\Dispatcher $dispatcher
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot(Dispatcher $dispatcher)
|
||||
{
|
||||
|
@ -14,6 +14,7 @@ namespace CachetHQ\Tests\Cachet;
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
use CachetHQ\Cachet\Settings\Cache;
|
||||
use CachetHQ\Cachet\Settings\Repository;
|
||||
use CachetHQ\Tests\Cachet\CreatesApplicationTrait;
|
||||
use Illuminate\Contracts\Console\Kernel;
|
||||
use Illuminate\Foundation\Testing\TestCase;
|
||||
|
||||
@ -21,15 +22,11 @@ use Illuminate\Foundation\Testing\TestCase;
|
||||
* This is the abstract test case class.
|
||||
*
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
abstract class AbstractTestCase extends TestCase
|
||||
{
|
||||
/**
|
||||
* The base URL to use while testing the application.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $baseUrl = 'http://localhost';
|
||||
use CreatesApplicationTrait;
|
||||
|
||||
/**
|
||||
* Test actor.
|
||||
@ -38,20 +35,6 @@ abstract class AbstractTestCase extends TestCase
|
||||
*/
|
||||
protected $user;
|
||||
|
||||
/**
|
||||
* Creates the application.
|
||||
*
|
||||
* @return \Illuminate\Foundation\Application
|
||||
*/
|
||||
public function createApplication()
|
||||
{
|
||||
$app = require __DIR__.'/../bootstrap/app.php';
|
||||
|
||||
$app->make(Kernel::class)->bootstrap();
|
||||
|
||||
return $app;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sign in an user if it's the case.
|
||||
*
|
||||
|
@ -24,6 +24,11 @@ class AnalysisTest extends TestCase
|
||||
{
|
||||
use AnalysisTrait;
|
||||
|
||||
/**
|
||||
* Get the code paths to analyze.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
protected function getPaths()
|
||||
{
|
||||
return [
|
||||
|
36
tests/CreatesApplicationTrait.php
Normal file
36
tests/CreatesApplicationTrait.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Tests\Cachet;
|
||||
|
||||
use Illuminate\Contracts\Console\Kernel;
|
||||
|
||||
/**
|
||||
* This is the creates application trait.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
trait CreatesApplicationTrait
|
||||
{
|
||||
/**
|
||||
* Creates the application.
|
||||
*
|
||||
* @return \Illuminate\Foundation\Application
|
||||
*/
|
||||
public function createApplication()
|
||||
{
|
||||
$app = require __DIR__.'/../bootstrap/app.php';
|
||||
|
||||
$app->make(Kernel::class)->bootstrap();
|
||||
|
||||
return $app;
|
||||
}
|
||||
}
|
@ -13,13 +13,29 @@ namespace CachetHQ\Tests\Cachet\Foundation\Providers;
|
||||
|
||||
use AltThree\TestBench\EventServiceProviderTrait;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use ReflectionClass;
|
||||
|
||||
/**
|
||||
* This is the event service provider test class.
|
||||
*
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class EventServiceProviderTest extends AbstractTestCase
|
||||
{
|
||||
use EventServiceProviderTrait;
|
||||
|
||||
public function testIsAnEventServiceProvider()
|
||||
{
|
||||
$class = $this->getServiceProviderClass($this->app);
|
||||
|
||||
$reflection = new ReflectionClass($class);
|
||||
|
||||
$provider = new ReflectionClass(ServiceProvider::class);
|
||||
|
||||
$msg = "Expected class '$class' to be a service provider.";
|
||||
|
||||
$this->assertTrue($reflection->isSubclassOf($provider), $msg);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user