This repository was archived by the owner on Jun 28, 2024. It is now read-only.
forked from brozot/Laravel-FCM
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathFCMTestCase.php
51 lines (42 loc) · 1.5 KB
/
FCMTestCase.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
namespace LaravelFCM\Tests;
use Illuminate\Contracts\Console\Kernel;
use Illuminate\Foundation\Testing\TestCase;
use LaravelFCM\FCMServiceProvider;
use PHPUnit\Runner\Version as PHPUnitVersion;
abstract class FCMTestCase extends TestCase
{
public function createApplication()
{
$app = require __DIR__ . '/../vendor/laravel/laravel/bootstrap/app.php';
$app->make(Kernel::class)->bootstrap();
$app->register(FCMServiceProvider::class);
$app['config']['fcm.driver'] = 'http';
$app['config']['fcm.http.timeout'] = 20;
$app['config']['fcm.http.server_send_url'] = 'http://test.test';
$app['config']['fcm.http.server_key'] = 'key=myKey';
$app['config']['fcm.http.sender_id'] = 'SENDER_ID';
return $app;
}
public function getPhpUnitVersion()
{
if (class_exists(PHPUnit_Runner_Version::class)) {
return (int) explode('.', PHPUnit_Runner_Version::id())[0];
}
return (int) explode('.', PHPUnitVersion::id())[0];
}
public function setExceptionExpected($className)
{
if ($this->getPhpUnitVersion() <= 5) {
return $this->setExpectedException($className);
}
return $this->expectException($className);
}
public function setExceptionExpectedMessage($className)
{
if ($this->getPhpUnitVersion() <= 4) {
return $this->setExpectedExceptionRegExp($className);
}
return $this->expectExceptionMessage($className);
}
}