This repository has been archived by the owner on Oct 17, 2022. It is now read-only.
forked from aimeos/aimeos-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DefaultTest.php
92 lines (72 loc) · 2.73 KB
/
DefaultTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
/**
* @copyright Copyright (c) Metaways Infosystems GmbH, 2011
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
*/
class Controller_ExtJS_Supplier_DefaultTest extends PHPUnit_Framework_TestCase
{
private $_object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*
* @access protected
*/
protected function setUp()
{
$this->_object = new Controller_ExtJS_Supplier_Default( TestHelper::getContext() );
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*
* @access protected
*/
protected function tearDown()
{
$this->_object = null;
}
public function testSearchItems()
{
$params = (object) array(
'site' => 'unittest',
'condition' => (object) array( '&&' => array( 0 => (object) array( '~=' => (object) array( 'supplier.label' => 'unitSupplier001' ) ) ) ),
'sort' => 'supplier.label',
'dir' => 'ASC',
'start' => 0,
'limit' => 1,
);
$result = $this->_object->searchItems( $params );
$this->assertEquals( 1, count( $result['items'] ) );
$this->assertEquals( 1, $result['total'] );
$this->assertEquals( 'unitSupplier001', $result['items'][0]->{'supplier.label'} );
}
public function testSaveDeleteItem()
{
$saveParam = (object) array(
'site' => 'unittest',
'items' => (object) array(
'supplier.label' => 'controller test supplier',
'supplier.status' => 1,
),
);
$searchParams = (object) array( 'site' => 'unittest', 'condition' => (object) array( '&&' => array( 0 => (object) array( '==' => (object) array( 'supplier.label' => 'controller test supplier' ) ) ) ) );
$saved = $this->_object->saveItems( $saveParam );
$searched = $this->_object->searchItems( $searchParams );
$deleteParams = (object) array( 'site' => 'unittest', 'items' => $saved['items']->{'supplier.id'} );
$this->_object->deleteItems( $deleteParams );
$result = $this->_object->searchItems( $searchParams );
$this->assertInternalType( 'object', $saved['items'] );
$this->assertNotNull( $saved['items']->{'supplier.id'} );
$this->assertEquals( $saved['items']->{'supplier.id'}, $searched['items'][0]->{'supplier.id'} );
$this->assertEquals( $saved['items']->{'supplier.label'}, $searched['items'][0]->{'supplier.label'} );
$this->assertEquals( $saved['items']->{'supplier.status'}, $searched['items'][0]->{'supplier.status'} );
$this->assertEquals( 1, count( $searched['items'] ) );
$this->assertEquals( 0, count( $result['items'] ) );
}
public function testFinish()
{
$result = $this->_object->finish( (object) array( 'site' => 'unittest', 'items' => -1 ) );
$this->assertEquals( array( 'success' => true ), $result );
}
}