How to write unit test for controller in laravel?

I am new to laravel and want to unit test my controller in laravel 5.6 Here is my controller. class NewOrdersController extends Controller { protected $newOrders; public function __construct(NewOrderRepositoryInterface $newOrders) { $this->newOrders = $newOrders; } public function orderList(){ $orders = $this->newOrders->getNewOrders(); if(count($orders) == 0){ return 0; } else{ return 1; } } } My test…

How to use pluck to get specific data from other table in Laravel?

From SalesController, I want to get specific name from table Item and passed to HTML. My controller looks like public function index() { $items=Item::orderBy(‘name’,’ASC’)->get()->pluck(‘name’,’id’); $sales=Sale::all(); return view(‘Sale.index’)->with(‘sales’,$sales,’items’,$items); } My HTML is <thead> <tr> <th>No</th> <th>Name</th> <th>Quantity</th> <th>Total Price</th> <th>Detail</th> </tr> </thead> <tbody> @foreach($sales as $sale) <tr> <td></td> <td></td> <td></td> <td>RM </td> <td></td> </tr> @endforeach </tbody>…