lundi 18 janvier 2016

undefined helper function in laravel phpunit testcase

I've a helper file helper.php where I keep some helper functions.

//helper.php
function isAuthLiked($authLikedPosts, $post)
{
    return !! Auth::check() && $authLikedPosts->contains('id', $post->id);
}

Now in my test case, I wrote:

    $this->assertTrue(isAuthLiked($authrenominations, $post[0]));

When I ran the test case, I get the error:

Fatal error: Call to undefined function isAuthLiked() in C:\wamp\www\Nom7\tests\integration\UserTest.php on line 304

I've added the helper file in the compose.json auto-load. But the problem persists.

"autoload": {
    "classmap": [
        "database",
        "app/Http/Controllers",
        "app/Models"
    ],
    "files":[
        "app/helper.php"
    ],
    "psr-4": {
        "App\\": "app/",
        "Acme\\": "app/Acme/"
    }
},
"autoload-dev": {
    "classmap": [
        "tests/TestCase.php"
    ],
    "files":[
        "app/helper.php"
    ]
},



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire