update v 1.0.7.5
This commit is contained in:
29
vendor/davejamesmiller/laravel-breadcrumbs/tests/integration/CustomServiceProviderTest.php
vendored
Normal file
29
vendor/davejamesmiller/laravel-breadcrumbs/tests/integration/CustomServiceProviderTest.php
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
class CustomServiceProviderTest extends TestCase {
|
||||
|
||||
protected function getPackageProviders()
|
||||
{
|
||||
return [
|
||||
'CustomServiceProvider',
|
||||
];
|
||||
}
|
||||
|
||||
public function testRender()
|
||||
{
|
||||
$html = Breadcrumbs::render('home');
|
||||
$this->assertXmlStringEqualsXmlFile(__DIR__ . '/../fixtures/CustomServiceProvider.html', $html);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class CustomServiceProvider extends DaveJamesMiller\Breadcrumbs\ServiceProvider {
|
||||
|
||||
public function registerBreadcrumbs()
|
||||
{
|
||||
Breadcrumbs::register('home', function($breadcrumbs) {
|
||||
$breadcrumbs->push('Home', '/');
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
class DependantServiceProviderErrorTest extends TestCase {
|
||||
|
||||
protected function getPackageProviders()
|
||||
{
|
||||
return [
|
||||
// These are in the wrong order
|
||||
'DependantServiceProviderError',
|
||||
'DaveJamesMiller\Breadcrumbs\ServiceProvider',
|
||||
];
|
||||
}
|
||||
|
||||
protected function loadServiceProvider()
|
||||
{
|
||||
// Disabled - we want to test the automatic loading instead
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException DaveJamesMiller\Breadcrumbs\Exception
|
||||
* @expectedExceptionMessage Breadcrumbs view not specified
|
||||
*/
|
||||
public function testRender()
|
||||
{
|
||||
Breadcrumbs::render('home');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class DependantServiceProviderError extends Illuminate\Support\ServiceProvider {
|
||||
|
||||
public function register()
|
||||
{
|
||||
}
|
||||
|
||||
public function boot()
|
||||
{
|
||||
Breadcrumbs::register('home', function($breadcrumbs) {
|
||||
$breadcrumbs->push('Home', '/');
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
39
vendor/davejamesmiller/laravel-breadcrumbs/tests/integration/DependantServiceProviderTest.php
vendored
Normal file
39
vendor/davejamesmiller/laravel-breadcrumbs/tests/integration/DependantServiceProviderTest.php
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
class DependantServiceProviderTest extends TestCase {
|
||||
|
||||
protected function getPackageProviders()
|
||||
{
|
||||
return [
|
||||
'DaveJamesMiller\Breadcrumbs\ServiceProvider',
|
||||
'DependantServiceProvider',
|
||||
];
|
||||
}
|
||||
|
||||
protected function loadServiceProvider()
|
||||
{
|
||||
// Disabled - we want to test the automatic loading instead
|
||||
}
|
||||
|
||||
public function testRender()
|
||||
{
|
||||
$html = Breadcrumbs::render('home');
|
||||
$this->assertXmlStringEqualsXmlFile(__DIR__ . '/../fixtures/DependantServiceProvider.html', $html);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class DependantServiceProvider extends Illuminate\Support\ServiceProvider {
|
||||
|
||||
public function register()
|
||||
{
|
||||
}
|
||||
|
||||
public function boot()
|
||||
{
|
||||
Breadcrumbs::register('home', function($breadcrumbs) {
|
||||
$breadcrumbs->push('Home', '/');
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
61
vendor/davejamesmiller/laravel-breadcrumbs/tests/integration/IntegrationTest.php
vendored
Normal file
61
vendor/davejamesmiller/laravel-breadcrumbs/tests/integration/IntegrationTest.php
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
class IntegrationTest extends TestCase {
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Breadcrumbs::register('home', function($breadcrumbs) {
|
||||
$breadcrumbs->push('Home', '/');
|
||||
});
|
||||
|
||||
Breadcrumbs::register('category', function($breadcrumbs, $category) {
|
||||
$breadcrumbs->parent('home');
|
||||
$breadcrumbs->push($category->title, '/category/' . $category->id);
|
||||
});
|
||||
|
||||
Breadcrumbs::register('post', function($breadcrumbs, $post) {
|
||||
$breadcrumbs->parent('category', $post->category);
|
||||
$breadcrumbs->push($post->title, '/blog/' . $post->id);
|
||||
});
|
||||
|
||||
$this->post = (object) [
|
||||
'id' => 123,
|
||||
'title' => 'Sample Post',
|
||||
'category' => (object) [
|
||||
'id' => 456,
|
||||
'title' => 'Sample Category',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function testGenerate()
|
||||
{
|
||||
$breadcrumbs = Breadcrumbs::generate('post', $this->post);
|
||||
|
||||
$this->assertCount(3, $breadcrumbs);
|
||||
|
||||
$this->assertSame('Home', $breadcrumbs[0]->title);
|
||||
$this->assertSame('/', $breadcrumbs[0]->url);
|
||||
$this->assertTrue($breadcrumbs[0]->first);
|
||||
$this->assertFalse($breadcrumbs[0]->last);
|
||||
|
||||
$this->assertSame('Sample Category', $breadcrumbs[1]->title);
|
||||
$this->assertSame('/category/456', $breadcrumbs[1]->url);
|
||||
$this->assertFalse($breadcrumbs[1]->first);
|
||||
$this->assertFalse($breadcrumbs[1]->last);
|
||||
|
||||
$this->assertSame('Sample Post', $breadcrumbs[2]->title);
|
||||
$this->assertSame('/blog/123', $breadcrumbs[2]->url);
|
||||
$this->assertFalse($breadcrumbs[2]->first);
|
||||
$this->assertTrue($breadcrumbs[2]->last);
|
||||
}
|
||||
|
||||
public function testRender()
|
||||
{
|
||||
$html = Breadcrumbs::render('post', $this->post);
|
||||
$this->assertXmlStringEqualsXmlFile(__DIR__ . '/../fixtures/integration.html', $html);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user