• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

How to test laravel controller method?

phplaraveltestingdesign-patterns


PHP Snippet 1:

$language = Language::create($request->only(['name', 'code', 'flag']));

PHP Snippet 2:

$response = $this->postJson('/language', ['name' => 'Swedish', 'code' => 'swe', 'flag => 'SE']);
 
$response
    ->assertStatus(200)
    ->assertJson([
        'success' => 'Language has been created successfully',
    ])
    ->assertJsonPath('data.name', 'Swedish')
    ->assertJsonPath('data.code', 'swe')
    ->assertJsonPath('data.flag', 'SE');

Related Snippets

printing all running session variable in laravel 5.1

Form repeater send wrong data with last element in Laravel

Prestashop cUrl Login

Move a child array to parent array and change parent/child name

VB.NET WebRequest with PHP POST

PHP: set a (deep) array key from an array [closed]

Filter array by skipping every nth element from the end

Inserting data into SQL Server Db An Invalid direction was specified

Facebook API, get page post link (PHP)

Call to undefined function openssl_decrypt

insert multiple rows in a saveall in cakephp

Laravel Blade checkbox not checked

How to Mock the Request Class in Laravel?

How to use $this->session->set_userdata in codeigniter

SQLSTATE[HY000]: General error: 1 table posts has no column named *

About Contact Privacy policy Terms and conditions