specialtactics / laravel-api-boilerplate

Laravel API Boilerplate | Quickly build quality API products!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] Testing cannot read route URI by name

vafrcor opened this issue · comments

Version Information
PHP Version: 7.2.1
Package Version (l5-api): v1.2.1

Describe the bug

  • File tests/Api/UserControllerTest
  • Case: Unable to read route uri by named-route
  • sample code:
<?php

namespace Tests\Api;

use Tests\ApiTestCase;

class UserTest extends ApiTestCase
{
    public function doGetAll()
    {
        // $jsonResponse = $this->actingAsAdmin()->json('GET', '/api/users');
        $jsonResponse = $this->actingAsAdmin()->json('GET', route('api.users.index', [], false));
        
        // Check status and structure
        $jsonResponse
            ->assertStatus(200);
    }

}

To Reproduce
Steps to reproduce the behavior:

  1. Go to project path
  2. Run phpunit
  3. See error

Expected behavior
Named route URI can be read on phpunit testing mode.

Additional context
Add any other context about the problem here.

commented

Hi

The problem is actually with the dingo/api package, not this package.

However since you made this ticket that problem has also been resolved (I'm pretty sure), so just update your packages.

In any case, if you still face difficulties with this, please report to dingo/api github.