Support the ongoing development of Laravel.io →
Laravel Testing
Last updated 2 years ago.
0

Hi. This worked for me:


namespace Modules\Administration\Tests\Entities\ArrayRepository;

use Tests\TestCase;
use Illuminate\Container\Container;


class UserEntityTest extends TestCase
{
    public function setUp()
    {
        parent::setUp();
        $app = Container::getInstance();
        $this->app->bind('Modules\Administration\Entities\User',
            'Modules\Administration\Repositories\ArrayRepository\User');
    }

    public function test_create_User_Entity()
    {
        /**
         * Thing to do in order to resolve this Entity from Array Repository
         *
         * 1. Make an interface Modules\Administration\Entities\User
         * 2. Make an implementation Modules\Administration\Repositories\ArrayRepository\User
         * 3. Bind the implementation to the interface
         */
        $user = resolve('Modules\Administration\Entities\User');
        $this->assertNotNull($user, 'Can not create Administration\Entities\User');
    }
}

Good luck!

0

Sign in to participate in this thread!

Eventy

Your banner here too?

shinijaQB shinijaqb Joined 1 Oct 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.