Skip to content

Commit

Permalink
Adjust Product Rule Conditions Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jbutz committed Oct 1, 2017
1 parent bcf5521 commit ad206eb
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions test/Unit/Api/Resources/RuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,27 @@ public function testUpdatePassesThroughToConnection()
$rule->update();
}

public function testConditionsPassesThroughToConnection()
public function testRuleHasConditions()
{
$rule = new Rule((object)array(
'product_id' => 1,
'conditions' => (object)array('resource' => '/products/1/rules/1/conditions')
'conditions' => array(
array('option_value_id' => 1, 'product_option_id' => 1)
)
));
$this->connection->expects($this->once())
->method('get')
->with($this->basePath . '/products/1/rules/1/conditions')
->will($this->returnValue(array(array(), array())));

$collection = $rule->conditions;
$this->assertInternalType('array', $collection);
foreach ($collection as $condition) {
$this->assertInstanceOf('Bigcommerce\\Api\\Resources\\RuleCondition', $condition);
}

$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);
}
}

0 comments on commit ad206eb

Please sign in to comment.