Skip to content

Commit

Permalink
service provider tests
Browse files Browse the repository at this point in the history
  • Loading branch information
leventcz committed May 18, 2024
1 parent 6aa7f8a commit 53828ab
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 10 deletions.
5 changes: 0 additions & 5 deletions tests/Feature/ExampleTest.php

This file was deleted.

51 changes: 51 additions & 0 deletions tests/ServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

use Illuminate\Config\Repository;
use Illuminate\Contracts\Redis\Factory;
use Illuminate\Foundation\Application;
use Illuminate\Redis\RedisManager;
use Leventcz\Top\Facades\State;
use Leventcz\Top\Facades\Top;
use Leventcz\Top\ServiceProvider;
use Leventcz\Top\StateManager;
use Leventcz\Top\TopManager;

beforeEach(function () {
$this->app = new Application();
$this->app->bind('config', fn() => new Repository());
$this->app->bind(Factory::class, fn() => Mockery::mock(RedisManager::class));
$this->app->register(ServiceProvider::class);
});

afterAll(function () {
Mockery::close();
});

it('ensures top is bound to the container', function () {
expect($this->app->get('top'))
->toBeInstanceOf(TopManager::class);
});

it('ensures top.state bound to the container', function () {
expect($this->app->get('top.state'))
->toBeInstanceOf(StateManager::class);
});

it('ensures top is always singleton', function () {
$top = $this->app->get('top');

expect($this->app->get('top'))->toBe($top);
});

it('ensures top facade resolves correctly', function () {
Top::setFacadeApplication($this->app);

expect(Top::getFacadeRoot())
->toBeInstanceOf(TopManager::class);
});

it('ensures state facade resolves correctly', function () {
State::setFacadeApplication($this->app);

expect(State::getFacadeRoot())->toBeInstanceOf(StateManager::class);
});
5 changes: 0 additions & 5 deletions tests/Unit/ExampleTest.php

This file was deleted.

0 comments on commit 53828ab

Please sign in to comment.