Update tests a little

This commit is contained in:
James Brooks 2018-06-25 22:13:53 +01:00
parent 2dd8199816
commit 06d4964a84
5 changed files with 62 additions and 20 deletions

View File

@ -33,6 +33,8 @@ class AppServiceProvider extends ServiceProvider
* Boot the service provider.
*
* @param \AltThree\Bus\Dispatcher $dispatcher
*
* @return void
*/
public function boot(Dispatcher $dispatcher)
{

View File

@ -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.
*

View File

@ -24,6 +24,11 @@ class AnalysisTest extends TestCase
{
use AnalysisTrait;
/**
* Get the code paths to analyze.
*
* @return string[]
*/
protected function getPaths()
{
return [

View 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;
}
}

View File

@ -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);
}
}