Updated tests

This commit is contained in:
Graham Campbell
2015-12-06 11:04:02 +00:00
parent 036c819922
commit 19e3804227
42 changed files with 340 additions and 412 deletions
+7 -59
View File
@@ -11,67 +11,15 @@
namespace CachetHQ\Tests\Cachet\Providers;
use CachetHQ\Cachet\Providers\EventServiceProvider;
use AltThree\TestBench\EventServiceProviderTrait;
use CachetHQ\Tests\Cachet\AbstractTestCase;
use GrahamCampbell\TestBenchCore\LaravelTrait;
use GrahamCampbell\TestBenchCore\ServiceProviderTrait;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use ReflectionClass;
/**
* This is the event service provider test class.
*
* @author Graham Campbell <graham@alt-three.com>
*/
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));
}
use EventServiceProviderTrait;
}