Skip to content

Commit

Permalink
Merge pull request #15 from Tr0nYx/master
Browse files Browse the repository at this point in the history
ArrayCollection Fix
  • Loading branch information
Tr0nYx committed Sep 30, 2016
2 parents ec628d4 + a0d12e7 commit 1d701ba
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/Api/Methods/BondController.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function getBonds()
'ArrayCollection<Alphatrader\ApiBundle\Model\Bond>',
'json'
);
if (empty($oResult) && !isset($oResult[0])) {
if (!is_array($oResult)) {
$oResult = $this->getSerializer()->deserialize(
$data,
'Alphatrader\ApiBundle\Model\Error',
Expand Down
2 changes: 1 addition & 1 deletion src/Api/Methods/CashTransferLogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function getCashTransferLogs(
'ArrayCollection<Alphatrader\ApiBundle\Model\CashTransferLogEntry>',
'json'
);
if (empty($oResult) && !isset($oResult[0])) {
if (!is_array($oResult)) {
$oResult = $this->getSerializer()->deserialize(
$data,
'Alphatrader\ApiBundle\Model\Error',
Expand Down
6 changes: 3 additions & 3 deletions src/Api/Methods/CompanyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function getCompanies($all)
'ArrayCollection<Alphatrader\ApiBundle\Model\Company>',
'json'
);
if (empty($oResult) && !isset($oResult[0])) {
if (!is_array($oResult)) {
$oResult = $this->getSerializer()->deserialize(
$data,
'Alphatrader\ApiBundle\Model\Error',
Expand Down Expand Up @@ -83,7 +83,7 @@ public function getCompanyByUserId(UserAccount $user)
'ArrayCollection<Alphatrader\ApiBundle\Model\Company>',
'json'
);
if (empty($oResult) && !isset($oResult[0])) {
if (!is_array($oResult)) {
$oResult = $this->getSerializer()->deserialize(
$data,
'Alphatrader\ApiBundle\Model\Error',
Expand All @@ -107,7 +107,7 @@ public function getCompanyByUserName($username)
'ArrayCollection<Alphatrader\ApiBundle\Model\Company>',
'json'
);
if (empty($oResult) && !isset($oResult[0])) {
if (!is_array($oResult)) {
$oResult = $this->getSerializer()->deserialize(
$data,
'Alphatrader\ApiBundle\Model\Error',
Expand Down
6 changes: 3 additions & 3 deletions src/Api/Methods/EventController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function getEvents($afterDate)
'ArrayCollection<Alphatrader\ApiBundle\Model\Events>',
'json'
);
if (empty($oResult) && !isset($oResult[0])) {
if (!is_array($oResult)) {
$oResult = $this->getSerializer()->deserialize(
$data,
'Alphatrader\ApiBundle\Model\Error',
Expand All @@ -59,7 +59,7 @@ public function searchEvents($realms, $afterDate)
'ArrayCollection<Alphatrader\ApiBundle\Model\Events>',
'json'
);
if (empty($oResult) && !isset($oResult[0])) {
if (!is_array($oResult)) {
$oResult = $this->getSerializer()->deserialize(
$data,
'Alphatrader\ApiBundle\Model\Error',
Expand All @@ -85,7 +85,7 @@ public function searchEventsByType($eventtype, $realms, $afterDate)
'ArrayCollection<Alphatrader\ApiBundle\Model\Events>',
'json'
);
if (empty($oResult) && !isset($oResult[0])) {
if (!is_array($oResult)) {
$oResult = $this->getSerializer()->deserialize(
$data,
'Alphatrader\ApiBundle\Model\Error',
Expand Down
2 changes: 1 addition & 1 deletion src/Api/Methods/ListingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function getListing($secIdentPart)
'ArrayCollection<Alphatrader\ApiBundle\Model\Listing>',
'json'
);
if (empty($oResult) && !isset($oResult[0])) {
if (!is_array($oResult)) {
$oResult = $this->getSerializer()->deserialize(
$data,
'Alphatrader\ApiBundle\Model\Error',
Expand Down
2 changes: 1 addition & 1 deletion src/Api/Methods/MainInterestRateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function getMainInterestRate()
'ArrayCollection<Alphatrader\ApiBundle\Model\MainInterestRate>',
'json'
);
if (empty($oResult) && !isset($oResult[0])) {
if (!is_array($oResult)) {
$oResult = $this->getSerializer()->deserialize(
$data,
'Alphatrader\ApiBundle\Model\Error',
Expand Down
4 changes: 2 additions & 2 deletions src/Api/Methods/NotificationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function getNotifications()
'ArrayCollection<Alphatrader\ApiBundle\Model\Notifications>',
'json'
);
if (empty($oResult) && !isset($oResult[0])) {
if (!is_array($oResult)) {
$oResult = $this->getSerializer()->deserialize(
$data,
'Alphatrader\ApiBundle\Model\Error',
Expand All @@ -53,7 +53,7 @@ public function getUnreadNotifications()
'ArrayCollection<Alphatrader\ApiBundle\Model\Notifications>',
'json'
);
if (empty($oResult) && !isset($oResult[0])) {
if (!is_array($oResult)) {
$oResult = $this->getSerializer()->deserialize(
$data,
'Alphatrader\ApiBundle\Model\Error',
Expand Down
13 changes: 8 additions & 5 deletions tests/AlphaTraderApiTests/AlphaTraderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Alphatrader\ApiBundle\Api\AlphaTrader;
use Alphatrader\ApiBundle\Model\Company;
use Alphatrader\ApiBundle\Model\Useraccount;
use JMS\Serializer\Exception\RuntimeException;
use Tests\Methods\BaseTestCase;

Expand Down Expand Up @@ -55,11 +54,15 @@ public function test_getCashTransferLogs()
$this->alphatrader->getCashTransferLogs(new \DateTime(),new \DateTime(),$log[0]['senderBankAccount'],$log[0]['receiverBankAccount']);
}

/*public function test_generateCash()
public function test_generateCash()
{
$this->expectException(RuntimeException::class);
$this->assertNull($this->alphatrader->generateCash(50000)->getMessagePrototype());
}*/
$response = ['cash'=>50000];
$expected = json_encode($response);
$myFactory = $this->getMockBuilder('Alphatrader\ApiBundle\Api\AlphaTrader', array('generateCash'))->disableOriginalConstructor()->getMock();
$myFactory->expects($this->any())->method('generateCash')->will($this->returnValue($expected));
$val = $myFactory->generateCash(50000);
$this->assertEquals(json_decode($val)->cash,$response['cash']);
}

public function test_getChats()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/AlphaTraderApiTests/Methods/BondControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,6 @@ public function test_getBonds()
$bondcontroller->setClient($this->getClient($expected));
$val = $bondcontroller->getBonds();

$this->assertInstanceOf('Alphatrader\ApiBundle\Model\Error', $val);
$this->assertTrue(is_array($val));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ public function test_getCashTransferLogs()
$bondcontroller->setClient($this->getClient($expected));
$val = $bondcontroller->getCashTransferLogs( new \DateTime(), new \DateTime(),1,1);

$this->assertInstanceOf('Alphatrader\ApiBundle\Model\Error', $val);
$this->assertTrue(is_array($val));
}
}

0 comments on commit 1d701ba

Please sign in to comment.