Skip to content

Instantly share code, notes, and snippets.

@ederrafo
Last active April 28, 2023 00:31
Show Gist options
  • Save ederrafo/e0c449127587dc010545d42a0cf4e2f2 to your computer and use it in GitHub Desktop.
Save ederrafo/e0c449127587dc010545d42a0cf4e2f2 to your computer and use it in GitHub Desktop.
phpunit test

ExampleTest basic

<?php

namespace Tests\Feature;

use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;

class ExampleTest extends TestCase
{
    /**
     * A basic test example.
     *
     * @return void
     */
    public function testBasicTest()
    {
        $this->assertTrue(true);
    }
}

sample 1

/**
     * A basic test example.
     *
     * @return void
     */
    public function test_searchByParameters()
    {   
        $this->markTestSkipped( 'PHPUnit will skip this test method' );
        $parameters = [
            'not_accounts_id'   => true,
            'user_id'           => 9,
            'business_unit_id'  => 1,
            'type_id'           => 1,
            'like'              => 'viajes',
            
        ];

        $response = $this->post(route('accounts.search_by_parameters'), $parameters)
                    ->assertStatus(200);
        //echo __FILE__." on line ".__LINE__,": "; print_r($response); echo "\n";
        
        //echo "<pre>",__FILE__." on line ".__LINE__,": "; exit(); echo "</pre>";
        //$this->assertTrue(true);
    }

Sample 2

 /**
     * A basic test example.
     *
     * @return void
     */
    public function test_getByParameters()
    {
        $this->markTestSkipped();
        $response = $this->get('/api/user/getByParameters?id=1');
        $response->assertStatus(200);
    }


    public function test_putUser()
    {   
        $this->markTestSkipped();
        $id   = 127;
        $data = [
            'name'  => 'prueba',
            'email' => 'j.veli@costamar.com',
            'code'  => 'NONE'
        ];

        $this->put(route('users.update', $id), $data)
                    ->assertStatus(200)
                    //->assertJson($data)
                    ;
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment