Laravel version update
Laravel version update
This commit is contained in:
7
vendor/davejamesmiller/laravel-breadcrumbs/tests/bootstrap.php
vendored
Normal file
7
vendor/davejamesmiller/laravel-breadcrumbs/tests/bootstrap.php
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
// Load Composer packages
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
// Load base class
|
||||
require __DIR__ . '/../tests/TestCase.php';
|
@@ -5,159 +5,167 @@ use Mockery as m;
|
||||
|
||||
class ManagerTest extends TestCase {
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->currentRoute = m::mock('DaveJamesMiller\Breadcrumbs\CurrentRoute');
|
||||
$this->generator = m::mock('DaveJamesMiller\Breadcrumbs\Generator');
|
||||
$this->view = m::mock('DaveJamesMiller\Breadcrumbs\View');
|
||||
$this->manager = new Manager($this->currentRoute, $this->generator, $this->view);
|
||||
$this->currentRoute = m::mock('DaveJamesMiller\Breadcrumbs\CurrentRoute');
|
||||
$this->generator = m::mock('DaveJamesMiller\Breadcrumbs\Generator');
|
||||
$this->view = m::mock('DaveJamesMiller\Breadcrumbs\View');
|
||||
$this->manager = new Manager($this->currentRoute, $this->generator, $this->view);
|
||||
|
||||
$this->manager->setView('view');
|
||||
}
|
||||
$this->manager->setView('view');
|
||||
}
|
||||
|
||||
// Breadcrumbs::register($name, $callback) is tested by other methods
|
||||
protected function register($name)
|
||||
{
|
||||
$this->manager->register($name, $fn = function() {
|
||||
// We're not testing whether the callbacks are executed - see GeneratorTest
|
||||
throw new Exception('Callback executed');
|
||||
});
|
||||
// Breadcrumbs::register($name, $callback) is tested by other methods
|
||||
protected function register($name)
|
||||
{
|
||||
$this->manager->register($name, $fn = function() {
|
||||
// We're not testing whether the callbacks are executed - see GeneratorTest
|
||||
throw new Exception('Callback executed');
|
||||
});
|
||||
|
||||
return $fn;
|
||||
}
|
||||
return $fn;
|
||||
}
|
||||
|
||||
// Breadcrumbs::exists() -> boolean
|
||||
public function testExists()
|
||||
{
|
||||
$this->currentRoute->shouldReceive('get')->andReturn(['sample', [1, 'blah']]);
|
||||
// Breadcrumbs::exists() -> boolean
|
||||
public function testExists()
|
||||
{
|
||||
$this->currentRoute->shouldReceive('get')->andReturn(['sample', [1, 'blah']]);
|
||||
|
||||
$this->assertFalse($this->manager->exists());
|
||||
$this->assertFalse($this->manager->exists());
|
||||
|
||||
$this->register('sample');
|
||||
$this->assertTrue($this->manager->exists());
|
||||
}
|
||||
$this->register('sample');
|
||||
$this->assertTrue($this->manager->exists());
|
||||
}
|
||||
|
||||
// Breadcrumbs::exists($name) -> boolean
|
||||
public function testExists_name()
|
||||
{
|
||||
$this->assertFalse($this->manager->exists('sample'));
|
||||
// Breadcrumbs::exists($name) -> boolean
|
||||
public function testExists_name()
|
||||
{
|
||||
$this->assertFalse($this->manager->exists('sample'));
|
||||
|
||||
$this->register('sample');
|
||||
$this->assertTrue($this->manager->exists('sample'));
|
||||
}
|
||||
$this->register('sample');
|
||||
$this->assertTrue($this->manager->exists('sample'));
|
||||
}
|
||||
|
||||
// Breadcrumbs::generate() -> array
|
||||
public function testGenerate()
|
||||
{
|
||||
$fn = $this->register('sample');
|
||||
// Breadcrumbs::generate() -> array
|
||||
public function testGenerate()
|
||||
{
|
||||
$fn = $this->register('sample');
|
||||
|
||||
$this->currentRoute->shouldReceive('get')->andReturn(['sample', [1, 'blah']]);
|
||||
$this->generator->shouldReceive('generate')->with(['sample' => $fn], 'sample', [1, 'blah'])->once()->andReturn('generated');;
|
||||
$this->currentRoute->shouldReceive('get')->andReturn(['sample', [1, 'blah']]);
|
||||
$this->generator->shouldReceive('generate')->with(['sample' => $fn], 'sample', [1, 'blah'])->once()->andReturn('generated');;
|
||||
|
||||
$this->assertSame('generated', $this->manager->generate());
|
||||
}
|
||||
$this->assertSame('generated', $this->manager->generate());
|
||||
}
|
||||
|
||||
// Breadcrumbs::generate($name) -> array
|
||||
public function testGenerate_name()
|
||||
{
|
||||
$fn = $this->register('sample');
|
||||
// Breadcrumbs::generate($name) -> array
|
||||
public function testGenerate_name()
|
||||
{
|
||||
$fn = $this->register('sample');
|
||||
|
||||
$this->generator->shouldReceive('generate')->with(['sample' => $fn], 'sample', [])->once()->andReturn('generated');;
|
||||
$this->generator->shouldReceive('generate')->with(['sample' => $fn], 'sample', [])->once()->andReturn('generated');;
|
||||
|
||||
$this->assertSame('generated', $this->manager->generate('sample'));
|
||||
}
|
||||
$this->assertSame('generated', $this->manager->generate('sample'));
|
||||
}
|
||||
|
||||
// Breadcrumbs::generate($name, $param1, ...) -> array
|
||||
public function testGenerate_name_params()
|
||||
{
|
||||
$fn = $this->register('sample');
|
||||
// Breadcrumbs::generate($name, $param1, ...) -> array
|
||||
public function testGenerate_name_params()
|
||||
{
|
||||
$fn = $this->register('sample');
|
||||
|
||||
$this->generator->shouldReceive('generate')->with(['sample' => $fn], 'sample', [1, 'blah'])->once()->andReturn('generated');;
|
||||
$this->generator->shouldReceive('generate')->with(['sample' => $fn], 'sample', [1, 'blah'])->once()->andReturn('generated');;
|
||||
|
||||
$this->assertSame('generated', $this->manager->generate('sample', 1, 'blah'));
|
||||
}
|
||||
$this->assertSame('generated', $this->manager->generate('sample', 1, 'blah'));
|
||||
}
|
||||
|
||||
// Breadcrumbs::generateArray($name, $params) -> array
|
||||
public function testGenerateArray_name_params()
|
||||
{
|
||||
$fn = $this->register('sample');
|
||||
// Breadcrumbs::generateArray($name, $params) -> array
|
||||
public function testGenerateArray_name_params()
|
||||
{
|
||||
$fn = $this->register('sample');
|
||||
|
||||
$this->generator->shouldReceive('generate')->with(['sample' => $fn], 'sample', [1, 'blah'])->once()->andReturn('generated');;
|
||||
$this->generator->shouldReceive('generate')->with(['sample' => $fn], 'sample', [1, 'blah'])->once()->andReturn('generated');;
|
||||
|
||||
$this->assertSame('generated', $this->manager->generateArray('sample', [1, 'blah']));
|
||||
}
|
||||
$this->assertSame('generated', $this->manager->generateArray('sample', [1, 'blah']));
|
||||
}
|
||||
|
||||
// Breadcrumbs::generateIfExists() -> array
|
||||
public function testGenerateIfExists_existing()
|
||||
{
|
||||
$fn = $this->register('sample');
|
||||
// Breadcrumbs::generateIfExists() -> array
|
||||
public function testGenerateIfExists_existing()
|
||||
{
|
||||
$fn = $this->register('sample');
|
||||
|
||||
$this->currentRoute->shouldReceive('get')->andReturn(['sample', [1, 'blah']]);
|
||||
$this->generator->shouldReceive('generate')->with(['sample' => $fn], 'sample', [1, 'blah'])->once()->andReturn('generated');
|
||||
$this->currentRoute->shouldReceive('get')->andReturn(['sample', [1, 'blah']]);
|
||||
$this->generator->shouldReceive('generate')->with(['sample' => $fn], 'sample', [1, 'blah'])->once()->andReturn('generated');
|
||||
|
||||
$this->assertSame('generated', $this->manager->generateIfExists());
|
||||
}
|
||||
$this->assertSame('generated', $this->manager->generateIfExists());
|
||||
}
|
||||
|
||||
public function testGenerateIfExists_nonexistant()
|
||||
{
|
||||
$this->currentRoute->shouldReceive('get')->andReturn(['sample', [1, 'blah']]);
|
||||
$this->generator->shouldReceive('generate')->never();
|
||||
public function testGenerateIfExists_nonexistant()
|
||||
{
|
||||
$this->currentRoute->shouldReceive('get')->andReturn(['sample', [1, 'blah']]);
|
||||
$this->generator->shouldReceive('generate')->never();
|
||||
|
||||
$this->assertSame([], $this->manager->generateIfExists());
|
||||
}
|
||||
$this->assertSame([], $this->manager->generateIfExists());
|
||||
}
|
||||
|
||||
// Breadcrumbs::generateIfExists($name) -> array
|
||||
public function testGenerateIfExists_name_existing()
|
||||
{
|
||||
$fn = $this->register('sample');
|
||||
public function testGenerateIfExists_noroute()
|
||||
{
|
||||
$this->currentRoute->shouldReceive('get')->andThrow('DaveJamesMiller\Breadcrumbs\Exception', 'The current route (GET /sample/unnamed) is not named - please check routes.php for an "as" parameter');
|
||||
$this->generator->shouldReceive('generate')->never();
|
||||
|
||||
$this->generator->shouldReceive('generate')->with(['sample' => $fn], 'sample', [])->once()->andReturn('generated');
|
||||
$this->assertSame([], $this->manager->generateIfExists());
|
||||
}
|
||||
|
||||
$this->assertSame('generated', $this->manager->generateIfExists('sample'));
|
||||
}
|
||||
// Breadcrumbs::generateIfExists($name) -> array
|
||||
public function testGenerateIfExists_name_existing()
|
||||
{
|
||||
$fn = $this->register('sample');
|
||||
|
||||
public function testGenerateIfExists_name_nonexistant()
|
||||
{
|
||||
$this->generator->shouldReceive('generate')->never();
|
||||
$this->generator->shouldReceive('generate')->with(['sample' => $fn], 'sample', [])->once()->andReturn('generated');
|
||||
|
||||
$this->assertSame([], $this->manager->generateIfExists('sample'));
|
||||
}
|
||||
$this->assertSame('generated', $this->manager->generateIfExists('sample'));
|
||||
}
|
||||
|
||||
// Breadcrumbs::generateIfExists($name, $param1, ...) -> array
|
||||
public function testGenerateIfExists_name_params_existing()
|
||||
{
|
||||
$fn = $this->register('sample');
|
||||
public function testGenerateIfExists_name_nonexistant()
|
||||
{
|
||||
$this->generator->shouldReceive('generate')->never();
|
||||
|
||||
$this->generator->shouldReceive('generate')->with(['sample' => $fn], 'sample', [1, 'blah'])->once()->andReturn('generated');
|
||||
$this->assertSame([], $this->manager->generateIfExists('sample'));
|
||||
}
|
||||
|
||||
$this->assertSame('generated', $this->manager->generateIfExists('sample', 1, 'blah'));
|
||||
}
|
||||
// Breadcrumbs::generateIfExists($name, $param1, ...) -> array
|
||||
public function testGenerateIfExists_name_params_existing()
|
||||
{
|
||||
$fn = $this->register('sample');
|
||||
|
||||
public function testGenerateIfExists_name_params_nonexistant()
|
||||
{
|
||||
$this->generator->shouldReceive('generate')->never();
|
||||
$this->generator->shouldReceive('generate')->with(['sample' => $fn], 'sample', [1, 'blah'])->once()->andReturn('generated');
|
||||
|
||||
$this->assertSame([], $this->manager->generateIfExists('sample', 1, 'blah'));
|
||||
}
|
||||
$this->assertSame('generated', $this->manager->generateIfExists('sample', 1, 'blah'));
|
||||
}
|
||||
|
||||
// Breadcrumbs::generateArrayIfExists($name, $params) -> array
|
||||
public function testGenerateArrayIfExists_name_params_existing()
|
||||
{
|
||||
$fn = $this->register('sample');
|
||||
public function testGenerateIfExists_name_params_nonexistant()
|
||||
{
|
||||
$this->generator->shouldReceive('generate')->never();
|
||||
|
||||
$this->generator->shouldReceive('generate')->with(['sample' => $fn], 'sample', [1, 'blah'])->once()->andReturn('generated');
|
||||
$this->assertSame([], $this->manager->generateIfExists('sample', 1, 'blah'));
|
||||
}
|
||||
|
||||
$this->assertSame('generated', $this->manager->generateArrayIfExists('sample', [1, 'blah']));
|
||||
}
|
||||
// Breadcrumbs::generateArrayIfExists($name, $params) -> array
|
||||
public function testGenerateArrayIfExists_name_params_existing()
|
||||
{
|
||||
$fn = $this->register('sample');
|
||||
|
||||
public function testGenerateArrayIfExists_name_params_nonexistant()
|
||||
{
|
||||
$this->generator->shouldReceive('generate')->never();
|
||||
$this->generator->shouldReceive('generate')->with(['sample' => $fn], 'sample', [1, 'blah'])->once()->andReturn('generated');
|
||||
|
||||
$this->assertSame([], $this->manager->generateArrayIfExists('sample', [1, 'blah']));
|
||||
}
|
||||
$this->assertSame('generated', $this->manager->generateArrayIfExists('sample', [1, 'blah']));
|
||||
}
|
||||
|
||||
public function testGenerateArrayIfExists_name_params_nonexistant()
|
||||
{
|
||||
$this->generator->shouldReceive('generate')->never();
|
||||
|
||||
$this->assertSame([], $this->manager->generateArrayIfExists('sample', [1, 'blah']));
|
||||
}
|
||||
|
||||
// Breadcrumbs::render() -> array
|
||||
public function testRender()
|
||||
@@ -225,6 +233,15 @@ class ManagerTest extends TestCase {
|
||||
$this->assertSame('', $this->manager->renderIfExists());
|
||||
}
|
||||
|
||||
public function testRenderIfExists_noroute()
|
||||
{
|
||||
$this->currentRoute->shouldReceive('get')->andThrow('DaveJamesMiller\Breadcrumbs\Exception', 'The current route (GET /sample/unnamed) is not named - please check routes.php for an "as" parameter');
|
||||
$this->generator->shouldReceive('generate')->never();
|
||||
$this->view->shouldReceive('render')->never();
|
||||
|
||||
$this->assertSame('', $this->manager->renderIfExists());
|
||||
}
|
||||
|
||||
// Breadcrumbs::renderIfExists($name) -> array
|
||||
public function testRenderIfExists_name_existing()
|
||||
{
|
||||
@@ -282,48 +299,48 @@ class ManagerTest extends TestCase {
|
||||
$this->assertSame('', $this->manager->renderArrayIfExists('sample', [1, 'blah']));
|
||||
}
|
||||
|
||||
// Breadcrumbs::setCurrentRoute($name)
|
||||
public function testSetCurrentRoute_name()
|
||||
{
|
||||
$this->currentRoute->shouldReceive('set')->with('sample', [])->once();
|
||||
// Breadcrumbs::setCurrentRoute($name)
|
||||
public function testSetCurrentRoute_name()
|
||||
{
|
||||
$this->currentRoute->shouldReceive('set')->with('sample', [])->once();
|
||||
|
||||
$this->manager->setCurrentRoute('sample');
|
||||
}
|
||||
$this->manager->setCurrentRoute('sample');
|
||||
}
|
||||
|
||||
// Breadcrumbs::setCurrentRoute($name, $param1, ...)
|
||||
public function testSetCurrentRoute_name_params()
|
||||
{
|
||||
$this->currentRoute->shouldReceive('set')->with('sample', [1, 'blah'])->once();
|
||||
// Breadcrumbs::setCurrentRoute($name, $param1, ...)
|
||||
public function testSetCurrentRoute_name_params()
|
||||
{
|
||||
$this->currentRoute->shouldReceive('set')->with('sample', [1, 'blah'])->once();
|
||||
|
||||
$this->manager->setCurrentRoute('sample', 1, 'blah');
|
||||
}
|
||||
$this->manager->setCurrentRoute('sample', 1, 'blah');
|
||||
}
|
||||
|
||||
// Breadcrumbs::setCurrentRouteArray($name, $params)
|
||||
public function testSetCurrentRouteArray_name_params()
|
||||
{
|
||||
$this->currentRoute->shouldReceive('set')->with('sample', [1, 'blah'])->once();
|
||||
// Breadcrumbs::setCurrentRouteArray($name, $params)
|
||||
public function testSetCurrentRouteArray_name_params()
|
||||
{
|
||||
$this->currentRoute->shouldReceive('set')->with('sample', [1, 'blah'])->once();
|
||||
|
||||
$this->manager->setCurrentRouteArray('sample', [1, 'blah']);
|
||||
}
|
||||
$this->manager->setCurrentRouteArray('sample', [1, 'blah']);
|
||||
}
|
||||
|
||||
// Breadcrumbs::clearCurrentRoute()
|
||||
public function testClearCurrentRoute()
|
||||
{
|
||||
$this->currentRoute->shouldReceive('clear')->withNoArgs()->once();
|
||||
// Breadcrumbs::clearCurrentRoute()
|
||||
public function testClearCurrentRoute()
|
||||
{
|
||||
$this->currentRoute->shouldReceive('clear')->withNoArgs()->once();
|
||||
|
||||
$this->manager->clearCurrentRoute();
|
||||
}
|
||||
$this->manager->clearCurrentRoute();
|
||||
}
|
||||
|
||||
// Breadcrumbs::setView($view)
|
||||
public function testSetView()
|
||||
{
|
||||
// Breadcrumbs::setView($view)
|
||||
public function testSetView()
|
||||
{
|
||||
$fn = $this->register('sample');
|
||||
|
||||
$this->generator->shouldReceive('generate')->with(['sample' => $fn], 'sample', [1, 'blah'])->once()->andReturn('generated');;
|
||||
$this->view->shouldReceive('render')->with('custom.view', 'generated')->once()->andReturn('rendered');
|
||||
|
||||
$this->manager->setView($view = 'custom.view');
|
||||
$this->manager->setView($view = 'custom.view');
|
||||
$this->assertSame('rendered', $this->manager->render('sample', 1, 'blah'));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user