|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2017-2025 |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
|
|
9
|
|
|
namespace Aimeos\Controller\Frontend\Basket\Decorator; |
|
10
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
class CategoryTest 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
|
|
|
$object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
22
|
|
|
$this->object = new \Aimeos\Controller\Frontend\Basket\Decorator\Category( $object, $this->context ); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
|
|
26
|
|
|
protected function tearDown() : void |
|
27
|
|
|
{ |
|
28
|
|
|
$this->object->clear(); |
|
29
|
|
|
$this->context->session()->set( 'aimeos', [] ); |
|
30
|
|
|
|
|
31
|
|
|
unset( $this->object ); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
|
|
35
|
|
|
public function testAddProductWithCategory() |
|
36
|
|
|
{ |
|
37
|
|
|
$manager = \Aimeos\MShop::create( $this->context, 'product' ); |
|
38
|
|
|
$item = $manager->find( 'CNE', ['price', 'catalog'] ); |
|
39
|
|
|
|
|
40
|
|
|
$this->assertSame( $this->object, $this->object->addProduct( $item ) ); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
|
|
44
|
|
|
public function testAddProductSelection() |
|
45
|
|
|
{ |
|
46
|
|
|
$manager = \Aimeos\MShop::create( $this->context, 'product' ); |
|
47
|
|
|
$item = $manager->find( 'U:TESTSUB05', ['price'] ); |
|
48
|
|
|
|
|
49
|
|
|
$this->assertSame( $this->object, $this->object->addProduct( $item, 2, [], [], [], 'default' ) ); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
|
|
53
|
|
|
public function testAddProductNoCategory() |
|
54
|
|
|
{ |
|
55
|
|
|
$manager = \Aimeos\MShop::create( $this->context, 'product' ); |
|
56
|
|
|
$item = $manager->find( 'U:MD' ); |
|
57
|
|
|
|
|
58
|
|
|
$this->expectException( \Aimeos\Controller\Frontend\Basket\Exception::class ); |
|
59
|
|
|
$this->object->addProduct( $item ); |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|