Git Product home page Git Product logo

Comments (5)

ajthinking avatar ajthinking commented on June 6, 2024 1

Thank you @calvinchiulele , glad you like it 🎉
Thats a great idea. Do you mean like a pipe that creates files in Tests\Unit ? One for each controller? Can you supply an example of such a file?

from laravel-create.

ajthinking avatar ajthinking commented on June 6, 2024 1

Thanks @calvinchiulele for the file! Hope to find time to fix soon. I'll paste it here in case anyone want to have a look until then.

<?php

namespace App\Tests;

use App\___MODEL___;
use Tests\TestCase;
use Illuminate\{
    Foundation\Testing\WithFaker,
    Foundation\Testing\RefreshDatabase,
    Http\Response,
    Http\Request,
    Support\Str,
};

class ___MODEL___ControllerTest extends TestCase
{
    public function testStore()
    {
    	$data = factory(___MODEL___::class)
    	            ->make()
    	            ->first()
    	            ->toArray();

    	$response = $this->json(
    		Request::METHOD_POST, 
    		route(Str::plural(Str::lower(___MODEL___))),
    		$data
    	);

    	$response->assertStatus(Response::HTTP_CREATED)
    	                ->assertJson([]);
    }

    public function testShow()
    {
    	$response = $this->json(
    		Request::METHOD_GET, 
    		route(Str::plural(Str::lower(___MODEL___)), ['id' => 1]),
    	);

    	$response
    	    ->assertStatus(Response::HTTP_OK)
    	    ->assertJson(
    	       	[
    	       		'data' => [],
    	       		'links' => [],
    	       		'meta' => []
    	       	]
    	    );
    }

    public function testUpdate()
    {
    	$data = factory(___MODEL___::class)
    	            ->make()
    	            ->first()
    	            ->toArray();

    	$response = $this->json(
    		Request::METHOD_PATCH, 
    		route(Str::plural(Str::lower(___MODEL___)), ['id' => 1]),
    		$data
    	);

    	$response->assertStatus(Response::HTTP_OK)
    	                ->assertJson([]);
    }

    public function testDelete()
    {
    	$response = $this->json(
    		Request::METHOD_DELETE,
    		route(Str::plural(Str::lower(___MODEL___)), ['id' => 1]),
    	);

    	$response
    	    ->assertStatus(Response::HTTP_NO_CONTENT)
    	    ->assertJson([]);
    }
}

from laravel-create.

ajthinking avatar ajthinking commented on June 6, 2024 1

Thanks @calvinchiulele ! Queued for next version, closing for now.

from laravel-create.

calvinchiulele avatar calvinchiulele commented on June 6, 2024

Yes, is that what I mean. I'll supply an example yes.

from laravel-create.

ajthinking avatar ajthinking commented on June 6, 2024

Added to this Trello board

from laravel-create.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.