Skip to content

Commit

Permalink
Refactor, update tests and snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
shengslogar committed May 23, 2021
1 parent e109770 commit c798236
Show file tree
Hide file tree
Showing 22 changed files with 57 additions and 217 deletions.
6 changes: 3 additions & 3 deletions src/Breadcrumbs.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
* @method static void after(callable $callback)
* @method static bool exists(string $name = NULL)
* @method static \Illuminate\Support\Collection generate(string $name = NULL, ...$params)
* @method static \Illuminate\Support\HtmlString view(string $view, string $name = NULL, ...$params)
* @method static \Illuminate\Support\HtmlString render(string $name = NULL, ...$params)
* @method static \stdClass|null current()
* @method static \Illuminate\Contracts\View\View view(string $view, string $name = NULL, ...$params)
* @method static \Illuminate\Contracts\View\View render(string $name = NULL, ...$params)
* @method static object|null current()
* @method static array getCurrentRoute()
* @method static void setCurrentRoute(string $name, ...$params)
* @method static void clearCurrentRoute()
Expand Down
5 changes: 2 additions & 3 deletions src/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Illuminate\Contracts\View\View;
use Illuminate\Routing\Router;
use Illuminate\Support\Collection;
use Illuminate\Support\HtmlString;
use Illuminate\Support\Traits\Macroable;

/**
Expand Down Expand Up @@ -182,14 +181,14 @@ public function view(string $view, ?string $name = null, ...$params): View
*
* @param string|null $name The name of the current page.
* @param mixed ...$params The parameters to pass to the closure for the current page.
* @return \Illuminate\Support\HtmlString The generated HTML.
* @return \Illuminate\Contracts\View\View The generated view.
* @throws \Diglactic\Breadcrumbs\Exceptions\InvalidBreadcrumbException if the name is (or any ancestor names are)
* not registered.
* @throws \Diglactic\Breadcrumbs\Exceptions\UnnamedRouteException if no name is given and the current route doesn't
* have an associated name.
* @throws \Diglactic\Breadcrumbs\Exceptions\ViewNotSetException if no view has been set.
*/
public function render(?string $name = null, ...$params): HtmlString
public function render(?string $name = null, ...$params): View
{
$view = config('breadcrumbs.view');

Expand Down
6 changes: 4 additions & 2 deletions tests/AdvancedUsageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,10 @@ public function testClearCurrentRoute()

public function testBreadcrumbsSupportForArrowFunctions()
{
Route::name('home')->get('/', function () { });
Route::name('blog.index')->get('/blog', function () { });
Route::name('home')->get('/', function () {
});
Route::name('blog.index')->get('/blog', function () {
});

Breadcrumbs::for('home', function ($trail) {
$trail->push('Some Data')
Expand Down
23 changes: 0 additions & 23 deletions tests/AliasTest.php

This file was deleted.

3 changes: 3 additions & 0 deletions tests/BasicFunctionalityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

class BasicFunctionalityTest extends TestCase
{
/** @var object */
private $post;

protected function setUp(): void
{
parent::setUp();
Expand Down
3 changes: 2 additions & 1 deletion tests/DeferredLoadingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class DeferredLoadingTest extends TestCase
{
protected function getEnvironmentSetUp($app)
protected function getEnvironmentSetUp($app): void
{
parent::getEnvironmentSetUp($app);

Expand Down Expand Up @@ -38,5 +38,6 @@ class DisabledConsoleKernel extends \Orchestra\Testbench\Console\Kernel
{
public function bootstrap()
{
//
}
}
2 changes: 1 addition & 1 deletion tests/FacadePhpDocTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function testFullyQualifiedClassNames($class, $line)
// IDE Helper (v2.4.3) doesn't rewrite class names to FQCNs, so make sure only
// fully qualified class names and built-in types are used in the Manager class
$this->assertRegExp(
'/^(\\\\.*|array|bool|callable|int|mixed|null|string|void)$/',
'/^(\\\\.*|array|object|bool|callable|int|mixed|null|string|void)$/',
$class,
"Must use fully qualified class names in BreadcrumbsManger PhpDoc: $line"
);
Expand Down
2 changes: 1 addition & 1 deletion tests/IgnitionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ private function assertSolutionMatchesSnapshot(ProvidesSolution $exception)
$this->assertMatchesSnapshot($solution->getDocumentationLinks());
}

public function dataOneOrManyConfigFiles()
public function dataOneOrManyConfigFiles(): array
{
return [
'Single config file' => [['routes/breadcrumbs.php']],
Expand Down
2 changes: 1 addition & 1 deletion tests/MultipleFileLoadingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class MultipleFileLoadingTest extends TestCase
{
protected function getEnvironmentSetUp($app)
protected function getEnvironmentSetUp($app): void
{
parent::getEnvironmentSetUp($app);

Expand Down
6 changes: 6 additions & 0 deletions tests/OutputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@

class OutputTest extends TestCase
{
/** @var object */
private $category;

/** @var string */
private $expectedHtml;

protected function setUp(): void
{
parent::setUp();
Expand Down
9 changes: 9 additions & 0 deletions tests/RecursionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@

class RecursionTest extends TestCase
{
/** @var object */
private $category1;

/** @var object */
private $category2;

/** @var object */
private $category3;

protected function setUp(): void
{
parent::setUp();
Expand Down
144 changes: 0 additions & 144 deletions tests/RegisterFunctionTest.php

This file was deleted.

2 changes: 1 addition & 1 deletion tests/SingleFileLoadingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class SingleFileLoadingTest extends TestCase
{
protected function getEnvironmentSetUp($app)
protected function getEnvironmentSetUp($app): void
{
parent::getEnvironmentSetUp($app);

Expand Down
2 changes: 1 addition & 1 deletion tests/SkipFileLoadingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class SkipFileLoadingTest extends TestCase
{
protected function getEnvironmentSetUp($app)
protected function getEnvironmentSetUp($app): void
{
parent::getEnvironmentSetUp($app);

Expand Down
8 changes: 4 additions & 4 deletions tests/TemplatesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,24 @@ public function viewProvider(): Generator
/** @dataProvider viewProvider */
public function testView($view)
{
$html = Breadcrumbs::view("breadcrumbs::$view", 'category', $this->category)->toHtml();
$html = Breadcrumbs::view("breadcrumbs::{$view}", 'category', $this->category)->toHtml();

$this->assertMatchesXmlSnapshot($html);
}

public function testCanResolveFacade()
{
app(Breadcrumbs::class)->for('category', function ($trail, $category) {
resolve('breadcrumbs')->for('foo', function ($trail, $category) {
$trail->parent('blog');
$trail->push($category->title, url("blog/category/{$category->id}"));
});
}

public function testCanReferenceDirectly()
{
\Diglactic\Breadcrumbs\Breadcrumbs::for('category', function (\Diglactic\Breadcrumbs\Generator $trail, $category) {
\Diglactic\Breadcrumbs\Breadcrumbs::for('bar', function (\Diglactic\Breadcrumbs\Generator $trail) {
$trail->parent('blog');
$trail->push($category->title, url("blog/category/{$category->id}"));
$trail->push('Bar', 'some/path');
});
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
For example:


```php
Route::get('blog', function() {
...
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
For example:


```php
Route::get('posts/{post}', 'PostController@edit')->name('sample-name');
```
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
For example:


```php
Route::view('blog', 'page')->name('sample-name');
```

This file was deleted.

This file was deleted.

Loading

0 comments on commit c798236

Please sign in to comment.