JQAdmTest::testCreateClientName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2015-2025
6
 */
7
8
9
namespace Aimeos\Admin;
10
11
12
class JQAdmTest extends \PHPUnit\Framework\TestCase
13
{
14
	private $aimeos;
15
	private $context;
16
17
18
	protected function setUp() : void
19
	{
20
		$this->aimeos = \TestHelper::getAimeos();
21
		$this->context = \TestHelper::context();
22
		$this->context->setView( \TestHelper::view() );
23
	}
24
25
26
	public function testCreateClient()
27
	{
28
		$this->context->config()->set( 'admin/jqadm/resources', ['product'] );
29
		$client = \Aimeos\Admin\JQAdm::create( $this->context, $this->aimeos, 'product' );
30
		$this->assertInstanceOf( '\\Aimeos\\Admin\\JQAdm\\Iface', $client );
31
	}
32
33
34
	public function testCreateClientName()
35
	{
36
		$this->context->config()->set( 'admin/jqadm/resources', ['product'] );
37
		$client = \Aimeos\Admin\JQAdm::create( $this->context, $this->aimeos, 'product', 'Standard' );
38
		$this->assertInstanceOf( '\\Aimeos\\Admin\\JQAdm\\Iface', $client );
39
	}
40
41
42
	public function testCreateSubClient()
43
	{
44
		$this->context->config()->set( 'admin/jqadm/resources', ['type'] );
45
		$client = \Aimeos\Admin\JQAdm::create( $this->context, $this->aimeos, 'type' );
46
		$this->assertInstanceOf( '\\Aimeos\\Admin\\JQAdm\\Iface', $client );
47
	}
48
49
50
	public function testCreateClientNameEmpty()
51
	{
52
		$this->expectException( '\\Aimeos\\Admin\\JQAdm\\Exception' );
53
		\Aimeos\Admin\JQAdm::create( $this->context, $this->aimeos, '' );
54
	}
55
56
57
	public function testCreateClientNameInvalid()
58
	{
59
		$this->expectException( \LogicException::class );
60
		\Aimeos\Admin\JQAdm::create( $this->context, $this->aimeos, '%^unknown' );
61
	}
62
63
64
	public function testCreateClientNameNotFound()
65
	{
66
		$this->expectException( \LogicException::class );
67
		\Aimeos\Admin\JQAdm::create( $this->context, $this->aimeos, 'unknown' );
68
	}
69
70
}
71