Passed
Push — 2023.10 ( f93328...d57fc8 )
by Aimeos
08:01 queued 02:01
created

StandardTest::testResolve()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 6
rs 10
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2021-2023
6
 */
7
8
9
namespace Aimeos\Controller\Frontend\Cms;
10
11
12
class StandardTest extends \PHPUnit\Framework\TestCase
13
{
14
	private $object;
15
	private $context;
16
17
18
	protected function setUp() : void
19
	{
20
		$this->context = \TestHelper::context();
21
		$this->context->locale()->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\Order\Manag...rvice\Transaction\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\Order\Manager\Service\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\Common\Manager\Property\Iface or Aimeos\MShop\Customer\Manager\Property\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\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\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\Order\Manager\Address\Iface or Aimeos\MShop\Product\Manager\Lists\Iface or Aimeos\MShop\Order\Manager\Product\Attribute\Iface or Aimeos\MShop\Order\Manager\Iface or Aimeos\MShop\Media\Manager\Iface or Aimeos\MShop\Rule\Manager\Type\Iface or Aimeos\MShop\Order\Manager\Coupon\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\Service\Attribute\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\Rule\Manager\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\Basket\Iface or Aimeos\MShop\Order\Manager\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 testResolve()
82
	{
83
		$item = $this->object->resolve( '/contact' );
84
85
		$this->assertInstanceOf( \Aimeos\MShop\Cms\Item\Iface::class, $item );
86
		$this->assertEquals( 'Contact', $item->getLabel() );
87
	}
88
89
90
	public function testSearch()
91
	{
92
		$total = 0;
93
		$items = $this->object->uses( ['text'] )->compare( '=~', 'cms.url', '/con' )
94
			->sort( 'cms.url' )->search( $total );
95
96
		$this->assertEquals( 1, count( $items ) );
97
		$this->assertEquals( 1, $total );
98
		$this->assertEquals( 3, count( $items->first()->getRefItems( 'text' ) ) );
99
	}
100
101
102
	public function testSlice()
103
	{
104
		$this->assertEquals( 1, count( $this->object->slice( 0, 1 )->search() ) );
105
	}
106
107
108
	public function testSort()
109
	{
110
		$this->assertGreaterThanOrEqual( 1, count( $this->object->sort()->search() ) );
111
	}
112
113
114
	public function testSortGeneric()
115
	{
116
		$this->assertGreaterThanOrEqual( 1, count( $this->object->sort( 'cms.label' )->search() ) );
117
	}
118
119
120
	public function testSortMultiple()
121
	{
122
		$this->assertGreaterThanOrEqual( 1, count( $this->object->sort( 'cms.label,-cms.id' )->search() ) );
123
	}
124
125
126
	public function testUses()
127
	{
128
		$this->assertSame( $this->object, $this->object->uses( ['text'] ) );
129
	}
130
}
131