Skip to content

Commit

Permalink
Add Delay facade (#3)
Browse files Browse the repository at this point in the history
* Add Delay facade
  • Loading branch information
edgarsn authored Mar 8, 2023
1 parent f57ac02 commit 5074ad4
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 1 deletion.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ composer require newman/laravel-delay

## :book: Usage

### Using as Facade

```php
use Newman\LaravelDelay\Facades\Delay;

// ...

Delay::for(3);
```

### Using as Trait

```php
Expand Down
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@
"laravel": {
"providers": [
"Newman\\LaravelDelay\\DelayServiceProvider"
]
],
"aliases": {
"Delay": "Newman\\LaravelDelay\\Facades\\Delay"
}
}
},
"minimum-stability": "dev",
Expand Down
19 changes: 19 additions & 0 deletions src/Facades/Delay.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

namespace Newman\LaravelDelay\Facades;

use Illuminate\Support\Facades\Facade;
use Newman\LaravelDelay\Contracts\DelayContract;

/**
* @mixin DelayContract
*/
class Delay extends Facade
{
protected static function getFacadeAccessor(): string
{
return DelayContract::class;
}
}
19 changes: 19 additions & 0 deletions tests/FacadeTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

namespace Newman\LaravelDelay\Tests;

use Newman\LaravelDelay\DelayFake;
use Newman\LaravelDelay\Facades\Delay;

class FacadeTest extends TestCase
{
public function test_it_sleeps_through_facade(): void
{
/** @var DelayFake $facade */
$facade = Delay::for(3);

$facade->assertSleep()->assertSleepFor(3);
}
}
8 changes: 8 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Newman\LaravelDelay\Contracts\DelayContract;
use Newman\LaravelDelay\DelayFake;
use Newman\LaravelDelay\DelayServiceProvider;
use Newman\LaravelDelay\Facades\Delay;
use Orchestra\Testbench\TestCase as BaseTestCase;

abstract class TestCase extends BaseTestCase
Expand All @@ -24,4 +25,11 @@ protected function getPackageProviders($app): array
DelayServiceProvider::class,
];
}

protected function getPackageAliases($app): array
{
return [
'Delay' => Delay::class,
];
}
}

0 comments on commit 5074ad4

Please sign in to comment.