@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | return [ |
4 | - 'providers' => [ |
|
4 | + 'providers' => [ |
|
5 | 5 | 0 => 'App\\Plugins\\Ccavanue\\ServiceProvider', |
6 | 6 | 1 => 'App\\Plugins\\Ping\\ServiceProvider', |
7 | 7 | 2 => 'App\\Plugins\\Twilio\\ServiceProvider', |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | 29 => 'App\\Providers\\EventServiceProvider', |
35 | 35 | 30 => 'App\\Providers\\RouteServiceProvider', |
36 | 36 | 31 => 'Illuminate\\Broadcasting\\BroadcastServiceProvider', |
37 | - ], |
|
38 | - 'eager' => [ |
|
37 | + ], |
|
38 | + 'eager' => [ |
|
39 | 39 | 0 => 'App\\Plugins\\Ccavanue\\ServiceProvider', |
40 | 40 | 1 => 'App\\Plugins\\Ping\\ServiceProvider', |
41 | 41 | 2 => 'App\\Plugins\\Twilio\\ServiceProvider', |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | 15 => 'App\\Providers\\AppServiceProvider', |
55 | 55 | 16 => 'App\\Providers\\EventServiceProvider', |
56 | 56 | 17 => 'App\\Providers\\RouteServiceProvider', |
57 | - ], |
|
58 | - 'deferred' => [ |
|
57 | + ], |
|
58 | + 'deferred' => [ |
|
59 | 59 | 'Illuminate\\Bus\\Dispatcher' => 'Illuminate\\Bus\\BusServiceProvider', |
60 | 60 | 'Illuminate\\Contracts\\Bus\\Dispatcher' => 'Illuminate\\Bus\\BusServiceProvider', |
61 | 61 | 'Illuminate\\Contracts\\Bus\\QueueingDispatcher' => 'Illuminate\\Bus\\BusServiceProvider', |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | 'Illuminate\\Broadcasting\\BroadcastManager' => 'Illuminate\\Broadcasting\\BroadcastServiceProvider', |
123 | 123 | 'Illuminate\\Contracts\\Broadcasting\\Factory' => 'Illuminate\\Broadcasting\\BroadcastServiceProvider', |
124 | 124 | 'Illuminate\\Contracts\\Broadcasting\\Broadcaster' => 'Illuminate\\Broadcasting\\BroadcastServiceProvider', |
125 | - ], |
|
126 | - 'when' => [ |
|
125 | + ], |
|
126 | + 'when' => [ |
|
127 | 127 | 'Illuminate\\Bus\\BusServiceProvider' => [ |
128 | 128 | ], |
129 | 129 | 'Illuminate\\Cache\\CacheServiceProvider' => [ |
@@ -152,5 +152,5 @@ discard block |
||
152 | 152 | ], |
153 | 153 | 'Illuminate\\Broadcasting\\BroadcastServiceProvider' => [ |
154 | 154 | ], |
155 | - ], |
|
155 | + ], |
|
156 | 156 | ]; |
@@ -58,6 +58,9 @@ |
||
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
61 | + /** |
|
62 | + * @param Exception $e |
|
63 | + */ |
|
61 | 64 | protected function renderException($e) { |
62 | 65 | |
63 | 66 | switch ($e) { |
@@ -63,7 +63,7 @@ |
||
63 | 63 | switch ($e) { |
64 | 64 | |
65 | 65 | case ($e instanceof ModelNotFoundException): |
66 | - return redirect('/')->with('fails',"Please configure ". $e->getMessage()); |
|
66 | + return redirect('/')->with('fails', "Please configure " . $e->getMessage()); |
|
67 | 67 | break; |
68 | 68 | |
69 | 69 | default: |
@@ -151,6 +151,9 @@ |
||
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
154 | + /** |
|
155 | + * @param Invoice $invoice |
|
156 | + */ |
|
154 | 157 | public function checkoutAction($invoice) { |
155 | 158 | try { |
156 | 159 | //dd($invoice); |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | $from = $settings->email; |
120 | 120 | $to = $this->user->email; |
121 | 121 | $data = $this->template->where('id', $settings->where('id', 1)->first()->welcome_mail)->first()->data; |
122 | - $replace = ['name' => $this->user->first_name . ' ' . $this->user->last_name, 'username' => $this->user->email, 'password' => $str,'url'=>$url]; |
|
122 | + $replace = ['name' => $this->user->first_name . ' ' . $this->user->last_name, 'username' => $this->user->email, 'password' => $str, 'url'=>$url]; |
|
123 | 123 | $this->templateController->Mailing($from, $to, $data, 'Welcome Email', $replace); |
124 | 124 | |
125 | 125 | \Auth::login($this->user); |
@@ -166,16 +166,16 @@ discard block |
||
166 | 166 | //get system values |
167 | 167 | $settings = new Setting(); |
168 | 168 | $settings = $settings->findOrFail(1); |
169 | - $name = \Auth::user()->first_name.' '.\Auth::user()->last_name; |
|
169 | + $name = \Auth::user()->first_name . ' ' . \Auth::user()->last_name; |
|
170 | 170 | $from = $settings->email; |
171 | 171 | $to = \Auth::user()->email; |
172 | - $data = $this->template->where('name','download link')->first()->data; |
|
172 | + $data = $this->template->where('name', 'download link')->first()->data; |
|
173 | 173 | $subject = "download"; |
174 | - $replace = ['url'=>$url,'name'=>$name,'product'=>$product]; |
|
174 | + $replace = ['url'=>$url, 'name'=>$name, 'product'=>$product]; |
|
175 | 175 | |
176 | 176 | //send mail |
177 | 177 | $template_controller = new TemplateController(); |
178 | - $template_controller->Mailing($from, $to, $data, $subject,$replace); |
|
178 | + $template_controller->Mailing($from, $to, $data, $subject, $replace); |
|
179 | 179 | } catch (\Exception $ex) { |
180 | 180 | dd($ex); |
181 | 181 | return redirect()->back()->with('fails', $ex->getMessage()); |
@@ -2,9 +2,7 @@ |
||
2 | 2 | |
3 | 3 | namespace App\Http\Controllers\Github; |
4 | 4 | |
5 | -use Illuminate\Http\Request; |
|
6 | -use App\Http\Requests; |
|
7 | -use App\Http\Controllers\Controller; |
|
5 | +use App\Http\Controllers\Controller; |
|
8 | 6 | use App\Model\Github\Github; |
9 | 7 | |
10 | 8 | class GithubApiController extends Controller { |
@@ -21,7 +21,7 @@ |
||
21 | 21 | $this->password = $this->github->password; |
22 | 22 | } |
23 | 23 | |
24 | - public function postCurl($url,$data='',$method="POST") { |
|
24 | + public function postCurl($url, $data = '', $method = "POST") { |
|
25 | 25 | $ch = curl_init(); |
26 | 26 | curl_setopt($ch, CURLOPT_URL, $url); |
27 | 27 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); |
@@ -86,7 +86,6 @@ discard block |
||
86 | 86 | |
87 | 87 | /** |
88 | 88 | * List only one release by tag |
89 | - * @param Request $request |
|
90 | 89 | * @return type |
91 | 90 | */ |
92 | 91 | public function getReleaseByTag($owner,$repo) { |
@@ -149,7 +148,7 @@ discard block |
||
149 | 148 | /** |
150 | 149 | * |
151 | 150 | * @param type $release |
152 | - * @return type .zip file |
|
151 | + * @return null|\Illuminate\Http\RedirectResponse .zip file |
|
153 | 152 | */ |
154 | 153 | public function download($release) { |
155 | 154 | try { |
@@ -2,7 +2,6 @@ |
||
2 | 2 | |
3 | 3 | namespace App\Plugins\Twilio\Controllers; |
4 | 4 | |
5 | -use App\Http\Requests; |
|
6 | 5 | use App\Http\Controllers\Controller; |
7 | 6 | use Illuminate\Http\Request; |
8 | 7 | use App\Plugins\Twilio\Model\Twilio; |
@@ -180,7 +180,7 @@ |
||
180 | 180 | } |
181 | 181 | |
182 | 182 | public function postSettings(Request $request){ |
183 | - $this->validate($request, [ |
|
183 | + $this->validate($request, [ |
|
184 | 184 | "username"=>"required", |
185 | 185 | "password"=>"required" |
186 | 186 | ]); |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * List all release |
74 | 74 | * @return type |
75 | 75 | */ |
76 | - public function listRepositories($owner,$repo) { |
|
76 | + public function listRepositories($owner, $repo) { |
|
77 | 77 | try { |
78 | 78 | $url = "https://api.github.com/repos/$owner/$repo/releases"; |
79 | 79 | $releases = $this->github_api->getCurl($url); |
@@ -89,10 +89,10 @@ discard block |
||
89 | 89 | * @param Request $request |
90 | 90 | * @return type |
91 | 91 | */ |
92 | - public function getReleaseByTag($owner,$repo) { |
|
92 | + public function getReleaseByTag($owner, $repo) { |
|
93 | 93 | try { |
94 | 94 | $tag = \Input::get('tag'); |
95 | - $all_releases = $this->listRepositories($owner,$repo); |
|
95 | + $all_releases = $this->listRepositories($owner, $repo); |
|
96 | 96 | //dd($all_releases); |
97 | 97 | if ($tag) { |
98 | 98 | foreach ($all_releases as $key => $release) { |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | //dd($version); |
109 | 109 | //execute download |
110 | 110 | |
111 | - if($this->download($version)=="success"){ |
|
111 | + if ($this->download($version) == "success") { |
|
112 | 112 | return "success"; |
113 | 113 | } |
114 | 114 | //return redirect()->back()->with('success', \Lang::get('message.downloaded-successfully')); |
@@ -173,20 +173,20 @@ discard block |
||
173 | 173 | public function getSettings() { |
174 | 174 | try { |
175 | 175 | $model = $this->github; |
176 | - return view('themes.default1.github.settings', compact('model')); |
|
176 | + return view('themes.default1.github.settings', compact('model')); |
|
177 | 177 | } catch (Exception $ex) { |
178 | 178 | return redirect('/')->with('fails', $ex->getMessage()); |
179 | 179 | } |
180 | 180 | } |
181 | 181 | |
182 | - public function postSettings(Request $request){ |
|
182 | + public function postSettings(Request $request) { |
|
183 | 183 | $this->validate($request, [ |
184 | 184 | "username"=>"required", |
185 | 185 | "password"=>"required" |
186 | 186 | ]); |
187 | - try{ |
|
187 | + try { |
|
188 | 188 | $this->github->fill($request->input())->save(); |
189 | - return redirect()->back()->with('success',\Lang::get('message.updated-successfully')); |
|
189 | + return redirect()->back()->with('success', \Lang::get('message.updated-successfully')); |
|
190 | 190 | } catch (Exception $ex) { |
191 | 191 | return redirect()->back()->with('fails', $ex->getMessage()); |
192 | 192 | } |
@@ -3,7 +3,6 @@ |
||
3 | 3 | namespace App\Http\Controllers\Product; |
4 | 4 | |
5 | 5 | use App\Http\Controllers\Controller; |
6 | -use App\Http\Requests\Product\ProductRequest; |
|
7 | 6 | use App\Model\Payment\Currency; |
8 | 7 | use App\Model\Payment\Plan; |
9 | 8 | use App\Model\Product\Addon; |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | |
28 | 28 | public function __construct() { |
29 | 29 | $this->middleware('auth'); |
30 | - $this->middleware('admin',['except' => ['userDownload']]); |
|
30 | + $this->middleware('admin', ['except' => ['userDownload']]); |
|
31 | 31 | |
32 | 32 | $product = new Product(); |
33 | 33 | $this->product = $product; |
@@ -71,13 +71,13 @@ discard block |
||
71 | 71 | |
72 | 72 | // try { |
73 | 73 | return \Datatable::collection($this->product->select('id', 'name', 'type', 'group')->where('id', '!=', 1)->get()) |
74 | - ->addColumn('#', function ($model) { |
|
74 | + ->addColumn('#', function($model) { |
|
75 | 75 | return "<input type='checkbox' value=" . $model->id . ' name=select[] id=check>'; |
76 | 76 | }) |
77 | - ->addColumn('name', function ($model) { |
|
77 | + ->addColumn('name', function($model) { |
|
78 | 78 | return ucfirst($model->name); |
79 | 79 | }) |
80 | - ->addColumn('type', function ($model) { |
|
80 | + ->addColumn('type', function($model) { |
|
81 | 81 | //dd($model->type()); |
82 | 82 | if ($this->type->where('id', $model->type)->first()) { |
83 | 83 | return $this->type->where('id', $model->type)->first()->name; |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | return 'Not available'; |
86 | 86 | } |
87 | 87 | }) |
88 | - ->addColumn('group', function ($model) { |
|
88 | + ->addColumn('group', function($model) { |
|
89 | 89 | //dd($model->type()); |
90 | 90 | if ($this->group->where('id', $model->group)->first()) { |
91 | 91 | return $this->group->where('id', $model->group)->first()->name; |
@@ -93,21 +93,21 @@ discard block |
||
93 | 93 | return 'Not available'; |
94 | 94 | } |
95 | 95 | }) |
96 | - ->addColumn('price', function ($model) { |
|
96 | + ->addColumn('price', function($model) { |
|
97 | 97 | if ($this->price->where('product_id', $model->id)->first()) { |
98 | 98 | return $this->price->where('product_id', $model->id)->first()->price; |
99 | 99 | } else { |
100 | 100 | return 'Not available'; |
101 | 101 | } |
102 | 102 | }) |
103 | - ->addColumn('currency', function ($model) { |
|
103 | + ->addColumn('currency', function($model) { |
|
104 | 104 | if ($this->price->where('product_id', $model->id)->first()) { |
105 | 105 | return $this->price->where('product_id', $model->id)->first()->currency; |
106 | 106 | } else { |
107 | 107 | return 'Not available'; |
108 | 108 | } |
109 | 109 | }) |
110 | - ->addColumn('action', function ($model) { |
|
110 | + ->addColumn('action', function($model) { |
|
111 | 111 | return '<a href=' . url('products/' . $model->id . '/edit') . " class='btn btn-sm btn-primary'>Edit</a>"; |
112 | 112 | }) |
113 | 113 | ->searchColumns('name', 'email') |
@@ -161,11 +161,11 @@ discard block |
||
161 | 161 | 'price.*' => 'required', |
162 | 162 | ]); |
163 | 163 | $v->sometimes(['file', 'image'], 'required', function($input) { |
164 | - return ($input->type == 2 && $input->github_owner == '' && $input->github_repository == '' ); |
|
164 | + return ($input->type == 2 && $input->github_owner == '' && $input->github_repository == ''); |
|
165 | 165 | }); |
166 | 166 | |
167 | 167 | $v->sometimes(['github_owner', 'github_repository'], 'required', function($input) { |
168 | - return ($input->type == 2 && $input->file == '' && $input->image == '' ); |
|
168 | + return ($input->type == 2 && $input->file == '' && $input->image == ''); |
|
169 | 169 | }); |
170 | 170 | if ($v->fails()) { |
171 | 171 | return redirect()->back()->with('errors', $v->errors()); |
@@ -272,11 +272,11 @@ discard block |
||
272 | 272 | 'price.*' => 'required', |
273 | 273 | ]); |
274 | 274 | $v->sometimes(['file', 'image'], 'required', function($input) { |
275 | - return ($input->type == 2 && $input->github_owner == '' && $input->github_repository == '' ); |
|
275 | + return ($input->type == 2 && $input->github_owner == '' && $input->github_repository == ''); |
|
276 | 276 | }); |
277 | 277 | |
278 | 278 | $v->sometimes(['github_owner', 'github_repository'], 'required', function($input) { |
279 | - return ($input->type == 2 && $input->file == '' && $input->image == '' ); |
|
279 | + return ($input->type == 2 && $input->file == '' && $input->image == ''); |
|
280 | 280 | }); |
281 | 281 | if ($v->fails()) { |
282 | 282 | return redirect()->back()->with('errors', $v->errors()); |
@@ -392,20 +392,20 @@ discard block |
||
392 | 392 | return $server; |
393 | 393 | } |
394 | 394 | |
395 | - public function downloadProduct($id){ |
|
396 | - try{ |
|
395 | + public function downloadProduct($id) { |
|
396 | + try { |
|
397 | 397 | $product = $this->product->findOrFail($id); |
398 | 398 | //dd($product); |
399 | 399 | $type = $product->type; |
400 | 400 | $owner = $product->github_owner; |
401 | 401 | $repository = $product->github_repository; |
402 | 402 | $file = $product->file; |
403 | - if($type==2){ |
|
404 | - if($owner&&$repository){ |
|
403 | + if ($type == 2) { |
|
404 | + if ($owner && $repository) { |
|
405 | 405 | //dd($repository); |
406 | 406 | $github_controller = new \App\Http\Controllers\Github\GithubController(); |
407 | 407 | return $github_controller->getReleaseByTag($owner, $repository); |
408 | - }elseif($file){ |
|
408 | + }elseif ($file) { |
|
409 | 409 | $file = storage_path() . '/products/' . $file; |
410 | 410 | return \Response::download($file); |
411 | 411 | } |
@@ -415,23 +415,23 @@ discard block |
||
415 | 415 | } |
416 | 416 | } |
417 | 417 | |
418 | - public function userDownload($userid,$invoice_number){ |
|
419 | - try{ |
|
418 | + public function userDownload($userid, $invoice_number) { |
|
419 | + try { |
|
420 | 420 | $user = new \App\User(); |
421 | 421 | $user = $user->findOrFail($userid); |
422 | 422 | $invoice = new \App\Model\Order\Invoice(); |
423 | - $invoice = $invoice->where('number',$invoice_number)->first(); |
|
424 | - if($user&&$invoice){ |
|
425 | - if($user->active==1){ |
|
423 | + $invoice = $invoice->where('number', $invoice_number)->first(); |
|
424 | + if ($user && $invoice) { |
|
425 | + if ($user->active == 1) { |
|
426 | 426 | $invoice_item = new \App\Model\Order\InvoiceItem(); |
427 | - $item = $invoice_item->where('invoice_id',$invoice->id)->first(); |
|
428 | - $product_id= $this->product->where('name',$item->product_name)->first()->id; |
|
427 | + $item = $invoice_item->where('invoice_id', $invoice->id)->first(); |
|
428 | + $product_id = $this->product->where('name', $item->product_name)->first()->id; |
|
429 | 429 | $this->downloadProduct($product_id); |
430 | - }else{ |
|
431 | - return redirect('auth/login')->with('fails',\Lang::get('activate-your-account')); |
|
430 | + } else { |
|
431 | + return redirect('auth/login')->with('fails', \Lang::get('activate-your-account')); |
|
432 | 432 | } |
433 | - }else{ |
|
434 | - return redirect('auth/login')->with('fails',\Lang::get('please-purcahse-a-product')); |
|
433 | + } else { |
|
434 | + return redirect('auth/login')->with('fails', \Lang::get('please-purcahse-a-product')); |
|
435 | 435 | } |
436 | 436 | } catch (Exception $ex) { |
437 | 437 |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | //dd($repository); |
406 | 406 | $github_controller = new \App\Http\Controllers\Github\GithubController(); |
407 | 407 | return $github_controller->getReleaseByTag($owner, $repository); |
408 | - }elseif($file){ |
|
408 | + } elseif($file){ |
|
409 | 409 | $file = storage_path() . '/products/' . $file; |
410 | 410 | return \Response::download($file); |
411 | 411 | } |
@@ -427,10 +427,10 @@ discard block |
||
427 | 427 | $item = $invoice_item->where('invoice_id',$invoice->id)->first(); |
428 | 428 | $product_id= $this->product->where('name',$item->product_name)->first()->id; |
429 | 429 | $this->downloadProduct($product_id); |
430 | - }else{ |
|
430 | + } else{ |
|
431 | 431 | return redirect('auth/login')->with('fails',\Lang::get('activate-your-account')); |
432 | 432 | } |
433 | - }else{ |
|
433 | + } else{ |
|
434 | 434 | return redirect('auth/login')->with('fails',\Lang::get('please-purcahse-a-product')); |
435 | 435 | } |
436 | 436 | } catch (Exception $ex) { |
@@ -4,7 +4,6 @@ |
||
4 | 4 | |
5 | 5 | use Closure; |
6 | 6 | use Illuminate\Contracts\Auth\Guard; |
7 | -use App\User; |
|
8 | 7 | |
9 | 8 | class Authenticate |
10 | 9 | { |
@@ -45,7 +45,7 @@ |
||
45 | 45 | } |
46 | 46 | } |
47 | 47 | if(\Auth::user()->active==1){ |
48 | - return $next($request); |
|
48 | + return $next($request); |
|
49 | 49 | }else{ |
50 | 50 | \Auth::logout(); |
51 | 51 | return redirect('home')->with('fails','Activate Your Account'); |
@@ -44,11 +44,11 @@ |
||
44 | 44 | return redirect()->guest('auth/login'); |
45 | 45 | } |
46 | 46 | } |
47 | - if(\Auth::user()->active==1){ |
|
47 | + if (\Auth::user()->active == 1) { |
|
48 | 48 | return $next($request); |
49 | - }else{ |
|
49 | + } else { |
|
50 | 50 | \Auth::logout(); |
51 | - return redirect('home')->with('fails','Activate Your Account'); |
|
51 | + return redirect('home')->with('fails', 'Activate Your Account'); |
|
52 | 52 | } |
53 | 53 | } |
54 | 54 | } |
@@ -292,7 +292,7 @@ |
||
292 | 292 | if ($product) { |
293 | 293 | $productCurrency = $product->price()->where('currency', $currency)->first()->currency; |
294 | 294 | $currency = $this->currency->where('code', $productCurrency)->get()->toArray(); |
295 | - }else{ |
|
295 | + } else{ |
|
296 | 296 | $currency=[]; |
297 | 297 | } |
298 | 298 | return $currency; |
@@ -8,7 +8,6 @@ |
||
8 | 8 | use App\Model\Payment\PromotionType; |
9 | 9 | use App\Model\Product\Product; |
10 | 10 | use App\Model\Product\ProductGroup; |
11 | -use App\Model\Product\Subscription; |
|
12 | 11 | use App\Model\Product\Type; |
13 | 12 | use Illuminate\Database\Eloquent\Model; |
14 | 13 | use Illuminate\Database\Seeder; |
@@ -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 |
@@ -5,185 +5,185 @@ |
||
5 | 5 | |
6 | 6 | class GeneratorTest extends TestCase { |
7 | 7 | |
8 | - public function setUp() |
|
9 | - { |
|
10 | - parent::setUp(); |
|
11 | - |
|
12 | - $this->generator = new Generator; |
|
13 | - } |
|
14 | - |
|
15 | - public function testCallbacks() |
|
16 | - { |
|
17 | - $this->generator->generate([ |
|
18 | - 'sample' => function($breadcrumbs) |
|
19 | - { |
|
20 | - $this->assertSame($this->generator, $breadcrumbs); |
|
21 | - }, |
|
22 | - ], 'sample', []); |
|
23 | - } |
|
24 | - |
|
25 | - public function testCallbackParameters() |
|
26 | - { |
|
27 | - $this->generator->generate([ |
|
28 | - 'sample' => function($breadcrumbs, $num, $text) |
|
29 | - { |
|
30 | - $this->assertSame(1, $num); |
|
31 | - $this->assertSame('blah', $text); |
|
32 | - }, |
|
33 | - ], 'sample', [1, 'blah']); |
|
34 | - } |
|
35 | - |
|
36 | - // $breadcrumbs->push($title) |
|
37 | - // $breadcrumb->title |
|
38 | - public function testPush_title() |
|
39 | - { |
|
40 | - $breadcrumbs = $this->generator->generate([ |
|
41 | - 'sample' => function($breadcrumbs) |
|
42 | - { |
|
43 | - $breadcrumbs->push('Home'); |
|
44 | - }, |
|
45 | - ], 'sample', []); |
|
46 | - |
|
47 | - $this->assertCount(1, $breadcrumbs); |
|
48 | - $this->assertSame('Home', $breadcrumbs[0]->title); |
|
49 | - $this->assertNull($breadcrumbs[0]->url); |
|
50 | - } |
|
51 | - |
|
52 | - // $breadcrumbs->push($title, $url) |
|
53 | - // $breadcrumb->url |
|
54 | - public function testPush_title_url() |
|
55 | - { |
|
56 | - $breadcrumbs = $this->generator->generate([ |
|
57 | - 'sample' => function($breadcrumbs) |
|
58 | - { |
|
59 | - $breadcrumbs->push('Home', '/'); |
|
60 | - }, |
|
61 | - ], 'sample', []); |
|
62 | - |
|
63 | - $this->assertCount(1, $breadcrumbs); |
|
64 | - $this->assertSame('Home', $breadcrumbs[0]->title); |
|
65 | - $this->assertSame('/', $breadcrumbs[0]->url); |
|
66 | - } |
|
67 | - |
|
68 | - // $breadcrumbs->push($title, $url, $data) |
|
69 | - // $breadcrumb->custom_attribute_name |
|
70 | - public function testPush_title_url_data() |
|
71 | - { |
|
72 | - $data = [ |
|
73 | - 'foo' => 'bar', |
|
74 | - 'baz' => 'qux', |
|
75 | - 'title' => 'should not be overwritten by custom data', |
|
76 | - ]; |
|
77 | - |
|
78 | - $breadcrumbs = $this->generator->generate([ |
|
79 | - 'sample' => function($breadcrumbs) |
|
80 | - { |
|
81 | - $breadcrumbs->push('Home', '/', ['foo' => 'bar', 'title' => 'ignored']); |
|
82 | - }, |
|
83 | - ], 'sample', []); |
|
84 | - |
|
85 | - $this->assertCount(1, $breadcrumbs); |
|
86 | - $this->assertSame('Home', $breadcrumbs[0]->title); |
|
87 | - $this->assertSame('/', $breadcrumbs[0]->url); |
|
88 | - $this->assertSame('bar', $breadcrumbs[0]->foo); |
|
89 | - } |
|
90 | - |
|
91 | - public function testPushMultipleTimes() |
|
92 | - { |
|
93 | - $breadcrumbs = $this->generator->generate([ |
|
94 | - 'sample' => function($breadcrumbs) |
|
95 | - { |
|
96 | - $breadcrumbs->push('Level 1', '/1'); |
|
97 | - $breadcrumbs->push('Level 2', '/2'); |
|
98 | - $breadcrumbs->push('Level 3', '/3'); |
|
99 | - }, |
|
100 | - ], 'sample', []); |
|
101 | - |
|
102 | - $this->assertCount(3, $breadcrumbs); |
|
103 | - $this->assertSame('Level 1', $breadcrumbs[0]->title); |
|
104 | - $this->assertSame('Level 2', $breadcrumbs[1]->title); |
|
105 | - $this->assertSame('Level 3', $breadcrumbs[2]->title); |
|
106 | - $this->assertSame('/1', $breadcrumbs[0]->url); |
|
107 | - $this->assertSame('/2', $breadcrumbs[1]->url); |
|
108 | - $this->assertSame('/3', $breadcrumbs[2]->url); |
|
109 | - } |
|
110 | - |
|
111 | - // $breadcrumbs->parent($name) |
|
112 | - public function testParent_name() |
|
113 | - { |
|
114 | - $breadcrumbs = $this->generator->generate([ |
|
115 | - 'home' => function($breadcrumbs) |
|
116 | - { |
|
117 | - $breadcrumbs->push('Home', '/'); |
|
118 | - }, |
|
119 | - 'sample' => function($breadcrumbs) |
|
120 | - { |
|
121 | - $breadcrumbs->parent('home'); |
|
122 | - $breadcrumbs->push('Page', '/page'); |
|
123 | - }, |
|
124 | - ], 'sample', []); |
|
125 | - |
|
126 | - $this->assertCount(2, $breadcrumbs); |
|
127 | - $this->assertSame('Home', $breadcrumbs[0]->title); |
|
128 | - $this->assertSame('/', $breadcrumbs[0]->url); |
|
129 | - $this->assertSame('Page', $breadcrumbs[1]->title); |
|
130 | - $this->assertSame('/page', $breadcrumbs[1]->url); |
|
131 | - } |
|
132 | - |
|
133 | - // $breadcrumbs->parent($name, $param1, ...) |
|
134 | - public function testParent_name_params() |
|
135 | - { |
|
136 | - $breadcrumbs = $this->generator->generate([ |
|
137 | - 'parent' => function($breadcrumbs, $num, $text) |
|
138 | - { |
|
139 | - $this->assertSame(1, $num); |
|
140 | - $this->assertSame('blah', $text); |
|
141 | - }, |
|
142 | - 'sample' => function($breadcrumbs) |
|
143 | - { |
|
144 | - $breadcrumbs->parent('parent', 1, 'blah'); |
|
145 | - }, |
|
146 | - ], 'sample', []); |
|
147 | - } |
|
148 | - |
|
149 | - // $breadcrumbs->parentArray($name, $params) |
|
150 | - public function testParentArray_name_params() |
|
151 | - { |
|
152 | - $breadcrumbs = $this->generator->generate([ |
|
153 | - 'parent' => function($breadcrumbs, $num, $text) |
|
154 | - { |
|
155 | - $this->assertSame(1, $num); |
|
156 | - $this->assertSame('blah', $text); |
|
157 | - }, |
|
158 | - 'sample' => function($breadcrumbs) |
|
159 | - { |
|
160 | - $breadcrumbs->parentArray('parent', [1, 'blah']); |
|
161 | - }, |
|
162 | - ], 'sample', []); |
|
163 | - } |
|
164 | - |
|
165 | - // $breadcrumb->first |
|
166 | - // $breadcrumb->last |
|
167 | - public function testFirstLast() |
|
168 | - { |
|
169 | - $breadcrumbs = $this->generator->generate([ |
|
170 | - 'sample' => function($breadcrumbs) |
|
171 | - { |
|
172 | - $breadcrumbs->push('Level 1', '/1'); |
|
173 | - $breadcrumbs->push('Level 2', '/2'); |
|
174 | - $breadcrumbs->push('Level 3', '/3'); |
|
175 | - }, |
|
176 | - ], 'sample', []); |
|
177 | - |
|
178 | - $this->assertCount(3, $breadcrumbs); |
|
179 | - |
|
180 | - $this->assertTrue($breadcrumbs[0]->first, '$breadcrumbs[0]->first'); |
|
181 | - $this->assertFalse($breadcrumbs[1]->first, '$breadcrumbs[1]->first'); |
|
182 | - $this->assertFalse($breadcrumbs[2]->first, '$breadcrumbs[2]->first'); |
|
183 | - |
|
184 | - $this->assertFalse($breadcrumbs[0]->last, '$breadcrumbs[0]->last'); |
|
185 | - $this->assertFalse($breadcrumbs[1]->last, '$breadcrumbs[1]->last'); |
|
186 | - $this->assertTrue($breadcrumbs[2]->last, '$breadcrumbs[2]->last'); |
|
187 | - } |
|
8 | + public function setUp() |
|
9 | + { |
|
10 | + parent::setUp(); |
|
11 | + |
|
12 | + $this->generator = new Generator; |
|
13 | + } |
|
14 | + |
|
15 | + public function testCallbacks() |
|
16 | + { |
|
17 | + $this->generator->generate([ |
|
18 | + 'sample' => function($breadcrumbs) |
|
19 | + { |
|
20 | + $this->assertSame($this->generator, $breadcrumbs); |
|
21 | + }, |
|
22 | + ], 'sample', []); |
|
23 | + } |
|
24 | + |
|
25 | + public function testCallbackParameters() |
|
26 | + { |
|
27 | + $this->generator->generate([ |
|
28 | + 'sample' => function($breadcrumbs, $num, $text) |
|
29 | + { |
|
30 | + $this->assertSame(1, $num); |
|
31 | + $this->assertSame('blah', $text); |
|
32 | + }, |
|
33 | + ], 'sample', [1, 'blah']); |
|
34 | + } |
|
35 | + |
|
36 | + // $breadcrumbs->push($title) |
|
37 | + // $breadcrumb->title |
|
38 | + public function testPush_title() |
|
39 | + { |
|
40 | + $breadcrumbs = $this->generator->generate([ |
|
41 | + 'sample' => function($breadcrumbs) |
|
42 | + { |
|
43 | + $breadcrumbs->push('Home'); |
|
44 | + }, |
|
45 | + ], 'sample', []); |
|
46 | + |
|
47 | + $this->assertCount(1, $breadcrumbs); |
|
48 | + $this->assertSame('Home', $breadcrumbs[0]->title); |
|
49 | + $this->assertNull($breadcrumbs[0]->url); |
|
50 | + } |
|
51 | + |
|
52 | + // $breadcrumbs->push($title, $url) |
|
53 | + // $breadcrumb->url |
|
54 | + public function testPush_title_url() |
|
55 | + { |
|
56 | + $breadcrumbs = $this->generator->generate([ |
|
57 | + 'sample' => function($breadcrumbs) |
|
58 | + { |
|
59 | + $breadcrumbs->push('Home', '/'); |
|
60 | + }, |
|
61 | + ], 'sample', []); |
|
62 | + |
|
63 | + $this->assertCount(1, $breadcrumbs); |
|
64 | + $this->assertSame('Home', $breadcrumbs[0]->title); |
|
65 | + $this->assertSame('/', $breadcrumbs[0]->url); |
|
66 | + } |
|
67 | + |
|
68 | + // $breadcrumbs->push($title, $url, $data) |
|
69 | + // $breadcrumb->custom_attribute_name |
|
70 | + public function testPush_title_url_data() |
|
71 | + { |
|
72 | + $data = [ |
|
73 | + 'foo' => 'bar', |
|
74 | + 'baz' => 'qux', |
|
75 | + 'title' => 'should not be overwritten by custom data', |
|
76 | + ]; |
|
77 | + |
|
78 | + $breadcrumbs = $this->generator->generate([ |
|
79 | + 'sample' => function($breadcrumbs) |
|
80 | + { |
|
81 | + $breadcrumbs->push('Home', '/', ['foo' => 'bar', 'title' => 'ignored']); |
|
82 | + }, |
|
83 | + ], 'sample', []); |
|
84 | + |
|
85 | + $this->assertCount(1, $breadcrumbs); |
|
86 | + $this->assertSame('Home', $breadcrumbs[0]->title); |
|
87 | + $this->assertSame('/', $breadcrumbs[0]->url); |
|
88 | + $this->assertSame('bar', $breadcrumbs[0]->foo); |
|
89 | + } |
|
90 | + |
|
91 | + public function testPushMultipleTimes() |
|
92 | + { |
|
93 | + $breadcrumbs = $this->generator->generate([ |
|
94 | + 'sample' => function($breadcrumbs) |
|
95 | + { |
|
96 | + $breadcrumbs->push('Level 1', '/1'); |
|
97 | + $breadcrumbs->push('Level 2', '/2'); |
|
98 | + $breadcrumbs->push('Level 3', '/3'); |
|
99 | + }, |
|
100 | + ], 'sample', []); |
|
101 | + |
|
102 | + $this->assertCount(3, $breadcrumbs); |
|
103 | + $this->assertSame('Level 1', $breadcrumbs[0]->title); |
|
104 | + $this->assertSame('Level 2', $breadcrumbs[1]->title); |
|
105 | + $this->assertSame('Level 3', $breadcrumbs[2]->title); |
|
106 | + $this->assertSame('/1', $breadcrumbs[0]->url); |
|
107 | + $this->assertSame('/2', $breadcrumbs[1]->url); |
|
108 | + $this->assertSame('/3', $breadcrumbs[2]->url); |
|
109 | + } |
|
110 | + |
|
111 | + // $breadcrumbs->parent($name) |
|
112 | + public function testParent_name() |
|
113 | + { |
|
114 | + $breadcrumbs = $this->generator->generate([ |
|
115 | + 'home' => function($breadcrumbs) |
|
116 | + { |
|
117 | + $breadcrumbs->push('Home', '/'); |
|
118 | + }, |
|
119 | + 'sample' => function($breadcrumbs) |
|
120 | + { |
|
121 | + $breadcrumbs->parent('home'); |
|
122 | + $breadcrumbs->push('Page', '/page'); |
|
123 | + }, |
|
124 | + ], 'sample', []); |
|
125 | + |
|
126 | + $this->assertCount(2, $breadcrumbs); |
|
127 | + $this->assertSame('Home', $breadcrumbs[0]->title); |
|
128 | + $this->assertSame('/', $breadcrumbs[0]->url); |
|
129 | + $this->assertSame('Page', $breadcrumbs[1]->title); |
|
130 | + $this->assertSame('/page', $breadcrumbs[1]->url); |
|
131 | + } |
|
132 | + |
|
133 | + // $breadcrumbs->parent($name, $param1, ...) |
|
134 | + public function testParent_name_params() |
|
135 | + { |
|
136 | + $breadcrumbs = $this->generator->generate([ |
|
137 | + 'parent' => function($breadcrumbs, $num, $text) |
|
138 | + { |
|
139 | + $this->assertSame(1, $num); |
|
140 | + $this->assertSame('blah', $text); |
|
141 | + }, |
|
142 | + 'sample' => function($breadcrumbs) |
|
143 | + { |
|
144 | + $breadcrumbs->parent('parent', 1, 'blah'); |
|
145 | + }, |
|
146 | + ], 'sample', []); |
|
147 | + } |
|
148 | + |
|
149 | + // $breadcrumbs->parentArray($name, $params) |
|
150 | + public function testParentArray_name_params() |
|
151 | + { |
|
152 | + $breadcrumbs = $this->generator->generate([ |
|
153 | + 'parent' => function($breadcrumbs, $num, $text) |
|
154 | + { |
|
155 | + $this->assertSame(1, $num); |
|
156 | + $this->assertSame('blah', $text); |
|
157 | + }, |
|
158 | + 'sample' => function($breadcrumbs) |
|
159 | + { |
|
160 | + $breadcrumbs->parentArray('parent', [1, 'blah']); |
|
161 | + }, |
|
162 | + ], 'sample', []); |
|
163 | + } |
|
164 | + |
|
165 | + // $breadcrumb->first |
|
166 | + // $breadcrumb->last |
|
167 | + public function testFirstLast() |
|
168 | + { |
|
169 | + $breadcrumbs = $this->generator->generate([ |
|
170 | + 'sample' => function($breadcrumbs) |
|
171 | + { |
|
172 | + $breadcrumbs->push('Level 1', '/1'); |
|
173 | + $breadcrumbs->push('Level 2', '/2'); |
|
174 | + $breadcrumbs->push('Level 3', '/3'); |
|
175 | + }, |
|
176 | + ], 'sample', []); |
|
177 | + |
|
178 | + $this->assertCount(3, $breadcrumbs); |
|
179 | + |
|
180 | + $this->assertTrue($breadcrumbs[0]->first, '$breadcrumbs[0]->first'); |
|
181 | + $this->assertFalse($breadcrumbs[1]->first, '$breadcrumbs[1]->first'); |
|
182 | + $this->assertFalse($breadcrumbs[2]->first, '$breadcrumbs[2]->first'); |
|
183 | + |
|
184 | + $this->assertFalse($breadcrumbs[0]->last, '$breadcrumbs[0]->last'); |
|
185 | + $this->assertFalse($breadcrumbs[1]->last, '$breadcrumbs[1]->last'); |
|
186 | + $this->assertTrue($breadcrumbs[2]->last, '$breadcrumbs[2]->last'); |
|
187 | + } |
|
188 | 188 | |
189 | 189 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | $this->generator->generate([ |
28 | 28 | 'sample' => function($breadcrumbs, $num, $text) |
29 | 29 | { |
30 | - $this->assertSame(1, $num); |
|
30 | + $this->assertSame(1, $num); |
|
31 | 31 | $this->assertSame('blah', $text); |
32 | 32 | }, |
33 | 33 | ], 'sample', [1, 'blah']); |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | }, |
45 | 45 | ], 'sample', []); |
46 | 46 | |
47 | - $this->assertCount(1, $breadcrumbs); |
|
47 | + $this->assertCount(1, $breadcrumbs); |
|
48 | 48 | $this->assertSame('Home', $breadcrumbs[0]->title); |
49 | 49 | $this->assertNull($breadcrumbs[0]->url); |
50 | 50 | } |
@@ -60,9 +60,9 @@ discard block |
||
60 | 60 | }, |
61 | 61 | ], 'sample', []); |
62 | 62 | |
63 | - $this->assertCount(1, $breadcrumbs); |
|
63 | + $this->assertCount(1, $breadcrumbs); |
|
64 | 64 | $this->assertSame('Home', $breadcrumbs[0]->title); |
65 | - $this->assertSame('/', $breadcrumbs[0]->url); |
|
65 | + $this->assertSame('/', $breadcrumbs[0]->url); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | // $breadcrumbs->push($title, $url, $data) |
@@ -82,10 +82,10 @@ discard block |
||
82 | 82 | }, |
83 | 83 | ], 'sample', []); |
84 | 84 | |
85 | - $this->assertCount(1, $breadcrumbs); |
|
85 | + $this->assertCount(1, $breadcrumbs); |
|
86 | 86 | $this->assertSame('Home', $breadcrumbs[0]->title); |
87 | - $this->assertSame('/', $breadcrumbs[0]->url); |
|
88 | - $this->assertSame('bar', $breadcrumbs[0]->foo); |
|
87 | + $this->assertSame('/', $breadcrumbs[0]->url); |
|
88 | + $this->assertSame('bar', $breadcrumbs[0]->foo); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | public function testPushMultipleTimes() |
@@ -99,13 +99,13 @@ discard block |
||
99 | 99 | }, |
100 | 100 | ], 'sample', []); |
101 | 101 | |
102 | - $this->assertCount(3, $breadcrumbs); |
|
102 | + $this->assertCount(3, $breadcrumbs); |
|
103 | 103 | $this->assertSame('Level 1', $breadcrumbs[0]->title); |
104 | 104 | $this->assertSame('Level 2', $breadcrumbs[1]->title); |
105 | 105 | $this->assertSame('Level 3', $breadcrumbs[2]->title); |
106 | - $this->assertSame('/1', $breadcrumbs[0]->url); |
|
107 | - $this->assertSame('/2', $breadcrumbs[1]->url); |
|
108 | - $this->assertSame('/3', $breadcrumbs[2]->url); |
|
106 | + $this->assertSame('/1', $breadcrumbs[0]->url); |
|
107 | + $this->assertSame('/2', $breadcrumbs[1]->url); |
|
108 | + $this->assertSame('/3', $breadcrumbs[2]->url); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | // $breadcrumbs->parent($name) |
@@ -123,10 +123,10 @@ discard block |
||
123 | 123 | }, |
124 | 124 | ], 'sample', []); |
125 | 125 | |
126 | - $this->assertCount(2, $breadcrumbs); |
|
127 | - $this->assertSame('Home', $breadcrumbs[0]->title); |
|
128 | - $this->assertSame('/', $breadcrumbs[0]->url); |
|
129 | - $this->assertSame('Page', $breadcrumbs[1]->title); |
|
126 | + $this->assertCount(2, $breadcrumbs); |
|
127 | + $this->assertSame('Home', $breadcrumbs[0]->title); |
|
128 | + $this->assertSame('/', $breadcrumbs[0]->url); |
|
129 | + $this->assertSame('Page', $breadcrumbs[1]->title); |
|
130 | 130 | $this->assertSame('/page', $breadcrumbs[1]->url); |
131 | 131 | } |
132 | 132 | |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | $breadcrumbs = $this->generator->generate([ |
137 | 137 | 'parent' => function($breadcrumbs, $num, $text) |
138 | 138 | { |
139 | - $this->assertSame(1, $num); |
|
139 | + $this->assertSame(1, $num); |
|
140 | 140 | $this->assertSame('blah', $text); |
141 | 141 | }, |
142 | 142 | 'sample' => function($breadcrumbs) |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | $breadcrumbs = $this->generator->generate([ |
153 | 153 | 'parent' => function($breadcrumbs, $num, $text) |
154 | 154 | { |
155 | - $this->assertSame(1, $num); |
|
155 | + $this->assertSame(1, $num); |
|
156 | 156 | $this->assertSame('blah', $text); |
157 | 157 | }, |
158 | 158 | 'sample' => function($breadcrumbs) |