Skip to content

Commit 7b0b3d0

Browse files
committed
wip
1 parent 8853c32 commit 7b0b3d0

10 files changed

+85
-69
lines changed

database/factories/ModelFactory.php

Lines changed: 0 additions & 19 deletions
This file was deleted.

database/migrations/create_nativephp_laravel_table.php.stub

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/Facades/GlobalShortcut.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Native\Laravel\Facades;
4+
5+
use Illuminate\Support\Facades\Facade;
6+
7+
class GlobalShortcut extends Facade
8+
{
9+
protected static function getFacadeAccessor()
10+
{
11+
return \Native\Laravel\GlobalShortcut::class;
12+
}
13+
}

src/GlobalShortcut.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ public function __construct(protected Client $client)
1414
{
1515
}
1616

17-
public static function new()
18-
{
19-
return new static(new Client());
20-
}
21-
2217
public function key(string $key): self
2318
{
2419
$this->key = $key;

src/NativeServiceProvider.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,6 @@
1111

1212
class NativeServiceProvider extends PackageServiceProvider
1313
{
14-
protected $passThrough = [
15-
'NATIVE_PHP_SECRET',
16-
'NATIVE_PHP_RUNNING',
17-
'NATIVE_PHP_STORAGE_PATH',
18-
'NATIVE_PHP_DATABASE_PATH',
19-
];
20-
2114
public function configurePackage(Package $package): void
2215
{
2316
$package

tests/ArchTest.php

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/ExampleTest.php

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
use Illuminate\Support\Facades\Event;
4+
5+
class TestEvent {
6+
public function __construct(public string $test = '') {
7+
8+
}
9+
}
10+
11+
it('dispatches an event', function() {
12+
Event::fake();
13+
14+
$this->withoutMiddleware()
15+
->post('_native/api/events', [
16+
'event' => TestEvent::class,
17+
])
18+
->assertOk();
19+
20+
Event::assertDispatched(TestEvent::class);
21+
});
22+
23+
it('dispatches no event in case it does not exist', function() {
24+
Event::fake();
25+
26+
$this->withoutMiddleware()
27+
->post('_native/api/events', [
28+
'event' => InvalidEvent::class,
29+
]);
30+
31+
Event::assertNotDispatched(InvalidEvent::class);
32+
});
33+
34+
it('passes the payload to the event', function() {
35+
Event::fake();
36+
37+
$this->withoutMiddleware()
38+
->post('_native/api/events', [
39+
'event' => TestEvent::class,
40+
'payload' => [
41+
'test' => 'Some payload string'
42+
]
43+
]);
44+
45+
Event::assertDispatched(TestEvent::class, function ($event) {
46+
return $event->test === 'Some payload string';
47+
});
48+
});
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
use Illuminate\Support\Facades\Event;
4+
use Native\Laravel\Events\App\ApplicationBooted;
5+
6+
class TestProvider {
7+
public function boot() {
8+
9+
}
10+
}
11+
12+
it('boots the NativePHP provider', function () {
13+
Event::fake();
14+
15+
config([
16+
'nativephp.provider' => TestProvider::class
17+
]);
18+
19+
$this->withoutMiddleware()
20+
->post('_native/api/booted')
21+
->assertOk();
22+
23+
Event::assertDispatched(ApplicationBooted::class);
24+
});

tests/TestCase.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ class TestCase extends Orchestra
1111
protected function setUp(): void
1212
{
1313
parent::setUp();
14-
15-
Factory::guessFactoryNamesUsing(
16-
fn (string $modelName) => 'Native\\Laravel\\Database\\Factories\\'.class_basename($modelName).'Factory'
17-
);
1814
}
1915

2016
protected function getPackageProviders($app)
@@ -27,10 +23,5 @@ protected function getPackageProviders($app)
2723
public function getEnvironmentSetUp($app)
2824
{
2925
config()->set('database.default', 'testing');
30-
31-
/*
32-
$migration = include __DIR__.'/../database/migrations/create_nativephp-laravel_table.php.stub';
33-
$migration->up();
34-
*/
3526
}
3627
}

0 commit comments

Comments
 (0)