2FAuth/tests/Feature/Services/LogoServiceTest.php

59 lines
1.4 KiB
PHP
Raw Normal View History

2022-07-22 16:26:23 +02:00
<?php
namespace Tests\Feature\Services;
use App\Services\LogoService;
use Illuminate\Foundation\Testing\WithoutMiddleware;
2022-11-22 15:15:52 +01:00
use Mockery\MockInterface;
use Tests\TestCase;
2022-07-22 16:26:23 +02:00
/**
* @covers \App\Services\LogoService
*/
class LogoServiceTest extends TestCase
{
use WithoutMiddleware;
/**
* @test
*/
public function setUp() : void
{
parent::setUp();
}
/**
* @test
*/
public function test_getIcon_returns_iconFilename_when_logo_exists()
{
$logoServiceMock = $this->partialMock(LogoService::class, function (MockInterface $mock) {
$mock->shouldAllowMockingProtectedMethods();
$mock->shouldReceive('getLogo', 'copyToIcons')
->once()
->andReturn('service.svg', true);
});
$icon = $logoServiceMock->getIcon('service');
2022-11-22 15:15:52 +01:00
2022-07-22 16:26:23 +02:00
$this->assertNotNull($icon);
}
/**
* @test
*/
public function test_getIcon_returns_null_when_no_logo_exists()
{
$logoServiceMock = $this->partialMock(LogoService::class, function (MockInterface $mock) {
2022-07-30 11:25:45 +02:00
$mock->shouldAllowMockingProtectedMethods()
->shouldReceive('getLogo')
2022-07-22 16:26:23 +02:00
->once()
->andReturn(null);
});
$icon = $logoServiceMock->getIcon('no_logo_should_exists_with_this_name');
2022-11-22 15:15:52 +01:00
2022-07-22 16:26:23 +02:00
$this->assertEquals(null, $icon);
}
2022-11-22 15:15:52 +01:00
}