@@ -4,74 +4,74 @@ |
||
4 | 4 | |
5 | 5 | class ServiceProvider extends BaseServiceProvider { |
6 | 6 | |
7 | - /** |
|
8 | - * Indicates if loading of the provider is deferred. |
|
9 | - * |
|
10 | - * @var bool |
|
11 | - */ |
|
12 | - // Can't enable this because there appears to be a bug in Laravel where a |
|
13 | - // non-deferred service provider can't use a deferred one because the boot |
|
14 | - // method is not called - see DependantServiceProviderTest. |
|
15 | - // protected $defer = true; |
|
7 | + /** |
|
8 | + * Indicates if loading of the provider is deferred. |
|
9 | + * |
|
10 | + * @var bool |
|
11 | + */ |
|
12 | + // Can't enable this because there appears to be a bug in Laravel where a |
|
13 | + // non-deferred service provider can't use a deferred one because the boot |
|
14 | + // method is not called - see DependantServiceProviderTest. |
|
15 | + // protected $defer = true; |
|
16 | 16 | |
17 | - /** |
|
18 | - * Get the services provided by the provider. |
|
19 | - * |
|
20 | - * @return array |
|
21 | - */ |
|
22 | - public function provides() |
|
23 | - { |
|
24 | - return ['breadcrumbs']; |
|
25 | - } |
|
17 | + /** |
|
18 | + * Get the services provided by the provider. |
|
19 | + * |
|
20 | + * @return array |
|
21 | + */ |
|
22 | + public function provides() |
|
23 | + { |
|
24 | + return ['breadcrumbs']; |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * Register the service provider. |
|
29 | - * |
|
30 | - * @return void |
|
31 | - */ |
|
32 | - public function register() |
|
33 | - { |
|
34 | - $this->app['breadcrumbs'] = $this->app->share(function($app) |
|
35 | - { |
|
36 | - $breadcrumbs = $this->app->make('DaveJamesMiller\Breadcrumbs\Manager'); |
|
27 | + /** |
|
28 | + * Register the service provider. |
|
29 | + * |
|
30 | + * @return void |
|
31 | + */ |
|
32 | + public function register() |
|
33 | + { |
|
34 | + $this->app['breadcrumbs'] = $this->app->share(function($app) |
|
35 | + { |
|
36 | + $breadcrumbs = $this->app->make('DaveJamesMiller\Breadcrumbs\Manager'); |
|
37 | 37 | |
38 | - $viewPath = __DIR__ . '/../views/'; |
|
38 | + $viewPath = __DIR__ . '/../views/'; |
|
39 | 39 | |
40 | - $this->loadViewsFrom($viewPath, 'breadcrumbs'); |
|
41 | - $this->loadViewsFrom($viewPath, 'laravel-breadcrumbs'); // Backwards-compatibility with 2.x |
|
40 | + $this->loadViewsFrom($viewPath, 'breadcrumbs'); |
|
41 | + $this->loadViewsFrom($viewPath, 'laravel-breadcrumbs'); // Backwards-compatibility with 2.x |
|
42 | 42 | |
43 | - $breadcrumbs->setView($app['config']['breadcrumbs.view']); |
|
43 | + $breadcrumbs->setView($app['config']['breadcrumbs.view']); |
|
44 | 44 | |
45 | - return $breadcrumbs; |
|
46 | - }); |
|
47 | - } |
|
45 | + return $breadcrumbs; |
|
46 | + }); |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * Bootstrap the application events. |
|
51 | - * |
|
52 | - * @return void |
|
53 | - */ |
|
54 | - public function boot() |
|
55 | - { |
|
56 | - $configFile = __DIR__ . '/../config/breadcrumbs.php'; |
|
49 | + /** |
|
50 | + * Bootstrap the application events. |
|
51 | + * |
|
52 | + * @return void |
|
53 | + */ |
|
54 | + public function boot() |
|
55 | + { |
|
56 | + $configFile = __DIR__ . '/../config/breadcrumbs.php'; |
|
57 | 57 | |
58 | - $this->mergeConfigFrom($configFile, 'breadcrumbs'); |
|
58 | + $this->mergeConfigFrom($configFile, 'breadcrumbs'); |
|
59 | 59 | |
60 | - $this->publishes([ |
|
61 | - $configFile => config_path('breadcrumbs.php') |
|
62 | - ]); |
|
60 | + $this->publishes([ |
|
61 | + $configFile => config_path('breadcrumbs.php') |
|
62 | + ]); |
|
63 | 63 | |
64 | - $this->registerBreadcrumbs(); |
|
65 | - } |
|
64 | + $this->registerBreadcrumbs(); |
|
65 | + } |
|
66 | 66 | |
67 | - // This method can be overridden in a child class |
|
68 | - public function registerBreadcrumbs() |
|
69 | - { |
|
70 | - // Load the app breadcrumbs if they're in app/Http/breadcrumbs.php |
|
71 | - if (file_exists($file = $this->app['path'].'/Http/breadcrumbs.php')) |
|
72 | - { |
|
73 | - require $file; |
|
74 | - } |
|
75 | - } |
|
67 | + // This method can be overridden in a child class |
|
68 | + public function registerBreadcrumbs() |
|
69 | + { |
|
70 | + // Load the app breadcrumbs if they're in app/Http/breadcrumbs.php |
|
71 | + if (file_exists($file = $this->app['path'].'/Http/breadcrumbs.php')) |
|
72 | + { |
|
73 | + require $file; |
|
74 | + } |
|
75 | + } |
|
76 | 76 | |
77 | 77 | } |
@@ -68,7 +68,7 @@ |
||
68 | 68 | public function registerBreadcrumbs() |
69 | 69 | { |
70 | 70 | // Load the app breadcrumbs if they're in app/Http/breadcrumbs.php |
71 | - if (file_exists($file = $this->app['path'].'/Http/breadcrumbs.php')) |
|
71 | + if (file_exists($file = $this->app['path'] . '/Http/breadcrumbs.php')) |
|
72 | 72 | { |
73 | 73 | require $file; |
74 | 74 | } |
@@ -4,15 +4,15 @@ |
||
4 | 4 | |
5 | 5 | class Facade extends BaseFacade { |
6 | 6 | |
7 | - /** |
|
8 | - * Get the registered name of the component. |
|
9 | - * |
|
10 | - * @return string |
|
11 | - */ |
|
12 | - protected static function getFacadeAccessor() |
|
13 | - { |
|
14 | - // App::make('breadcrumbs') |
|
15 | - return 'breadcrumbs'; |
|
16 | - } |
|
7 | + /** |
|
8 | + * Get the registered name of the component. |
|
9 | + * |
|
10 | + * @return string |
|
11 | + */ |
|
12 | + protected static function getFacadeAccessor() |
|
13 | + { |
|
14 | + // App::make('breadcrumbs') |
|
15 | + return 'breadcrumbs'; |
|
16 | + } |
|
17 | 17 | |
18 | 18 | } |
@@ -2,157 +2,157 @@ |
||
2 | 2 | |
3 | 3 | class Manager { |
4 | 4 | |
5 | - protected $currentRoute; |
|
6 | - protected $generator; |
|
7 | - protected $view; |
|
8 | - |
|
9 | - protected $callbacks = []; |
|
10 | - protected $viewName; |
|
11 | - protected $currentRouteManual; |
|
12 | - |
|
13 | - public function __construct(CurrentRoute $currentRoute, Generator $generator, View $view) |
|
14 | - { |
|
15 | - $this->generator = $generator; |
|
16 | - $this->currentRoute = $currentRoute; |
|
17 | - $this->view = $view; |
|
18 | - } |
|
19 | - |
|
20 | - public function register($name, $callback) |
|
21 | - { |
|
22 | - $this->callbacks[$name] = $callback; |
|
23 | - } |
|
24 | - |
|
25 | - public function exists($name = null) |
|
26 | - { |
|
27 | - if (is_null($name)) { |
|
28 | - try { |
|
29 | - list($name) = $this->currentRoute->get(); |
|
30 | - } catch (Exception $e) { |
|
31 | - return false; |
|
32 | - } |
|
33 | - } |
|
34 | - |
|
35 | - return isset($this->callbacks[$name]); |
|
36 | - } |
|
37 | - |
|
38 | - public function generate($name = null) |
|
39 | - { |
|
40 | - if (is_null($name)) |
|
41 | - list($name, $params) = $this->currentRoute->get(); |
|
42 | - else |
|
43 | - $params = array_slice(func_get_args(), 1); |
|
44 | - |
|
45 | - return $this->generator->generate($this->callbacks, $name, $params); |
|
46 | - } |
|
47 | - |
|
48 | - public function generateArray($name, $params = []) |
|
49 | - { |
|
50 | - return $this->generator->generate($this->callbacks, $name, $params); |
|
51 | - } |
|
52 | - |
|
53 | - public function generateIfExists($name = null) |
|
54 | - { |
|
55 | - if (is_null($name)) |
|
56 | - list($name, $params) = $this->currentRoute->get(); |
|
57 | - else |
|
58 | - $params = array_slice(func_get_args(), 1); |
|
59 | - |
|
60 | - if (!$this->exists($name)) |
|
61 | - return []; |
|
62 | - |
|
63 | - return $this->generator->generate($this->callbacks, $name, $params); |
|
64 | - } |
|
65 | - |
|
66 | - public function generateIfExistsArray($name, $params = []) |
|
67 | - { |
|
68 | - if (!$this->exists($name)) |
|
69 | - return []; |
|
70 | - |
|
71 | - return $this->generator->generate($this->callbacks, $name, $params); |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * @deprecated Since 3.0.0 |
|
76 | - * @see generateIfExistsArray |
|
77 | - */ |
|
78 | - public function generateArrayIfExists() |
|
79 | - { |
|
80 | - return call_user_func_array([$this, 'generateIfExistsArray'], func_get_args()); |
|
81 | - } |
|
82 | - |
|
83 | - public function render($name = null) |
|
84 | - { |
|
85 | - if (is_null($name)) |
|
86 | - list($name, $params) = $this->currentRoute->get(); |
|
87 | - else |
|
88 | - $params = array_slice(func_get_args(), 1); |
|
89 | - |
|
90 | - $breadcrumbs = $this->generator->generate($this->callbacks, $name, $params); |
|
91 | - |
|
92 | - return $this->view->render($this->viewName, $breadcrumbs); |
|
93 | - } |
|
94 | - |
|
95 | - public function renderArray($name, $params = []) |
|
96 | - { |
|
97 | - $breadcrumbs = $this->generator->generate($this->callbacks, $name, $params); |
|
98 | - |
|
99 | - return $this->view->render($this->viewName, $breadcrumbs); |
|
100 | - } |
|
101 | - |
|
102 | - public function renderIfExists($name = null) |
|
103 | - { |
|
104 | - if (is_null($name)) |
|
105 | - list($name, $params) = $this->currentRoute->get(); |
|
106 | - else |
|
107 | - $params = array_slice(func_get_args(), 1); |
|
108 | - |
|
109 | - if (!$this->exists($name)) |
|
110 | - return ''; |
|
111 | - |
|
112 | - $breadcrumbs = $this->generator->generate($this->callbacks, $name, $params); |
|
113 | - |
|
114 | - return $this->view->render($this->viewName, $breadcrumbs); |
|
115 | - } |
|
116 | - |
|
117 | - public function renderIfExistsArray($name, $params = []) |
|
118 | - { |
|
119 | - if (!$this->exists($name)) |
|
120 | - return ''; |
|
121 | - |
|
122 | - $breadcrumbs = $this->generator->generate($this->callbacks, $name, $params); |
|
123 | - |
|
124 | - return $this->view->render($this->viewName, $breadcrumbs); |
|
125 | - } |
|
126 | - |
|
127 | - /** |
|
128 | - * @deprecated Since 3.0.0 |
|
129 | - * @see renderIfExistsArray |
|
130 | - */ |
|
131 | - public function renderArrayIfExists() |
|
132 | - { |
|
133 | - return call_user_func_array([$this, 'renderIfExistsArray'], func_get_args()); |
|
134 | - } |
|
135 | - |
|
136 | - public function setCurrentRoute($name) |
|
137 | - { |
|
138 | - $params = array_slice(func_get_args(), 1); |
|
139 | - |
|
140 | - $this->currentRoute->set($name, $params); |
|
141 | - } |
|
142 | - |
|
143 | - public function setCurrentRouteArray($name, $params = []) |
|
144 | - { |
|
145 | - $this->currentRoute->set($name, $params); |
|
146 | - } |
|
147 | - |
|
148 | - public function clearCurrentRoute() |
|
149 | - { |
|
150 | - $this->currentRoute->clear(); |
|
151 | - } |
|
152 | - |
|
153 | - public function setView($view) |
|
154 | - { |
|
155 | - $this->viewName = $view; |
|
156 | - } |
|
5 | + protected $currentRoute; |
|
6 | + protected $generator; |
|
7 | + protected $view; |
|
8 | + |
|
9 | + protected $callbacks = []; |
|
10 | + protected $viewName; |
|
11 | + protected $currentRouteManual; |
|
12 | + |
|
13 | + public function __construct(CurrentRoute $currentRoute, Generator $generator, View $view) |
|
14 | + { |
|
15 | + $this->generator = $generator; |
|
16 | + $this->currentRoute = $currentRoute; |
|
17 | + $this->view = $view; |
|
18 | + } |
|
19 | + |
|
20 | + public function register($name, $callback) |
|
21 | + { |
|
22 | + $this->callbacks[$name] = $callback; |
|
23 | + } |
|
24 | + |
|
25 | + public function exists($name = null) |
|
26 | + { |
|
27 | + if (is_null($name)) { |
|
28 | + try { |
|
29 | + list($name) = $this->currentRoute->get(); |
|
30 | + } catch (Exception $e) { |
|
31 | + return false; |
|
32 | + } |
|
33 | + } |
|
34 | + |
|
35 | + return isset($this->callbacks[$name]); |
|
36 | + } |
|
37 | + |
|
38 | + public function generate($name = null) |
|
39 | + { |
|
40 | + if (is_null($name)) |
|
41 | + list($name, $params) = $this->currentRoute->get(); |
|
42 | + else |
|
43 | + $params = array_slice(func_get_args(), 1); |
|
44 | + |
|
45 | + return $this->generator->generate($this->callbacks, $name, $params); |
|
46 | + } |
|
47 | + |
|
48 | + public function generateArray($name, $params = []) |
|
49 | + { |
|
50 | + return $this->generator->generate($this->callbacks, $name, $params); |
|
51 | + } |
|
52 | + |
|
53 | + public function generateIfExists($name = null) |
|
54 | + { |
|
55 | + if (is_null($name)) |
|
56 | + list($name, $params) = $this->currentRoute->get(); |
|
57 | + else |
|
58 | + $params = array_slice(func_get_args(), 1); |
|
59 | + |
|
60 | + if (!$this->exists($name)) |
|
61 | + return []; |
|
62 | + |
|
63 | + return $this->generator->generate($this->callbacks, $name, $params); |
|
64 | + } |
|
65 | + |
|
66 | + public function generateIfExistsArray($name, $params = []) |
|
67 | + { |
|
68 | + if (!$this->exists($name)) |
|
69 | + return []; |
|
70 | + |
|
71 | + return $this->generator->generate($this->callbacks, $name, $params); |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * @deprecated Since 3.0.0 |
|
76 | + * @see generateIfExistsArray |
|
77 | + */ |
|
78 | + public function generateArrayIfExists() |
|
79 | + { |
|
80 | + return call_user_func_array([$this, 'generateIfExistsArray'], func_get_args()); |
|
81 | + } |
|
82 | + |
|
83 | + public function render($name = null) |
|
84 | + { |
|
85 | + if (is_null($name)) |
|
86 | + list($name, $params) = $this->currentRoute->get(); |
|
87 | + else |
|
88 | + $params = array_slice(func_get_args(), 1); |
|
89 | + |
|
90 | + $breadcrumbs = $this->generator->generate($this->callbacks, $name, $params); |
|
91 | + |
|
92 | + return $this->view->render($this->viewName, $breadcrumbs); |
|
93 | + } |
|
94 | + |
|
95 | + public function renderArray($name, $params = []) |
|
96 | + { |
|
97 | + $breadcrumbs = $this->generator->generate($this->callbacks, $name, $params); |
|
98 | + |
|
99 | + return $this->view->render($this->viewName, $breadcrumbs); |
|
100 | + } |
|
101 | + |
|
102 | + public function renderIfExists($name = null) |
|
103 | + { |
|
104 | + if (is_null($name)) |
|
105 | + list($name, $params) = $this->currentRoute->get(); |
|
106 | + else |
|
107 | + $params = array_slice(func_get_args(), 1); |
|
108 | + |
|
109 | + if (!$this->exists($name)) |
|
110 | + return ''; |
|
111 | + |
|
112 | + $breadcrumbs = $this->generator->generate($this->callbacks, $name, $params); |
|
113 | + |
|
114 | + return $this->view->render($this->viewName, $breadcrumbs); |
|
115 | + } |
|
116 | + |
|
117 | + public function renderIfExistsArray($name, $params = []) |
|
118 | + { |
|
119 | + if (!$this->exists($name)) |
|
120 | + return ''; |
|
121 | + |
|
122 | + $breadcrumbs = $this->generator->generate($this->callbacks, $name, $params); |
|
123 | + |
|
124 | + return $this->view->render($this->viewName, $breadcrumbs); |
|
125 | + } |
|
126 | + |
|
127 | + /** |
|
128 | + * @deprecated Since 3.0.0 |
|
129 | + * @see renderIfExistsArray |
|
130 | + */ |
|
131 | + public function renderArrayIfExists() |
|
132 | + { |
|
133 | + return call_user_func_array([$this, 'renderIfExistsArray'], func_get_args()); |
|
134 | + } |
|
135 | + |
|
136 | + public function setCurrentRoute($name) |
|
137 | + { |
|
138 | + $params = array_slice(func_get_args(), 1); |
|
139 | + |
|
140 | + $this->currentRoute->set($name, $params); |
|
141 | + } |
|
142 | + |
|
143 | + public function setCurrentRouteArray($name, $params = []) |
|
144 | + { |
|
145 | + $this->currentRoute->set($name, $params); |
|
146 | + } |
|
147 | + |
|
148 | + public function clearCurrentRoute() |
|
149 | + { |
|
150 | + $this->currentRoute->clear(); |
|
151 | + } |
|
152 | + |
|
153 | + public function setView($view) |
|
154 | + { |
|
155 | + $this->viewName = $view; |
|
156 | + } |
|
157 | 157 | |
158 | 158 | } |
@@ -37,10 +37,11 @@ discard block |
||
37 | 37 | |
38 | 38 | public function generate($name = null) |
39 | 39 | { |
40 | - if (is_null($name)) |
|
41 | - list($name, $params) = $this->currentRoute->get(); |
|
42 | - else |
|
43 | - $params = array_slice(func_get_args(), 1); |
|
40 | + if (is_null($name)) { |
|
41 | + list($name, $params) = $this->currentRoute->get(); |
|
42 | + } else { |
|
43 | + $params = array_slice(func_get_args(), 1); |
|
44 | + } |
|
44 | 45 | |
45 | 46 | return $this->generator->generate($this->callbacks, $name, $params); |
46 | 47 | } |
@@ -52,21 +53,24 @@ discard block |
||
52 | 53 | |
53 | 54 | public function generateIfExists($name = null) |
54 | 55 | { |
55 | - if (is_null($name)) |
|
56 | - list($name, $params) = $this->currentRoute->get(); |
|
57 | - else |
|
58 | - $params = array_slice(func_get_args(), 1); |
|
56 | + if (is_null($name)) { |
|
57 | + list($name, $params) = $this->currentRoute->get(); |
|
58 | + } else { |
|
59 | + $params = array_slice(func_get_args(), 1); |
|
60 | + } |
|
59 | 61 | |
60 | - if (!$this->exists($name)) |
|
61 | - return []; |
|
62 | + if (!$this->exists($name)) { |
|
63 | + return []; |
|
64 | + } |
|
62 | 65 | |
63 | 66 | return $this->generator->generate($this->callbacks, $name, $params); |
64 | 67 | } |
65 | 68 | |
66 | 69 | public function generateIfExistsArray($name, $params = []) |
67 | 70 | { |
68 | - if (!$this->exists($name)) |
|
69 | - return []; |
|
71 | + if (!$this->exists($name)) { |
|
72 | + return []; |
|
73 | + } |
|
70 | 74 | |
71 | 75 | return $this->generator->generate($this->callbacks, $name, $params); |
72 | 76 | } |
@@ -82,10 +86,11 @@ discard block |
||
82 | 86 | |
83 | 87 | public function render($name = null) |
84 | 88 | { |
85 | - if (is_null($name)) |
|
86 | - list($name, $params) = $this->currentRoute->get(); |
|
87 | - else |
|
88 | - $params = array_slice(func_get_args(), 1); |
|
89 | + if (is_null($name)) { |
|
90 | + list($name, $params) = $this->currentRoute->get(); |
|
91 | + } else { |
|
92 | + $params = array_slice(func_get_args(), 1); |
|
93 | + } |
|
89 | 94 | |
90 | 95 | $breadcrumbs = $this->generator->generate($this->callbacks, $name, $params); |
91 | 96 | |
@@ -101,13 +106,15 @@ discard block |
||
101 | 106 | |
102 | 107 | public function renderIfExists($name = null) |
103 | 108 | { |
104 | - if (is_null($name)) |
|
105 | - list($name, $params) = $this->currentRoute->get(); |
|
106 | - else |
|
107 | - $params = array_slice(func_get_args(), 1); |
|
109 | + if (is_null($name)) { |
|
110 | + list($name, $params) = $this->currentRoute->get(); |
|
111 | + } else { |
|
112 | + $params = array_slice(func_get_args(), 1); |
|
113 | + } |
|
108 | 114 | |
109 | - if (!$this->exists($name)) |
|
110 | - return ''; |
|
115 | + if (!$this->exists($name)) { |
|
116 | + return ''; |
|
117 | + } |
|
111 | 118 | |
112 | 119 | $breadcrumbs = $this->generator->generate($this->callbacks, $name, $params); |
113 | 120 | |
@@ -116,8 +123,9 @@ discard block |
||
116 | 123 | |
117 | 124 | public function renderIfExistsArray($name, $params = []) |
118 | 125 | { |
119 | - if (!$this->exists($name)) |
|
120 | - return ''; |
|
126 | + if (!$this->exists($name)) { |
|
127 | + return ''; |
|
128 | + } |
|
121 | 129 | |
122 | 130 | $breadcrumbs = $this->generator->generate($this->callbacks, $name, $params); |
123 | 131 |
@@ -2,38 +2,38 @@ |
||
2 | 2 | |
3 | 3 | abstract class TestCase extends Orchestra\Testbench\TestCase { |
4 | 4 | |
5 | - protected function getPackageProviders() |
|
6 | - { |
|
7 | - return [ |
|
8 | - 'DaveJamesMiller\Breadcrumbs\ServiceProvider', |
|
9 | - ]; |
|
10 | - } |
|
11 | - |
|
12 | - protected function getPackageAliases() |
|
13 | - { |
|
14 | - return [ |
|
15 | - 'Breadcrumbs' => 'DaveJamesMiller\Breadcrumbs\Facade' |
|
16 | - ]; |
|
17 | - } |
|
18 | - |
|
19 | - public function setUp() |
|
20 | - { |
|
21 | - parent::setUp(); |
|
22 | - |
|
23 | - $this->loadServiceProvider(); |
|
24 | - } |
|
25 | - |
|
26 | - protected function loadServiceProvider() |
|
27 | - { |
|
28 | - // Need to trigger register() to test the views |
|
29 | - $this->app->make('breadcrumbs'); |
|
30 | - } |
|
31 | - |
|
32 | - public function tearDown() |
|
33 | - { |
|
34 | - $this->addToAssertionCount(Mockery::getContainer()->mockery_getExpectationCount()); |
|
35 | - |
|
36 | - Mockery::close(); |
|
37 | - } |
|
5 | + protected function getPackageProviders() |
|
6 | + { |
|
7 | + return [ |
|
8 | + 'DaveJamesMiller\Breadcrumbs\ServiceProvider', |
|
9 | + ]; |
|
10 | + } |
|
11 | + |
|
12 | + protected function getPackageAliases() |
|
13 | + { |
|
14 | + return [ |
|
15 | + 'Breadcrumbs' => 'DaveJamesMiller\Breadcrumbs\Facade' |
|
16 | + ]; |
|
17 | + } |
|
18 | + |
|
19 | + public function setUp() |
|
20 | + { |
|
21 | + parent::setUp(); |
|
22 | + |
|
23 | + $this->loadServiceProvider(); |
|
24 | + } |
|
25 | + |
|
26 | + protected function loadServiceProvider() |
|
27 | + { |
|
28 | + // Need to trigger register() to test the views |
|
29 | + $this->app->make('breadcrumbs'); |
|
30 | + } |
|
31 | + |
|
32 | + public function tearDown() |
|
33 | + { |
|
34 | + $this->addToAssertionCount(Mockery::getContainer()->mockery_getExpectationCount()); |
|
35 | + |
|
36 | + Mockery::close(); |
|
37 | + } |
|
38 | 38 | |
39 | 39 | } |
@@ -2,50 +2,50 @@ |
||
2 | 2 | |
3 | 3 | class ViewTest extends TestCase { |
4 | 4 | |
5 | - public function setUp() |
|
6 | - { |
|
7 | - parent::setUp(); |
|
5 | + public function setUp() |
|
6 | + { |
|
7 | + parent::setUp(); |
|
8 | 8 | |
9 | - $this->view = app('DaveJamesMiller\Breadcrumbs\View'); |
|
9 | + $this->view = app('DaveJamesMiller\Breadcrumbs\View'); |
|
10 | 10 | |
11 | - $this->breadcrumbs = [ |
|
12 | - (object) [ |
|
13 | - 'title' => 'Home', |
|
14 | - 'url' => '/', |
|
15 | - 'first' => true, |
|
16 | - 'last' => false, |
|
17 | - ], |
|
18 | - (object) [ |
|
19 | - 'title' => 'Not a link', |
|
20 | - 'url' => null, // Test non-links |
|
21 | - 'first' => false, |
|
22 | - 'last' => false, |
|
23 | - ], |
|
24 | - (object) [ |
|
25 | - 'title' => 'Blog & < >', // Test HTML escaping |
|
26 | - 'url' => '/blog', |
|
27 | - 'first' => false, |
|
28 | - 'last' => false, |
|
29 | - ], |
|
30 | - (object) [ |
|
31 | - 'title' => 'Sample Post', |
|
32 | - 'url' => '/blog/123', |
|
33 | - 'first' => false, |
|
34 | - 'last' => true, |
|
35 | - ], |
|
36 | - ]; |
|
37 | - } |
|
11 | + $this->breadcrumbs = [ |
|
12 | + (object) [ |
|
13 | + 'title' => 'Home', |
|
14 | + 'url' => '/', |
|
15 | + 'first' => true, |
|
16 | + 'last' => false, |
|
17 | + ], |
|
18 | + (object) [ |
|
19 | + 'title' => 'Not a link', |
|
20 | + 'url' => null, // Test non-links |
|
21 | + 'first' => false, |
|
22 | + 'last' => false, |
|
23 | + ], |
|
24 | + (object) [ |
|
25 | + 'title' => 'Blog & < >', // Test HTML escaping |
|
26 | + 'url' => '/blog', |
|
27 | + 'first' => false, |
|
28 | + 'last' => false, |
|
29 | + ], |
|
30 | + (object) [ |
|
31 | + 'title' => 'Sample Post', |
|
32 | + 'url' => '/blog/123', |
|
33 | + 'first' => false, |
|
34 | + 'last' => true, |
|
35 | + ], |
|
36 | + ]; |
|
37 | + } |
|
38 | 38 | |
39 | - public function testBootstrap2() |
|
40 | - { |
|
41 | - $html = $this->view->render('breadcrumbs::bootstrap2', $this->breadcrumbs); |
|
42 | - $this->assertXmlStringEqualsXmlFile(__DIR__ . '/../fixtures/bootstrap2.html', $html); |
|
43 | - } |
|
39 | + public function testBootstrap2() |
|
40 | + { |
|
41 | + $html = $this->view->render('breadcrumbs::bootstrap2', $this->breadcrumbs); |
|
42 | + $this->assertXmlStringEqualsXmlFile(__DIR__ . '/../fixtures/bootstrap2.html', $html); |
|
43 | + } |
|
44 | 44 | |
45 | - public function testBootstrap3() |
|
46 | - { |
|
47 | - $html = $this->view->render('breadcrumbs::bootstrap3', $this->breadcrumbs); |
|
48 | - $this->assertXmlStringEqualsXmlFile(__DIR__ . '/../fixtures/bootstrap3.html', $html); |
|
49 | - } |
|
45 | + public function testBootstrap3() |
|
46 | + { |
|
47 | + $html = $this->view->render('breadcrumbs::bootstrap3', $this->breadcrumbs); |
|
48 | + $this->assertXmlStringEqualsXmlFile(__DIR__ . '/../fixtures/bootstrap3.html', $html); |
|
49 | + } |
|
50 | 50 | |
51 | 51 | } |
@@ -5,76 +5,76 @@ |
||
5 | 5 | |
6 | 6 | class CurrentRouteTest extends TestCase { |
7 | 7 | |
8 | - public function setUp() |
|
9 | - { |
|
10 | - parent::setUp(); |
|
11 | - |
|
12 | - $this->currentRoute = app('DaveJamesMiller\Breadcrumbs\CurrentRoute'); |
|
13 | - } |
|
14 | - |
|
15 | - public function testNamedRoute() |
|
16 | - { |
|
17 | - Route::get('/sample', ['as' => 'sampleroute', function() |
|
18 | - { |
|
19 | - $this->assertSame(['sampleroute', []], $this->currentRoute->get()); |
|
20 | - }]); |
|
21 | - |
|
22 | - $this->call('GET', '/sample'); |
|
23 | - } |
|
24 | - |
|
25 | - public function testNamedRouteWithParameters() |
|
26 | - { |
|
27 | - $object = new stdClass; |
|
28 | - |
|
29 | - Route::bind('object', function() use ($object) { |
|
30 | - return $object; |
|
31 | - }); |
|
32 | - |
|
33 | - Route::get('/sample/{text}/{object}', ['as' => 'sampleroute', function() use ($object) |
|
34 | - { |
|
35 | - $this->assertSame(['sampleroute', ['blah', $object]], $this->currentRoute->get()); |
|
36 | - }]); |
|
37 | - |
|
38 | - $this->call('GET', '/sample/blah/object'); |
|
39 | - } |
|
40 | - |
|
41 | - /** |
|
42 | - * @expectedException DaveJamesMiller\Breadcrumbs\Exception |
|
43 | - * @expectedExceptionMessage The current route (GET /sample/unnamed) is not named - please check routes.php for an "as" parameter |
|
44 | - */ |
|
45 | - public function testUnnamedRoute() |
|
46 | - { |
|
47 | - Route::get('/sample/unnamed', function() |
|
48 | - { |
|
49 | - $this->assertSame(['sample', []], $this->currentRoute->get()); |
|
50 | - }); |
|
51 | - |
|
52 | - $this->call('GET', '/sample/unnamed'); |
|
53 | - } |
|
54 | - |
|
55 | - public function testSet() |
|
56 | - { |
|
57 | - $this->currentRoute->set('custom', [1, 'blah']); |
|
58 | - |
|
59 | - Route::get('/sample', ['as' => 'sampleroute', function() |
|
60 | - { |
|
61 | - $this->assertSame(['custom', [1, 'blah']], $this->currentRoute->get()); |
|
62 | - }]); |
|
63 | - |
|
64 | - $this->call('GET', '/sample'); |
|
65 | - } |
|
66 | - |
|
67 | - public function testClear() |
|
68 | - { |
|
69 | - $this->currentRoute->set('custom', [1, 'blah']); |
|
70 | - $this->currentRoute->clear(); |
|
71 | - |
|
72 | - Route::get('/sample', ['as' => 'sampleroute', function() |
|
73 | - { |
|
74 | - $this->assertSame(['sampleroute', []], $this->currentRoute->get()); |
|
75 | - }]); |
|
76 | - |
|
77 | - $this->call('GET', '/sample'); |
|
78 | - } |
|
8 | + public function setUp() |
|
9 | + { |
|
10 | + parent::setUp(); |
|
11 | + |
|
12 | + $this->currentRoute = app('DaveJamesMiller\Breadcrumbs\CurrentRoute'); |
|
13 | + } |
|
14 | + |
|
15 | + public function testNamedRoute() |
|
16 | + { |
|
17 | + Route::get('/sample', ['as' => 'sampleroute', function() |
|
18 | + { |
|
19 | + $this->assertSame(['sampleroute', []], $this->currentRoute->get()); |
|
20 | + }]); |
|
21 | + |
|
22 | + $this->call('GET', '/sample'); |
|
23 | + } |
|
24 | + |
|
25 | + public function testNamedRouteWithParameters() |
|
26 | + { |
|
27 | + $object = new stdClass; |
|
28 | + |
|
29 | + Route::bind('object', function() use ($object) { |
|
30 | + return $object; |
|
31 | + }); |
|
32 | + |
|
33 | + Route::get('/sample/{text}/{object}', ['as' => 'sampleroute', function() use ($object) |
|
34 | + { |
|
35 | + $this->assertSame(['sampleroute', ['blah', $object]], $this->currentRoute->get()); |
|
36 | + }]); |
|
37 | + |
|
38 | + $this->call('GET', '/sample/blah/object'); |
|
39 | + } |
|
40 | + |
|
41 | + /** |
|
42 | + * @expectedException DaveJamesMiller\Breadcrumbs\Exception |
|
43 | + * @expectedExceptionMessage The current route (GET /sample/unnamed) is not named - please check routes.php for an "as" parameter |
|
44 | + */ |
|
45 | + public function testUnnamedRoute() |
|
46 | + { |
|
47 | + Route::get('/sample/unnamed', function() |
|
48 | + { |
|
49 | + $this->assertSame(['sample', []], $this->currentRoute->get()); |
|
50 | + }); |
|
51 | + |
|
52 | + $this->call('GET', '/sample/unnamed'); |
|
53 | + } |
|
54 | + |
|
55 | + public function testSet() |
|
56 | + { |
|
57 | + $this->currentRoute->set('custom', [1, 'blah']); |
|
58 | + |
|
59 | + Route::get('/sample', ['as' => 'sampleroute', function() |
|
60 | + { |
|
61 | + $this->assertSame(['custom', [1, 'blah']], $this->currentRoute->get()); |
|
62 | + }]); |
|
63 | + |
|
64 | + $this->call('GET', '/sample'); |
|
65 | + } |
|
66 | + |
|
67 | + public function testClear() |
|
68 | + { |
|
69 | + $this->currentRoute->set('custom', [1, 'blah']); |
|
70 | + $this->currentRoute->clear(); |
|
71 | + |
|
72 | + Route::get('/sample', ['as' => 'sampleroute', function() |
|
73 | + { |
|
74 | + $this->assertSame(['sampleroute', []], $this->currentRoute->get()); |
|
75 | + }]); |
|
76 | + |
|
77 | + $this->call('GET', '/sample'); |
|
78 | + } |
|
79 | 79 | |
80 | 80 | } |
@@ -1,7 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | use DaveJamesMiller\Breadcrumbs\Generator; |
4 | -use Mockery as m; |
|
5 | 4 | |
6 | 5 | class GeneratorTest extends TestCase { |
7 | 6 |
@@ -2,10 +2,10 @@ |
||
2 | 2 | |
3 | 3 | class FacadeTest extends TestCase { |
4 | 4 | |
5 | - public function testFacade() |
|
6 | - { |
|
7 | - $this->assertInstanceOf('DaveJamesMiller\Breadcrumbs\Manager', Breadcrumbs::getFacadeRoot()); |
|
8 | - $this->assertSame($this->app['breadcrumbs'], Breadcrumbs::getFacadeRoot()); |
|
9 | - } |
|
5 | + public function testFacade() |
|
6 | + { |
|
7 | + $this->assertInstanceOf('DaveJamesMiller\Breadcrumbs\Manager', Breadcrumbs::getFacadeRoot()); |
|
8 | + $this->assertSame($this->app['breadcrumbs'], Breadcrumbs::getFacadeRoot()); |
|
9 | + } |
|
10 | 10 | |
11 | 11 | } |
@@ -2,42 +2,42 @@ |
||
2 | 2 | |
3 | 3 | class DependantServiceProviderErrorTest extends TestCase { |
4 | 4 | |
5 | - protected function getPackageProviders() |
|
6 | - { |
|
7 | - return [ |
|
8 | - // These are in the wrong order |
|
9 | - 'DependantServiceProviderError', |
|
10 | - 'DaveJamesMiller\Breadcrumbs\ServiceProvider', |
|
11 | - ]; |
|
12 | - } |
|
13 | - |
|
14 | - protected function loadServiceProvider() |
|
15 | - { |
|
16 | - // Disabled - we want to test the automatic loading instead |
|
17 | - } |
|
18 | - |
|
19 | - /** |
|
20 | - * @expectedException DaveJamesMiller\Breadcrumbs\Exception |
|
21 | - * @expectedExceptionMessage Breadcrumbs view not specified |
|
22 | - */ |
|
23 | - public function testRender() |
|
24 | - { |
|
25 | - Breadcrumbs::render('home'); |
|
26 | - } |
|
5 | + protected function getPackageProviders() |
|
6 | + { |
|
7 | + return [ |
|
8 | + // These are in the wrong order |
|
9 | + 'DependantServiceProviderError', |
|
10 | + 'DaveJamesMiller\Breadcrumbs\ServiceProvider', |
|
11 | + ]; |
|
12 | + } |
|
13 | + |
|
14 | + protected function loadServiceProvider() |
|
15 | + { |
|
16 | + // Disabled - we want to test the automatic loading instead |
|
17 | + } |
|
18 | + |
|
19 | + /** |
|
20 | + * @expectedException DaveJamesMiller\Breadcrumbs\Exception |
|
21 | + * @expectedExceptionMessage Breadcrumbs view not specified |
|
22 | + */ |
|
23 | + public function testRender() |
|
24 | + { |
|
25 | + Breadcrumbs::render('home'); |
|
26 | + } |
|
27 | 27 | |
28 | 28 | } |
29 | 29 | |
30 | 30 | class DependantServiceProviderError extends Illuminate\Support\ServiceProvider { |
31 | 31 | |
32 | - public function register() |
|
33 | - { |
|
34 | - } |
|
32 | + public function register() |
|
33 | + { |
|
34 | + } |
|
35 | 35 | |
36 | - public function boot() |
|
37 | - { |
|
38 | - Breadcrumbs::register('home', function($breadcrumbs) { |
|
39 | - $breadcrumbs->push('Home', '/'); |
|
40 | - }); |
|
41 | - } |
|
36 | + public function boot() |
|
37 | + { |
|
38 | + Breadcrumbs::register('home', function($breadcrumbs) { |
|
39 | + $breadcrumbs->push('Home', '/'); |
|
40 | + }); |
|
41 | + } |
|
42 | 42 | |
43 | 43 | } |
@@ -2,38 +2,38 @@ |
||
2 | 2 | |
3 | 3 | class DependantServiceProviderTest extends TestCase { |
4 | 4 | |
5 | - protected function getPackageProviders() |
|
6 | - { |
|
7 | - return [ |
|
8 | - 'DaveJamesMiller\Breadcrumbs\ServiceProvider', |
|
9 | - 'DependantServiceProvider', |
|
10 | - ]; |
|
11 | - } |
|
12 | - |
|
13 | - protected function loadServiceProvider() |
|
14 | - { |
|
15 | - // Disabled - we want to test the automatic loading instead |
|
16 | - } |
|
17 | - |
|
18 | - public function testRender() |
|
19 | - { |
|
20 | - $html = Breadcrumbs::render('home'); |
|
21 | - $this->assertXmlStringEqualsXmlFile(__DIR__ . '/../fixtures/DependantServiceProvider.html', $html); |
|
22 | - } |
|
5 | + protected function getPackageProviders() |
|
6 | + { |
|
7 | + return [ |
|
8 | + 'DaveJamesMiller\Breadcrumbs\ServiceProvider', |
|
9 | + 'DependantServiceProvider', |
|
10 | + ]; |
|
11 | + } |
|
12 | + |
|
13 | + protected function loadServiceProvider() |
|
14 | + { |
|
15 | + // Disabled - we want to test the automatic loading instead |
|
16 | + } |
|
17 | + |
|
18 | + public function testRender() |
|
19 | + { |
|
20 | + $html = Breadcrumbs::render('home'); |
|
21 | + $this->assertXmlStringEqualsXmlFile(__DIR__ . '/../fixtures/DependantServiceProvider.html', $html); |
|
22 | + } |
|
23 | 23 | |
24 | 24 | } |
25 | 25 | |
26 | 26 | class DependantServiceProvider extends Illuminate\Support\ServiceProvider { |
27 | 27 | |
28 | - public function register() |
|
29 | - { |
|
30 | - } |
|
28 | + public function register() |
|
29 | + { |
|
30 | + } |
|
31 | 31 | |
32 | - public function boot() |
|
33 | - { |
|
34 | - Breadcrumbs::register('home', function($breadcrumbs) { |
|
35 | - $breadcrumbs->push('Home', '/'); |
|
36 | - }); |
|
37 | - } |
|
32 | + public function boot() |
|
33 | + { |
|
34 | + Breadcrumbs::register('home', function($breadcrumbs) { |
|
35 | + $breadcrumbs->push('Home', '/'); |
|
36 | + }); |
|
37 | + } |
|
38 | 38 | |
39 | 39 | } |