mirror of
https://github.com/CachetHQ/Cachet.git
synced 2025-01-17 05:28:18 +01:00
Added tests for Service Providers
This commit is contained in:
parent
532a7139a3
commit
5b897f18b9
@ -27,11 +27,11 @@ class EventServiceProvider extends ServiceProvider
|
||||
'CachetHQ\Cachet\Events\Incident\MaintenanceWasScheduledEvent' => [
|
||||
'CachetHQ\Cachet\Handlers\Events\Incident\SendMaintenanceEmailNotificationHandler',
|
||||
],
|
||||
'CachetHQ\Cachet\Events\User\UserWasAddedEvent' => [
|
||||
//
|
||||
],
|
||||
'CachetHQ\Cachet\Events\Subscriber\SubscriberHasSubscribedEvent' => [
|
||||
'CachetHQ\Cachet\Handlers\Events\Subscriber\SendSubscriberVerificationEmailHandler',
|
||||
],
|
||||
'CachetHQ\Cachet\Events\User\UserWasAddedEvent' => [
|
||||
//
|
||||
],
|
||||
];
|
||||
}
|
||||
|
@ -39,6 +39,7 @@
|
||||
},
|
||||
"require-dev": {
|
||||
"fzaninotto/faker": "^1.5",
|
||||
"graham-campbell/testbench-core": "^1.0",
|
||||
"mockery/mockery": "^0.9.4",
|
||||
"phpunit/phpunit": "^4.7.6"
|
||||
},
|
||||
|
66
composer.lock
generated
66
composer.lock
generated
@ -4,8 +4,8 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"hash": "4b5a5184752be8d270d8be97d85d26fd",
|
||||
"content-hash": "dc1e35be9fd2c68b8409f2512d3daed6",
|
||||
"hash": "fc32fe7d00a5482612de93c45587ed46",
|
||||
"content-hash": "b614724a941f8e64a4293befaa0852f3",
|
||||
"packages": [
|
||||
{
|
||||
"name": "alt-three/emoji",
|
||||
@ -1665,7 +1665,7 @@
|
||||
"name": "Jeremy Lindblom",
|
||||
"email": "jeremeamia@gmail.com",
|
||||
"homepage": "https://github.com/jeremeamia",
|
||||
"role": "developer"
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "Serialize Closure objects, including their context and binding",
|
||||
@ -3394,6 +3394,66 @@
|
||||
],
|
||||
"time": "2015-05-29 06:29:14"
|
||||
},
|
||||
{
|
||||
"name": "graham-campbell/testbench-core",
|
||||
"version": "v1.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/GrahamCampbell/Laravel-TestBench-Core.git",
|
||||
"reference": "caa22f1bfdd2197443d1f74b2a607c117daa1d23"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/GrahamCampbell/Laravel-TestBench-Core/zipball/caa22f1bfdd2197443d1f74b2a607c117daa1d23",
|
||||
"reference": "caa22f1bfdd2197443d1f74b2a607c117daa1d23",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.5.9"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.7.6"
|
||||
},
|
||||
"suggest": {
|
||||
"illuminate/support": "Required to use the laravel trait.",
|
||||
"mockery/mockery": "Required to use the mockery trait.",
|
||||
"phpunit/phpunit": "Required to use the most of the features."
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"GrahamCampbell\\TestBenchCore\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Graham Campbell",
|
||||
"email": "graham@alt-three.com"
|
||||
}
|
||||
],
|
||||
"description": "TestBench Core Provides Some Testing Functionality For Laravel 5",
|
||||
"keywords": [
|
||||
"Graham Campbell",
|
||||
"GrahamCampbell",
|
||||
"Laravel TestBench Core",
|
||||
"Laravel-TestBench-Core",
|
||||
"TestBench",
|
||||
"framework",
|
||||
"laravel",
|
||||
"testbench-core",
|
||||
"testing"
|
||||
],
|
||||
"time": "2015-06-26 16:35:19"
|
||||
},
|
||||
{
|
||||
"name": "hamcrest/hamcrest-php",
|
||||
"version": "v1.2.2",
|
||||
|
27
tests/Providers/AppServiceProviderTest.php
Normal file
27
tests/Providers/AppServiceProviderTest.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?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\Providers;
|
||||
|
||||
use CachetHQ\Cachet\Providers\AppServiceProvider;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
use GrahamCampbell\TestBenchCore\LaravelTrait;
|
||||
use GrahamCampbell\TestBenchCore\ServiceProviderTrait;
|
||||
|
||||
class AppServiceProviderTest extends AbstractTestCase
|
||||
{
|
||||
use LaravelTrait, ServiceProviderTrait;
|
||||
|
||||
protected function getServiceProviderClass($app)
|
||||
{
|
||||
return AppServiceProvider::class;
|
||||
}
|
||||
}
|
76
tests/Providers/EventServiceProviderTest.php
Normal file
76
tests/Providers/EventServiceProviderTest.php
Normal file
@ -0,0 +1,76 @@
|
||||
<?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\Providers;
|
||||
|
||||
use CachetHQ\Cachet\Providers\EventServiceProvider;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
use GrahamCampbell\TestBenchCore\LaravelTrait;
|
||||
use GrahamCampbell\TestBenchCore\ServiceProviderTrait;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
use ReflectionClass;
|
||||
|
||||
class EventServiceProviderTest extends AbstractTestCase
|
||||
{
|
||||
use LaravelTrait, ServiceProviderTrait;
|
||||
|
||||
protected function getServiceProviderClass($app)
|
||||
{
|
||||
return EventServiceProvider::class;
|
||||
}
|
||||
|
||||
public function testIsAnEventServiceProvider()
|
||||
{
|
||||
$class = $this->getServiceProviderClass($this->app);
|
||||
$reflection = new ReflectionClass($class);
|
||||
$provider = new ReflectionClass(ServiceProvider::class);
|
||||
$msg = "Expected class '$class' to be an event service provider.";
|
||||
$this->assertTrue($reflection->isSubclassOf($provider), $msg);
|
||||
}
|
||||
|
||||
public function testListenerMapIsAnArray()
|
||||
{
|
||||
$map = $this->getListenerMap();
|
||||
$this->assertInternalType('array', $map);
|
||||
$this->assertGreaterThan(0, count($map));
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testListenerMapIsAnArray
|
||||
*/
|
||||
public function testListenerMapEventsExist()
|
||||
{
|
||||
$map = $this->getListenerMap();
|
||||
foreach (array_keys($map) as $event) {
|
||||
$this->assertTrue(class_exists($event));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testListenerMapIsAnArray
|
||||
*/
|
||||
public function testListenerMapKeysAreSorted()
|
||||
{
|
||||
$map = $this->getListenerMap();
|
||||
$events = array_keys($map);
|
||||
sort($events);
|
||||
$this->assertSame($events, array_keys($map));
|
||||
}
|
||||
|
||||
protected function getListenerMap()
|
||||
{
|
||||
$class = $this->getServiceProviderClass($this->app);
|
||||
$reflection = new ReflectionClass($class);
|
||||
$property = $reflection->getProperty('listen');
|
||||
$property->setAccessible(true);
|
||||
return $property->getValue(new $class($this->app));
|
||||
}
|
||||
}
|
33
tests/Providers/RepositoryServiceProviderTest.php
Normal file
33
tests/Providers/RepositoryServiceProviderTest.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?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\Providers;
|
||||
|
||||
use CachetHQ\Cachet\Providers\RepositoryServiceProvider;
|
||||
use CachetHQ\Cachet\Repositories\Metric\MetricRepository;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
use GrahamCampbell\TestBenchCore\LaravelTrait;
|
||||
use GrahamCampbell\TestBenchCore\ServiceProviderTrait;
|
||||
|
||||
class RepositoryServiceProviderTest extends AbstractTestCase
|
||||
{
|
||||
use LaravelTrait, ServiceProviderTrait;
|
||||
|
||||
protected function getServiceProviderClass($app)
|
||||
{
|
||||
return RepositoryServiceProvider::class;
|
||||
}
|
||||
|
||||
public function testMetricRepositoryIsInjectable()
|
||||
{
|
||||
$this->assertIsInjectable(MetricRepository::class);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user