Skip to content

Commit 4a78f69

Browse files
author
Ernest E
committed
test: add package test
1 parent a682158 commit 4a78f69

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

tests/BaseTester.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ class BaseTester extends TestCase {
1515

1616
protected $appId = 620;
1717

18+
protected $packageId = 76710;
19+
1820
protected $groupId = 103582791429521412;
1921

2022
protected $groupName = 'Valve';
@@ -87,6 +89,11 @@ protected function checkAppProperties($app)
8789
$this->checkNestedAppProperties($app);
8890
}
8991

92+
protected function checkPackageProperties($package)
93+
{
94+
$this->checkNestedPackageProperties($package);
95+
}
96+
9097
protected function checkGroupProperties($group)
9198
{
9299
$this->checkGroupMainSummaryProperties($group);
@@ -134,6 +141,18 @@ private function checkNestedAppProperties($app)
134141
$this->assertObjectHasAttributes($attributes, $app->metacritic);
135142
}
136143

144+
/**
145+
* @param $packahe
146+
*/
147+
private function checkNestedPackageProperties($packahe)
148+
{
149+
$attributes = ['currency', 'initial', 'final', 'discount_percent', 'individual'];
150+
$this->assertObjectHasAttributes($attributes, $packahe->price);
151+
152+
$attributes = ['windows', 'mac', 'linux'];
153+
$this->assertObjectHasAttributes($attributes, $packahe->platforms);
154+
}
155+
137156
/**
138157
* @param $group
139158
*/

tests/PackageTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
require_once 'BaseTester.php';
4+
5+
/** @group Package */
6+
class PackageTest extends BaseTester
7+
{
8+
/** @test */
9+
public function it_gets_details_for_an_package_by_id()
10+
{
11+
$details = $this->steamClient->package()->packageDetails($this->packageId);
12+
13+
$this->assertCount(1, $details);
14+
15+
$detail = $details->first();
16+
17+
$this->checkPackageProperties($detail);
18+
$this->checkPackageClasses($detail);
19+
}
20+
21+
/**
22+
* @param $detail
23+
*/
24+
private function checkPackageClasses($detail)
25+
{
26+
$this->assertInstanceOf('Syntax\SteamApi\Containers\Package', $detail);
27+
}
28+
}

0 commit comments

Comments
 (0)