|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Created by PhpStorm. |
|
5
|
|
|
* User: pjxh |
|
6
|
|
|
* Date: 15-11-1 |
|
7
|
|
|
* Time: 下午5:10 |
|
8
|
|
|
*/ |
|
9
|
|
|
namespace Overtrue\Wechat\Test\Shop; |
|
10
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
use Overtrue\Wechat\Image; |
|
13
|
|
|
use Overtrue\Wechat\Shop\Data\Shelf as ShelfData; |
|
14
|
|
|
use Overtrue\Wechat\Shop\Shelf; |
|
15
|
|
|
use Overtrue\Wechat\Test\TestBase; |
|
16
|
|
|
|
|
17
|
|
|
class ShelfTest extends TestBase |
|
18
|
|
|
{ |
|
19
|
|
|
|
|
20
|
|
|
protected $url; |
|
21
|
|
|
|
|
22
|
|
|
protected function setUp() |
|
23
|
|
|
{ |
|
24
|
|
|
parent::setUp(); |
|
25
|
|
|
|
|
26
|
|
|
$img = new Image($this->config->appId,$this->config->appSecret); |
|
|
|
|
|
|
27
|
|
|
|
|
28
|
|
|
$this->url = $img->upload(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'Image'.DIRECTORY_SEPARATOR.'aa.jpg'); |
|
29
|
|
|
|
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public static function shelf($arry = false) |
|
33
|
|
|
{ |
|
34
|
|
|
$groupId = '207133170'; |
|
35
|
|
|
|
|
36
|
|
|
$shelf = new ShelfData(); |
|
37
|
|
|
$shelf->controlTwo(array($groupId,$groupId,$groupId)); |
|
38
|
|
|
|
|
39
|
|
|
if ($arry) return $shelf->toArray(); |
|
40
|
|
|
|
|
41
|
|
|
return $shelf; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
View Code Duplication |
public function testAdd() |
|
45
|
|
|
{ |
|
46
|
|
|
|
|
47
|
|
|
$shelfData = $this->shelf(); |
|
48
|
|
|
|
|
49
|
|
|
$shelf = new Shelf($this->http); |
|
50
|
|
|
$response = $shelf->add(function(ShelfData $shelf) use ($shelfData) { |
|
|
|
|
|
|
51
|
|
|
return $shelfData; |
|
52
|
|
|
},$this->url,'test'); |
|
53
|
|
|
$this->assertTrue(is_array($response)); |
|
54
|
|
|
|
|
55
|
|
|
return $response['shelf_id']; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @depends testAdd |
|
60
|
|
|
*/ |
|
61
|
|
View Code Duplication |
public function testUpdate($shelfId) |
|
62
|
|
|
{ |
|
63
|
|
|
|
|
64
|
|
|
$shelfData = $this->shelf(); |
|
65
|
|
|
|
|
66
|
|
|
$shelf = new Shelf($this->http); |
|
67
|
|
|
$response = $shelf->update(function(ShelfData $shelf) use ($shelfData) { |
|
|
|
|
|
|
68
|
|
|
return $shelfData; |
|
69
|
|
|
}, $shelfId, $this->url,'测试'); |
|
70
|
|
|
|
|
71
|
|
|
$this->assertTrue($response); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
public function testLists() |
|
75
|
|
|
{ |
|
76
|
|
|
|
|
77
|
|
|
$shelf = new Shelf($this->http); |
|
78
|
|
|
$response = $shelf->lists(); |
|
79
|
|
|
$this->assertTrue(is_array($response)); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* @depends testAdd |
|
84
|
|
|
*/ |
|
85
|
|
|
public function testGetById($shelfId) |
|
86
|
|
|
{ |
|
87
|
|
|
|
|
88
|
|
|
$shelf = new Shelf($this->http); |
|
89
|
|
|
$response = $shelf->getById($shelfId); |
|
90
|
|
|
$this->assertTrue(is_array($response)); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* @depends testAdd |
|
95
|
|
|
*/ |
|
96
|
|
|
public function testDelete($shelfId) |
|
97
|
|
|
{ |
|
98
|
|
|
|
|
99
|
|
|
$shelf = new Shelf($this->http); |
|
100
|
|
|
$response = $shelf->delete($shelfId); |
|
101
|
|
|
$this->assertTrue($response); |
|
102
|
|
|
} |
|
103
|
|
|
} |
|
104
|
|
|
|
Since your code implements the magic getter
_get, this function will be called for any read access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.