guzzleFactory/tests/Apps/OxidLoggerTestTrait.php
2024-12-27 14:10:01 +01:00

109 Zeilen
2.5 KiB
PHP

<?php
/**
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* https://www.d3data.de
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
* @link https://www.oxidmodule.com
*/
namespace D3\GuzzleFactory\tests\Apps;
use D3\GuzzleFactory\GuzzleFactory;
use Monolog\Logger;
use ReflectionException;
use RuntimeException;
trait OxidLoggerTestTrait
{
/**
* @test
* @return void
* @throws ReflectionException
* @covers \D3\GuzzleFactory\GuzzleFactory::addOxidLogger
*/
public function testAddOxidLoggerWithoutOxid(): void
{
$sut = GuzzleFactory::create();
$this->expectException(RuntimeException::class);
$this->callMethod(
$sut,
'addOxidLogger',
);
}
/**
* @test
* @return void
* @throws ReflectionException
* @covers \D3\GuzzleFactory\GuzzleFactory::getOxidLogPath
*/
public function testGetOxidLogPathWithoutOxid(): void
{
$sut = GuzzleFactory::create();
$this->expectException(RuntimeException::class);
$this->assertSame(
'foo',
$this->callMethod(
$sut,
'getOxidLogPath',
['fixture.log']
)
);
}
/**
* @test
* @return void
* @throws ReflectionException
* @covers \D3\GuzzleFactory\GuzzleFactory::addOxidLogger
*/
public function testAddOxidLoggerInOxid(): void
{
require_once __DIR__.'/../Helpers/classAliases.php';
$sut = GuzzleFactory::create();
$this->callMethod(
$sut,
'addOxidLogger',
);
$loggers = $this->getValue($sut, 'loggers');
$this->assertArrayHasKey('oxid', $loggers);
$this->assertInstanceOf(Logger::class, $loggers['oxid']);
}
/**
* @test
* @return void
* @throws ReflectionException
* @covers \D3\GuzzleFactory\GuzzleFactory::getOxidLogPath
*/
public function testGetOxidLogPathInOxid(): void
{
require_once __DIR__.'/../Helpers/classAliases.php';
$sut = GuzzleFactory::create();
$this->assertStringEndsWith(
'tests/Helpers/log/fixture.log',
$this->callMethod(
$sut,
'getOxidLogPath',
['fixture.log']
)
);
}
}