Skip to content

feat(discovery): discover autoload-dev namespaces#1438

Closed
Treggats wants to merge 1 commit intotempestphp:mainfrom
Treggats:feature/combine-composer-namespaces
Closed

feat(discovery): discover autoload-dev namespaces#1438
Treggats wants to merge 1 commit intotempestphp:mainfrom
Treggats:feature/combine-composer-namespaces

Conversation

@Treggats
Copy link
Contributor

Working on some tests and wanted to use a different database than default. Which is SQLite.
I tried adding the database config under the tests directory, only it was never discovered.

After digging it turned out that only the namespaces from autoload.psr-4 where loaded and not autoload-dev.psr-4

This PR updates processing the namespaces from the composer.json file and adds autoload-dev.psr-4 to it.

@innocenzi innocenzi changed the title feat(composer): discover both autoload & autoload-dev namespaces feat(discovery): discover autoload-dev namespaces Jul 28, 2025
@brendt
Copy link
Member

brendt commented Jul 29, 2025

Sorry for not getting back on you via Discord. We used to discover dev locations, but that ended up causing a lot of issues. Instead, you should manually add your testing discovery locations during test setup. Here's what that looks like:

    protected function setUp(): void
    {
        $this->discoveryLocations = [
            new DiscoveryLocation('Tests\\Tempest\\Integration\\Console\\Fixtures', __DIR__ . '/Console/Fixtures'),
            new DiscoveryLocation('Tests\\Tempest\\Fixtures', __DIR__ . '/../Fixtures'),
        ];

        parent::setUp();

This assumes you extend \Tempest\Framework\Testing\IntegrationTest

@brendt brendt closed this Jul 29, 2025
@Treggats
Copy link
Contributor Author

@brendt Actually I'm glad, as I've also was seeing weird issues on the tests in this repository but nog my application.

Is this test setUp() documented? As I've been searching for something like this. But couldn't find anything

@Treggats Treggats deleted the feature/combine-composer-namespaces branch July 29, 2025 07:27
@brendt
Copy link
Member

brendt commented Jul 30, 2025

It's not documented no, we should add it here: https://tempestphp.com/docs/essentials/testing

I made an issue for it: #1443 I'll pick this up somewhere later, or you can look at it if you want to

@Treggats
Copy link
Contributor Author

It's not documented no, we should add it here: https://tempestphp.com/docs/essentials/testing

I made an issue for it: #1443 I'll pick this up somewhere later, or you can look at it if you want to

I'll have a look :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants