forked from d13r/laravel-breadcrumbs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add 'manager-class' and 'generator-class' config options
- Loading branch information
Showing
5 changed files
with
147 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace BreadcrumbsTests; | ||
|
||
use Breadcrumbs; | ||
use Config; | ||
use DaveJamesMiller\Breadcrumbs\BreadcrumbsGenerator; | ||
use DaveJamesMiller\Breadcrumbs\BreadcrumbsManager; | ||
use Illuminate\Support\Collection; | ||
use Route; | ||
use URL; | ||
|
||
class CustomGeneratorTest extends TestCase | ||
{ | ||
protected function resolveApplicationConfiguration($app) | ||
{ | ||
parent::resolveApplicationConfiguration($app); | ||
|
||
// Need to inject this early, before the package is loaded, to simulate it being set in the config file | ||
$app['config']['breadcrumbs.generator-class'] = CustomGenerator::class; | ||
} | ||
|
||
public function testCustomGenerator() | ||
{ | ||
$breadcrumbs = Breadcrumbs::generate(); | ||
|
||
$this->assertSame('custom-generator', $breadcrumbs[0]); | ||
} | ||
} | ||
|
||
class CustomGenerator extends BreadcrumbsGenerator | ||
{ | ||
public function generate(array $callbacks, array $before, array $after, string $name, array $params): Collection | ||
{ | ||
return new Collection(['custom-generator']); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace BreadcrumbsTests; | ||
|
||
use Breadcrumbs; | ||
use Config; | ||
use DaveJamesMiller\Breadcrumbs\BreadcrumbsGenerator; | ||
use DaveJamesMiller\Breadcrumbs\BreadcrumbsManager; | ||
use Illuminate\Support\Collection; | ||
use Route; | ||
use URL; | ||
|
||
class CustomManagerTest extends TestCase | ||
{ | ||
protected function resolveApplicationConfiguration($app) | ||
{ | ||
parent::resolveApplicationConfiguration($app); | ||
|
||
// Need to inject this early, before the package is loaded, to simulate it being set in the config file | ||
$app['config']['breadcrumbs.manager-class'] = CustomManager::class; | ||
} | ||
|
||
public function testCustomManager() | ||
{ | ||
$breadcrumbs = Breadcrumbs::generate(); | ||
|
||
$this->assertSame('custom-manager', $breadcrumbs[0]); | ||
} | ||
} | ||
|
||
class CustomManager extends BreadcrumbsManager | ||
{ | ||
public function generate(string $name = null, ...$params): Collection | ||
{ | ||
return new Collection(['custom-manager']); | ||
} | ||
} |