Passed
Push — main ( f9f23c...f7616c )
by Aimeos
05:03
created

StandardTest   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 108
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 33
c 1
b 0
f 0
dl 0
loc 108
rs 10
wmc 14

14 Methods

Rating   Name   Duplication   Size   Complexity  
A testSlice() 0 3 1
A testSortMultiple() 0 3 1
A testSearch() 0 9 1
A testCompare() 0 3 1
A testSort() 0 3 1
A testFunction() 0 4 1
A testHas() 0 6 1
A testUses() 0 3 1
A testGet() 0 7 1
A testFind() 0 6 1
A testParse() 0 4 1
A setUp() 0 6 1
A testSortGeneric() 0 3 1
A tearDown() 0 3 1
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2021
6
 */
7
8
9
namespace Aimeos\Controller\Frontend\Cms;
10
11
12
class StandardTest extends \PHPUnit\Framework\TestCase
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
{
14
	private $object;
15
	private $context;
16
17
18
	protected function setUp() : void
19
	{
20
		$this->context = \TestHelperFrontend::getContext();
21
		$this->context->getLocale()->setLanguageId( 'en' );
22
23
		$this->object = new \Aimeos\Controller\Frontend\Cms\Standard( $this->context );
24
	}
25
26
27
	protected function tearDown() : void
28
	{
29
		unset( $this->object, $this->context );
30
	}
31
32
33
	public function testCompare()
34
	{
35
		$this->assertEquals( 1, count( $this->object->compare( '=~', 'cms.label', 'Con' )->search() ) );
36
	}
37
38
39
	public function testFind()
40
	{
41
		$item = $this->object->uses( ['text'] )->find( '/contact' );
42
43
		$this->assertInstanceOf( \Aimeos\MShop\Cms\Item\Iface::class, $item );
44
		$this->assertEquals( 3, count( $item->getRefItems( 'text' ) ) );
45
	}
46
47
48
	public function testFunction()
49
	{
50
		$str = $this->object->function( 'cms:has', ['domain', 'type', 'refid'] );
51
		$this->assertEquals( 'cms:has("domain","type","refid")', $str );
52
	}
53
54
55
	public function testGet()
56
	{
57
		$item = \Aimeos\MShop::create( $this->context, 'cms' )->find( '/contact' );
0 ignored issues
show
Bug introduced by
The method find() does not exist on Aimeos\MShop\Common\Manager\Iface. It seems like you code against a sub-type of said class. However, the method does not exist in Aimeos\MShop\Common\Manager\Decorator\Iface or Aimeos\MShop\Service\Manager\Lists\Type\Iface or Aimeos\MShop\Price\Manager\Iface or Aimeos\MShop\Attribute\Manager\Type\Iface or Aimeos\MShop\Review\Manager\Iface or Aimeos\MShop\Price\Manager\Lists\Type\Iface or Aimeos\MShop\Media\Manager\Type\Iface or Aimeos\MShop\Order\Manager\Base\Coupon\Iface or Aimeos\MShop\Common\Manager\Property\Iface or Aimeos\MShop\Customer\Manager\Property\Iface or Aimeos\MShop\Order\Manager\Base\Service\Iface or Aimeos\MShop\Order\Manager\Base\Iface or Aimeos\MShop\Price\Manager\Lists\Iface or Aimeos\MShop\Cms\Manager\Lists\Type\Iface or Aimeos\MShop\Supplier\Manager\Lists\Type\Iface or Aimeos\MShop\Order\Manag...Service\Attribute\Iface or Aimeos\MShop\Service\Manager\Lists\Iface or Aimeos\MShop\Tag\Manager\Type\Iface or Aimeos\MShop\Text\Manager\Lists\Iface or Aimeos\MShop\Price\Manager\Type\Iface or Aimeos\MShop\Locale\Manager\Currency\Iface or Aimeos\MShop\Order\Manag...Product\Attribute\Iface or Aimeos\MShop\Media\Manager\Lists\Type\Iface or Aimeos\MShop\Catalog\Manager\Lists\Iface or Aimeos\MShop\Tag\Manager\Iface or Aimeos\MShop\Coupon\Manager\Iface or Aimeos\MShop\Common\Manager\Lists\Iface or Aimeos\MShop\Service\Manager\Type\Iface or Aimeos\MShop\Product\Manager\Lists\Iface or Aimeos\MShop\Order\Manager\Iface or Aimeos\MShop\Media\Manager\Iface or Aimeos\MShop\Customer\Manager\Lists\Type\Iface or Aimeos\MShop\Attribute\Manager\Lists\Iface or Aimeos\MShop\Media\Manager\Lists\Iface or Aimeos\MShop\Plugin\Manager\Iface or Aimeos\MShop\Order\Manager\Base\Address\Iface or Aimeos\MShop\Product\Manager\Type\Iface or Aimeos\MShop\Supplier\Manager\Lists\Iface or Aimeos\MShop\Text\Manager\Iface or Aimeos\MAdmin\Job\Manager\Iface or Aimeos\MShop\Product\Manager\Lists\Type\Iface or Aimeos\MShop\Text\Manager\Lists\Type\Iface or Aimeos\MShop\Text\Manager\Type\Iface or Aimeos\MShop\Order\Manager\Status\Iface or Aimeos\MShop\Common\Manager\Address\Iface or Aimeos\MShop\Plugin\Manager\Type\Iface or Aimeos\MShop\Stock\Manager\Iface or Aimeos\MShop\Attribute\Manager\Property\Iface or Aimeos\MShop\Subscription\Manager\Iface or Aimeos\MShop\Product\Manager\Property\Iface or Aimeos\MShop\Locale\Manager\Language\Iface or Aimeos\MShop\Media\Manager\Property\Iface or Aimeos\MShop\Attribute\Manager\Lists\Type\Iface or Aimeos\MAdmin\Log\Manager\Iface or Aimeos\MShop\Cms\Manager\Lists\Iface or Aimeos\MShop\Locale\Manager\Iface or Aimeos\MAdmin\Cache\Manager\Iface or Aimeos\MShop\Order\Manager\Base\Product\Iface or Aimeos\MShop\Price\Manager\Property\Iface or Aimeos\MShop\Customer\Manager\Lists\Iface or Aimeos\MShop\Catalog\Manager\Lists\Type\Iface or Aimeos\MShop\Supplier\Manager\Address\Iface or Aimeos\MShop\Customer\Manager\Address\Iface. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

57
		$item = \Aimeos\MShop::create( $this->context, 'cms' )->/** @scrutinizer ignore-call */ find( '/contact' );
Loading history...
58
		$item = $this->object->uses( ['text'] )->get( $item->getId() );
59
60
		$this->assertInstanceOf( \Aimeos\MShop\Cms\Item\Iface::class, $item );
61
		$this->assertEquals( 3, count( $item->getRefItems( 'text' ) ) );
62
	}
63
64
65
	public function testHas()
66
	{
67
		$manager = \Aimeos\MShop::create( $this->context, 'text' );
68
		$textId = $manager->search( $manager->filter()->add( ['text.domain' => 'cms'] ) )->firstKey();
69
70
		$this->assertEquals( 1, count( $this->object->has( 'text', 'default', $textId )->search() ) );
71
	}
72
73
74
	public function testParse()
75
	{
76
		$cond = ['&&' => [['==' => ['cms.status' => 1]], ['=~' => ['cms.label' => 'Con']]]];
77
		$this->assertEquals( 1, count( $this->object->parse( $cond )->search() ) );
78
	}
79
80
81
	public function testSearch()
82
	{
83
		$total = 0;
84
		$items = $this->object->uses( ['text'] )->compare( '=~', 'cms.url', '/con' )
85
			->sort( 'cms.url' )->search( $total );
86
87
		$this->assertEquals( 1, count( $items ) );
88
		$this->assertEquals( 1, $total );
89
		$this->assertEquals( 3, count( $items->first()->getRefItems( 'text' ) ) );
90
	}
91
92
93
	public function testSlice()
94
	{
95
		$this->assertEquals( 1, count( $this->object->slice( 0, 1 )->search() ) );
96
	}
97
98
99
	public function testSort()
100
	{
101
		$this->assertGreaterThanOrEqual( 1, count( $this->object->sort()->search() ) );
102
	}
103
104
105
	public function testSortGeneric()
106
	{
107
		$this->assertGreaterThanOrEqual( 1, count( $this->object->sort( 'cms.label' )->search() ) );
108
	}
109
110
111
	public function testSortMultiple()
112
	{
113
		$this->assertGreaterThanOrEqual( 1, count( $this->object->sort( 'cms.label,-cms.id' )->search() ) );
114
	}
115
116
117
	public function testUses()
118
	{
119
		$this->assertSame( $this->object, $this->object->uses( ['text'] ) );
120
	}
121
}
122