dbudwin/RoboHome-Web

View on GitHub
tests/Unit/Controller/Common/DevicesControllerTestCase.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace Tests\Unit\Controller\Common;

use App\Http\MQTT\MessagePublisher;
use Mockery;

class DevicesControllerTestCase extends ControllerTestCase
{
    protected function mockMessagePublisher(int $timesPublishIsCalled, bool $messagePublishedSuccessfully = true): void
    {
        $mockMessagePublisher = Mockery::mock(MessagePublisher::class);
        $mockMessagePublisher
            ->shouldReceive('publish')
            ->withAnyArgs()
            ->times($timesPublishIsCalled)
            ->andReturn($messagePublishedSuccessfully);

        $this->app->instance(MessagePublisher::class, $mockMessagePublisher);
    }
}