Skip to content
This repository was archived by the owner on Oct 18, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
"license": "MIT License",
"require": {
"php": ">=5.3.0",
"illuminate/support": ">=4.0",
"illuminate/view": ">=4.0"
"illuminate/support": "~4.1",
"illuminate/view": "~4.1"
},
"require-dev": {
"mockery/mockery": "~0.8.0",
"mockery/mockery": "~0.9.0",
"phpunit/phpunit": "4.0.*",
"satooshi/php-coveralls": "~0.6.0"
},
"autoload": {
Expand Down
15 changes: 10 additions & 5 deletions src/DaveJamesMiller/Breadcrumbs/Manager.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
<?php
namespace DaveJamesMiller\Breadcrumbs;

use InvalidArgumentException;
use Illuminate\Routing\Router;
use Illuminate\View\Environment as ViewEnvironment;

class Manager
{
protected $environment;
protected $factory;
protected $router;

protected $callbacks = array();
protected $view;

protected $currentRoute;

public function __construct(ViewEnvironment $environment, Router $router)
public function __construct($factory, Router $router)
{
$this->environment = $environment;
if (! $factory instanceof \Illuminate\View\Factory && ! $factory instanceof \Illuminate\View\Environment)
{
throw new InvalidArgumentException('$factory must be an instance of either \Illuminate\View\Factory or \Illuminate\View\Environment');
}

$this->factory = $factory;
$this->router = $router;
}

Expand Down Expand Up @@ -99,7 +104,7 @@ public function renderArray($name, $params = array())
{
$breadcrumbs = $this->generateArray($name, $params);

return $this->environment->make($this->view, compact('breadcrumbs'))->render();
return $this->factory->make($this->view, compact('breadcrumbs'))->render();
}

public function renderArrayIfExists($name = null)
Expand Down
14 changes: 11 additions & 3 deletions tests/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@ class IntegrationTest extends PHPUnit_Framework_TestCase
{
public function setUp()
{
$this->environment = m::mock('Illuminate\View\Environment');
if (class_exists('Illuminate\\View\\Factory'))
{
$this->factory = m::mock('Illuminate\View\Factory');
}
else
{
$this->factory = m::mock('Illuminate\View\Environment');
}

$this->router = m::mock('Illuminate\Routing\Router');
$this->manager = new Breadcrumbs\Manager($this->environment, $this->router);
$this->manager = new Breadcrumbs\Manager($this->factory, $this->router);

$this->manager->register('home', function($breadcrumbs) {
$breadcrumbs->push('Home', '/');
Expand Down Expand Up @@ -99,7 +107,7 @@ public function testRender()
// Make sure the view is created with the correct parameters
$breadcrumbs = $this->manager->generate('home');
$vars = array('breadcrumbs' => $breadcrumbs);
$this->environment->shouldReceive('make')->once()->with($viewName, $vars)->andReturn($view);
$this->factory->shouldReceive('make')->once()->with($viewName, $vars)->andReturn($view);

// Make sure the HTML rendered by the view is returned by the manager
$this->assertSame($html, $this->manager->render('home'));
Expand Down
12 changes: 10 additions & 2 deletions tests/ManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@ class ManagerTest extends PHPUnit_Framework_TestCase
{
public function setUp()
{
$this->environment = m::mock('Illuminate\View\Environment');
if (class_exists('Illuminate\\View\\Factory'))
{
$this->factory = m::mock('Illuminate\View\Factory');
}
else
{
$this->factory = m::mock('Illuminate\View\Environment');
}

$this->router = m::mock('Illuminate\Routing\Router');
$this->manager = new Breadcrumbs\Manager($this->environment, $this->router);
$this->manager = new Breadcrumbs\Manager($this->factory, $this->router);

$this->manager->register('sample', function() {});
}
Expand Down