![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-new-relic-reporting/Test/Unit/Model/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ declare(strict_types=1); namespace Magento\NewRelicReporting\Test\Unit\Model; use Magento\NewRelicReporting\Model\Config; use Magento\NewRelicReporting\Model\Cron; use Magento\NewRelicReporting\Model\Cron\ReportCounts; use Magento\NewRelicReporting\Model\Cron\ReportModulesInfo; use Magento\NewRelicReporting\Model\Cron\ReportNewRelicCron; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; class CronTest extends TestCase { /** * @var Cron */ protected $model; /** * @var Config|MockObject */ protected $configMock; /** * @var ReportModulesInfo|MockObject */ protected $reportModulesInfoMock; /** * @var ReportCounts|MockObject */ protected $reportCountsMock; /** * @var ReportNewRelicCron|MockObject */ protected $reportNewRelicCronMock; protected function setUp(): void { $this->configMock = $this->getMockBuilder(Config::class) ->setMethods(['isCronEnabled']) ->disableOriginalConstructor() ->getMock(); $this->reportModulesInfoMock = $this->getMockBuilder( ReportModulesInfo::class )->disableOriginalConstructor() ->getMock(); $this->reportCountsMock = $this->getMockBuilder(ReportCounts::class) ->disableOriginalConstructor() ->getMock(); $this->reportNewRelicCronMock = $this->getMockBuilder( ReportNewRelicCron::class )->disableOriginalConstructor() ->getMock(); $this->model = new Cron( $this->configMock, $this->reportModulesInfoMock, $this->reportCountsMock, $this->reportNewRelicCronMock ); } /** * Test case when cron is disabled in config */ public function testRunCronCronDisabledFromConfig() { $this->configMock->expects($this->once()) ->method('isCronEnabled') ->willReturn(false); $this->assertSame( $this->model, $this->model->runCron() ); } /** * Test case when cron is enabled in config */ public function testRunCronCronEnabledFromConfig() { $this->configMock->expects($this->once()) ->method('isCronEnabled') ->willReturn(true); $this->reportModulesInfoMock->expects($this->once()) ->method('report') ->willReturnSelf(); $this->reportCountsMock->expects($this->once()) ->method('report') ->willReturnSelf(); $this->reportNewRelicCronMock->expects($this->once()) ->method('report') ->willReturnSelf(); $this->assertSame( $this->model, $this->model->runCron() ); } }