Skip to content

Commit

Permalink
Unit test SV_WC_Plugin::logger method
Browse files Browse the repository at this point in the history
  • Loading branch information
nmolham-godaddy committed Aug 29, 2024
1 parent 55c5334 commit 5caffd5
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions tests/unit/PluginTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0\Tests\Unit;

use Mockery;
use ReflectionException;
use SkyVerge\WooCommerce\PluginFramework\v5_14_0\SV_WC_Plugin;
use SkyVerge\WooCommerce\PluginFramework\v5_14_0\Tests\TestCase;
use WP_Mock;

/**
* @covers \SkyVerge\WooCommerce\PluginFramework\v5_14_0\SV_WC_Plugin
*/
class PluginTest extends TestCase
{
/**
* @var Mockery\MockInterface&SV_WC_Plugin
*/
private $testObject;

public function setUp() : void
{
parent::setUp();

$this->testObject = Mockery::mock(SV_WC_Plugin::class)
->shouldAllowMockingProtectedMethods()
->makePartial();
}

/**
* @covers \SkyVerge\WooCommerce\PluginFramework\v5_14_0\SV_WC_Plugin::logger()
* @throws ReflectionException
*/
public function testCanGetLogger() : void
{
WP_Mock::userFunction('wc_get_logger')
->once()
->andReturn($logger = Mockery::mock('WC_Logger_Interface'));

$this->assertSame(
$logger,
$this->invokeInaccessibleMethod($this->testObject, 'logger')
);

$this->assertSame(
$logger,
$this->invokeInaccessibleMethod($this->testObject, 'logger')
);
}
}

0 comments on commit 5caffd5

Please sign in to comment.