-
Notifications
You must be signed in to change notification settings - Fork 182
Expand file tree
/
Copy pathRuleTest.php
More file actions
52 lines (42 loc) · 1.47 KB
/
RuleTest.php
File metadata and controls
52 lines (42 loc) · 1.47 KB
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
<?php
namespace Bigcommerce\Test\Unit\Api\Resources;
use Bigcommerce\Api\Resources\Rule;
use Bigcommerce\Api\Client;
class RuleTest extends ResourceTestBase
{
public function testCreatePassesThroughToConnection()
{
$rule = new Rule((object)array('id' => 1, 'product_id' => 1));
$this->connection->expects($this->once())
->method('post')
->with($this->basePath . '/products/1/rules', (object)array());
$rule->create();
}
public function testUpdatePassesThroughToConnection()
{
$rule = new Rule((object)array('id' => 1, 'product_id' => 1));
$this->connection->expects($this->once())
->method('put')
->with($this->basePath . '/products/1/rules/1', (object)array());
$rule->update();
}
public function testRuleHasConditions()
{
$rule = new Rule((object)array(
'product_id' => 1,
'conditions' => array(
array('option_value_id' => 1, 'product_option_id' => 1)
)
));
$this->assertInstanceOf('Bigcommerce\Api\Resources\RuleCondition', $rule->conditions[0]);
$this->assertEquals(1, $rule->conditions[0]->option_value_id);
$this->assertEquals(1, $rule->conditions[0]->product_option_id);
}
public function testRuleHasNoConditions()
{
$rule = new Rule((object)array(
'product_id' => 1
));
$this->assertEmpty($rule->conditions);
}
}