Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

byronsmith's avatar

PHPUnit baseUrl

Hi, Can anyone tell me what is the difference betweeen the PHPUnit $baseUrl and the Laravel config/app.url.

My PHPUnit tests seem to want to use the app.url rather than the baseUrl?

Cheers Byron

0 likes
5 replies
glenlockhart's avatar

I am totally bamboozed with this. Did you work out where the phpunit gets its baseUrl. I have set it in the testcase - but it seems to be ignored or cached or something.

thanks

byronsmith's avatar

Hi Glen,

I did, but I can't remember dude. What I can tell you is that I moved away from PHPUnit and onto Codeception. For me the integration was far easier and seems like a cleaner implementation.

Sorry I couldn't help you out further.

Cheers, Byron

autefrum's avatar

I think thomas.giordmaina menas to put it in your PHPUnit TestCase classes for example: in tests/Features/TrivialTest.php

<?php
namespace Tests\Feature;
use Tests\TestCase;
class TrivialTest extends TestCase
{
    public function setUp() {
        parent::setUp();
        config(['app.url' => 'http://127.0.0.1/dashboard']);

    }
    public function testTrivial1()
    {
        $uri = route('hi');
        $response = $this->get($uri);
        $response->assertStatus(200);
        $response->dump();
    }
}

Please or to participate in this conversation.