Passed
Push — master ( 00b32c...f72d01 )
by Aimeos
04:46
created

BaseTest::testCheckConfigBE()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @license LGPLv3, https://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2015-2021
6
 */
7
8
9
namespace Aimeos\MShop\Service\Provider\Payment;
10
11
12
class BaseTest extends \PHPUnit\Framework\TestCase
13
{
14
	private $object;
15
	private $context;
16
17
18
	protected function setUp() : void
19
	{
20
		$this->context = \TestHelperMShop::getContext();
21
22
		$servManager = \Aimeos\MShop\Service\Manager\Factory::create( $this->context );
23
		$search = $servManager->filter();
24
		$search->setConditions( $search->compare( '==', 'service.provider', 'Standard' ) );
25
		$result = $servManager->search( $search, array( 'price' ) )->toArray();
26
27
		if( ( $item = reset( $result ) ) === false ) {
28
			throw new \RuntimeException( 'No order base item found' );
29
		}
30
31
		$this->object = new TestBase( $this->context, $item );
32
	}
33
34
35
	protected function tearDown() : void
36
	{
37
		unset( $this->object );
38
	}
39
40
41
	public function testCheckConfigBE()
42
	{
43
		$result = $this->object->checkConfigBE( array( 'payment.url-success' => true ) );
44
45
		$this->assertEquals( 0, count( $result ) );
46
	}
47
48
49
	public function testGetConfigBE()
50
	{
51
		$result = $this->object->getConfigBE();
52
53
		$this->assertEquals( 0, count( $result ) );
54
		$this->assertIsArray( $result );
55
	}
56
57
58
	public function testCancel()
59
	{
60
		$item = \Aimeos\MShop\Order\Manager\Factory::create( $this->context )->create();
61
62
		$this->expectException( \Aimeos\MShop\Service\Exception::class );
63
		$this->object->cancel( $item );
64
	}
65
66
67
	public function testCapture()
68
	{
69
		$item = \Aimeos\MShop\Order\Manager\Factory::create( $this->context )->create();
70
71
		$this->expectException( \Aimeos\MShop\Service\Exception::class );
72
		$this->object->capture( $item );
73
	}
74
75
	public function testProcess()
76
	{
77
		$item = \Aimeos\MShop\Order\Manager\Factory::create( $this->context )->create();
78
		$this->object->injectGlobalConfigBE( ['payment.url-success' => 'url'] );
79
80
		$result = $this->object->process( $item, [] );
81
		$this->assertInstanceOf( \Aimeos\MShop\Common\Helper\Form\Iface::class, $result );
82
	}
83
84
85
	public function testRefund()
86
	{
87
		$item = \Aimeos\MShop\Order\Manager\Factory::create( $this->context )->create();
88
89
		$this->expectException( \Aimeos\MShop\Service\Exception::class );
90
		$this->object->refund( $item );
91
	}
92
93
94
	public function testRepay()
95
	{
96
		$item = \Aimeos\MShop\Order\Manager\Factory::create( $this->context )->create();
97
98
		$this->expectException( \Aimeos\MShop\Service\Exception::class );
99
		$this->object->repay( $item );
100
	}
101
102
103
	public function testSetConfigFE()
104
	{
105
		$item = \Aimeos\MShop\Order\Manager\Factory::create( $this->context )
106
			->getSubManager( 'base' )->getSubManager( 'service' )->create();
107
108
		$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Service\Iface::class, $this->object->setConfigFE( $item, [] ) );
109
	}
110
111
112
	public function testTransfer()
113
	{
114
		$item = \Aimeos\MShop\Order\Manager\Factory::create( $this->context )->create();
115
116
		$this->expectException( \Aimeos\MShop\Service\Exception::class );
117
		$this->object->transfer( $item );
118
	}
119
}
120
121
122
class TestBase
123
	extends \Aimeos\MShop\Service\Provider\Payment\Base
124
	implements \Aimeos\MShop\Service\Provider\Payment\Iface
125
{
126
127
}
128