Skip to content

Commit

Permalink
Removing array dereference to be php 5.3 compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
gerbenjacobs committed Mar 28, 2015
1 parent 4f7cb52 commit cccceee
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
5 changes: 3 additions & 2 deletions tests/Entities/HabboTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ public function testGetHabboName() {
}

public function testTwoSelectedBadges() {
$this->assertEquals(2, count($this->habbo->getSelectedBadges()));
$this->assertInstanceOf('HabboAPI\Entities\Badge', $this->habbo->getSelectedBadges()[0]);
$selectedBadges = $this->habbo->getSelectedBadges();
$this->assertEquals(2, count($selectedBadges));
$this->assertInstanceOf('HabboAPI\Entities\Badge', $selectedBadges[0]);
}
}

23 changes: 16 additions & 7 deletions tests/HabboParserTest.php
Original file line number Diff line number Diff line change
@@ -1,32 +1,41 @@
<?php

use HabboAPI\Entities\Habbo;
use HabboAPI\HabboParser;

class HabboParserTest extends PHPUnit_Framework_TestCase {
private static $habbo;
private static $profile;
/** @var HabboParser|PHPUnit_Framework_MockObject_MockObject $habboParserMock */
private $habboParserMock;

public static function setUpBeforeClass() {
self::$habbo = json_decode(file_get_contents(dirname(__FILE__).'/data/com_koeientemmer_gethabbo.json'), true);
self::$profile = json_decode(file_get_contents(dirname(__FILE__).'/data/com_koeientemmer_getprofile.json'), true);
}

public function setUp() {
$this->habboParserMock = $this->getMock('\HabboAPI\HabboParser', array('_callUrl'), array($this->any()));
}

/**
* Testing the parseHabbo method with static input
*/
public function testParseHabbo() {
$habboParserMock = $this->getMock('\HabboAPI\HabboParser', array('_callUrl'), array($this->any()));
$habboParserMock->expects($this->once())->method('_callUrl')->will($this->returnValue(self::$habbo));
$this->habboParserMock->expects($this->once())->method('_callUrl')->will($this->returnValue(self::$habbo));

$habboObject = $habboParserMock->parseHabbo('koeientemmer');
/** @var Habbo $habboObject */
$habboObject = $this->habboParserMock->parseHabbo('koeientemmer');

$this->assertInstanceOf('HabboAPI\Entities\Habbo', $habboObject);
$this->assertInstanceOf('HabboAPI\Entities\Badge', $habboObject->getSelectedBadges()[0]);
$selectedBadges = $habboObject->getSelectedBadges();
$this->assertInstanceOf('HabboAPI\Entities\Badge', $selectedBadges[0]);
}

public function testParseProfile() {
$habboParserMock = $this->getMock('\HabboAPI\HabboParser', array('_callUrl'), array($this->any()));
$habboParserMock->expects($this->once())->method('_callUrl')->will($this->returnValue(self::$profile));
$this->habboParserMock->expects($this->once())->method('_callUrl')->will($this->returnValue(self::$profile));

$profile = $habboParserMock->parseProfile('hhus-9cd61b156972c2eb33a145d69918f965');
$profile = $this->habboParserMock->parseProfile('hhus-9cd61b156972c2eb33a145d69918f965');

$this->assertInstanceOf('HabboAPI\Entities\Habbo', $profile['habbo']);
$this->assertInstanceOf('HabboAPI\Entities\Habbo', $profile['friends'][0]);
Expand Down

0 comments on commit cccceee

Please sign in to comment.