This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$view = $response->viewData('products') // was passed to view in controller | |
$this->assertEquals($product->name, $view->first()->name); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function update(Product $product, UpdateProductRequest $request) | |
{ | |
$product->update($request->all()); | |
return redirect()->route('products.index'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@forelse ($users as $user) | |
{{ $user->name }} | |
@empty | |
No users | |
@endforelse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function getPriceEurAttribute() { | |
return $this->price*0.8; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$product = Product:create([ | |
'name' => 'Product 1', | |
'price' => 99.99 | |
]); | |
// in your test | |
$response->assertSee($product->name); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Controller | |
public function store(Request $request) | |
{ | |
Product::create($request->all()); | |
return redirect()->route('home'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$subject = new UserUpdateRequest(); | |
// will call the file App\Http\Requests\UserUpdateRequest; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
assertActionUsesFormRequest( | |
UsersController::class, // Controller | |
'update', // Method | |
UserUpdateRequest::class); // Form Request | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function testSpying() | |
{ | |
$spy = Mockery::spy(); | |
$this->assertNull($spy->quix()); | |
// assert behavior | |
$spy->shouldHaveReceived('quix')->once(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected function setUp(): void | |
{ | |
parent::setUp(); | |
$this->subject = new UserUpdateRequest(); | |
} |