|
1 | 1 | <?php |
2 | 2 |
|
| 3 | +use HabboAPI\Entities\Habbo; |
| 4 | +use HabboAPI\HabboParser; |
| 5 | + |
3 | 6 | class HabboParserTest extends PHPUnit_Framework_TestCase { |
4 | 7 | private static $habbo; |
5 | 8 | private static $profile; |
| 9 | + /** @var HabboParser|PHPUnit_Framework_MockObject_MockObject $habboParserMock */ |
| 10 | + private $habboParserMock; |
6 | 11 |
|
7 | 12 | public static function setUpBeforeClass() { |
8 | 13 | self::$habbo = json_decode(file_get_contents(dirname(__FILE__).'/data/com_koeientemmer_gethabbo.json'), true); |
9 | 14 | self::$profile = json_decode(file_get_contents(dirname(__FILE__).'/data/com_koeientemmer_getprofile.json'), true); |
10 | 15 | } |
11 | 16 |
|
| 17 | + public function setUp() { |
| 18 | + $this->habboParserMock = $this->getMock('\HabboAPI\HabboParser', array('_callUrl'), array($this->any())); |
| 19 | + } |
| 20 | + |
12 | 21 | /** |
13 | 22 | * Testing the parseHabbo method with static input |
14 | 23 | */ |
15 | 24 | public function testParseHabbo() { |
16 | | - $habboParserMock = $this->getMock('\HabboAPI\HabboParser', array('_callUrl'), array($this->any())); |
17 | | - $habboParserMock->expects($this->once())->method('_callUrl')->will($this->returnValue(self::$habbo)); |
| 25 | + $this->habboParserMock->expects($this->once())->method('_callUrl')->will($this->returnValue(self::$habbo)); |
18 | 26 |
|
19 | | - $habboObject = $habboParserMock->parseHabbo('koeientemmer'); |
| 27 | + /** @var Habbo $habboObject */ |
| 28 | + $habboObject = $this->habboParserMock->parseHabbo('koeientemmer'); |
20 | 29 |
|
21 | 30 | $this->assertInstanceOf('HabboAPI\Entities\Habbo', $habboObject); |
22 | | - $this->assertInstanceOf('HabboAPI\Entities\Badge', $habboObject->getSelectedBadges()[0]); |
| 31 | + $selectedBadges = $habboObject->getSelectedBadges(); |
| 32 | + $this->assertInstanceOf('HabboAPI\Entities\Badge', $selectedBadges[0]); |
23 | 33 | } |
24 | 34 |
|
25 | 35 | public function testParseProfile() { |
26 | | - $habboParserMock = $this->getMock('\HabboAPI\HabboParser', array('_callUrl'), array($this->any())); |
27 | | - $habboParserMock->expects($this->once())->method('_callUrl')->will($this->returnValue(self::$profile)); |
| 36 | + $this->habboParserMock->expects($this->once())->method('_callUrl')->will($this->returnValue(self::$profile)); |
28 | 37 |
|
29 | | - $profile = $habboParserMock->parseProfile('hhus-9cd61b156972c2eb33a145d69918f965'); |
| 38 | + $profile = $this->habboParserMock->parseProfile('hhus-9cd61b156972c2eb33a145d69918f965'); |
30 | 39 |
|
31 | 40 | $this->assertInstanceOf('HabboAPI\Entities\Habbo', $profile['habbo']); |
32 | 41 | $this->assertInstanceOf('HabboAPI\Entities\Habbo', $profile['friends'][0]); |
|
0 commit comments