App\Http\Controllers\AuthorsController::update PHP Method

update() public method

public update ( AuthorRequest $request, App\Author $author )
$request App\Http\Requests\AuthorRequest
$author App\Author
    public function update(AuthorRequest $request, Author $author)
    {
        $author->update($request->all());
        session()->flash('flash_message', 'Author was updated with success');
        if (Request::wantsJson()) {
            return $author;
        }
        return redirect('authors');
    }

Usage Example

 public function testUpdate_ok()
 {
     $ar = \Mockery::mock(AR::class)->makePartial();
     $av = \Mockery::mock(AV::class)->makePartial();
     $ac = new AC($ar, $av);
     $req = new Request();
     $ar->shouldReceive('update')->andReturn(150);
     $av->shouldReceive('update');
     $r = $ac->update($req, 149);
     $this->assertInstanceOf(JsonResponse::class, $r);
     $this->assertSame(200, $r->getStatusCode());
     $this->assertSame(150, $r->getData());
 }