lundi 26 septembre 2016

PHPUnit: My Package Class not found

I am working on a package for Laravel 5 and my PHPUnit Tests are failing with error

"Class VendorName\PackageName\MyPackage not found"

I still can't make out what is responsible for this error and would be glad if someone assists.

This is what my structure looks like:

src/
    ├─ MyPackage.php
test/
    ├─ MyPackageTest.php
composer.json
composer.lock

Composer.json

"psr-4": {
    "VendorName\\PackageName\\": "src/"
},
"autoload-dev": {
    "psr-4": {
        "VendorName\\PackageName\\Test\\": "tests/"
    }
},

This is (possibly) where my error is coming from:

MyPackageTest.php

namespace VendorName\PackageName\Test;

use PHPUnit\Framework\TestCase;
use VendorName\PackageName\MyPackage;

class InterswitchTest extends TestCase
{
    protected $app;

    public function setUp()
    {
        $this->app = new MyPackage();
    }
}

I have done the usual composer dump-autoload rituals to get this working as it should but all to no avail.

I also changed the composer.json file in the root of my Laravel project with the content above but I still could not get this to work.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire