Skip to content

Commit

Permalink
Trying to fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
marktheunissen committed Oct 29, 2020
1 parent e852b64 commit 1762aa2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tests/unit_tests/Commands/Plan/ListCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ public function testListPlans()
['id' => 'master', 'sku' => 'xxx'],
['id' => 'another', 'sku' => 'yyy'],
];

$plans_collection = $this->getMockBuilder(Plans::class)
->disableOriginalConstructor()
->getMock();
$this->site = $this->getMockBuilder(Site::class)
->disableOriginalConstructor()
->getMock();
$this->site->id = 'site_id';
$plans_collection->method('getCollectedClass')->willReturn(Plan::class);
$plans_collection->expects($this->once())
->method('serialize')
Expand Down
21 changes: 21 additions & 0 deletions tests/unit_tests/Models/PlanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ public function setUp()
$this->plans = $this->getMockBuilder(Plans::class)
->disableOriginalConstructor()
->getMock();
$this->site = $this->getMockBuilder(Site::class)
->disableOriginalConstructor()
->getMock();
$this->data = [
'monthly_collection' => [
'attributes' => [
Expand Down Expand Up @@ -78,6 +81,8 @@ public function setUp()
*/
public function testConstruct()
{
$this->site->id = 'site_id';

$data_from_collection = $this->data['monthly_collection'];
$this->assertEquals(
$data_from_collection['attributes']['plan_name'],
Expand All @@ -93,6 +98,8 @@ public function testConstruct()
*/
public function testGetMonthlyPrice()
{
$this->site->id = 'site_id';

$annual_data = $this->data['annual_collection'];
$this->assertEquals(
($annual_data['attributes']['price']/12),
Expand All @@ -108,6 +115,8 @@ public function testGetMonthlyPrice()
*/
public function testGetName()
{
$this->site->id = 'site_id';

$data_from_collection = $this->data['annual_collection'];
$this->assertEquals(
$data_from_collection['attributes']['plan_name'],
Expand All @@ -123,6 +132,8 @@ public function testGetName()
*/
public function testGetReferences()
{
$this->site->id = 'site_id';

$data = $this->data['monthly_site'];
$this->assertEquals(
[$data['id'], $data['sku'],],
Expand All @@ -135,6 +146,8 @@ public function testGetReferences()
*/
public function testGetSku()
{
$this->site->id = 'site_id';

$data_from_collection = $this->data['annual_collection'];
$this->assertEquals(
$data_from_collection['attributes']['plan_sku'],
Expand All @@ -150,6 +163,8 @@ public function testGetSku()
*/
public function testIsAnnual()
{
$this->site->id = 'site_id';

$this->assertTrue($this->makePlan($this->data['annual_collection'])->isAnnual());
$this->assertFalse($this->makePlan($this->data['monthly_collection'])->isAnnual());
}
Expand All @@ -159,6 +174,8 @@ public function testIsAnnual()
*/
public function testIsFree()
{
$this->site->id = 'site_id';

$this->assertFalse($this->makePlan($this->data['annual_collection'])->isFree());
$this->assertTrue($this->makePlan($this->data['free'])->isFree());
}
Expand All @@ -168,6 +185,8 @@ public function testIsFree()
*/
public function testIsMonthly()
{
$this->site->id = 'site_id';

$this->assertFalse($this->makePlan($this->data['annual_collection'])->isMonthly());
$this->assertTrue($this->makePlan($this->data['monthly_collection'])->isMonthly());
}
Expand All @@ -177,6 +196,8 @@ public function testIsMonthly()
*/
public function testSerialize()
{
$this->site->id = 'site_id';

$this->config->expects($this->exactly(2))
->method('get')
->with('monetary_format')
Expand Down

0 comments on commit 1762aa2

Please sign in to comment.