Skip to content

Commit

Permalink
Merge pull request #114 from ljbergmann/1.0.0
Browse files Browse the repository at this point in the history
fixed bug
  • Loading branch information
ljbergmann committed Nov 15, 2016
2 parents 69d8291 + 5581f82 commit 7d77466
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Api/Traits/TimeStampTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ trait TimeStampTrait
*/
protected function formatTimeStamp($time)
{
return $time ?: ($time instanceof \DateTime ? ($time->getTimestamp() * 1000) : ((int)$time * 1000)) ?: null;
return ($time instanceof \DateTime ? ($time->getTimestamp() * 1000) : ((int)$time * 1000)) ?: null;
}
}
12 changes: 8 additions & 4 deletions tests/AlphaTraderApiTests/AlphaTraderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,22 @@ public function test_createClient()
{
self::assertInstanceOf(AlphaTrader::class, $this->alphatrader);
}

public function test_formatTimeStamp()
{
$timestamp = $this->invokeMethod($this->alphatrader, 'formatTimeStamp', array(new \DateTime()));
$this->assertInstanceOf('\DateTime', $timestamp);
$time = mt_rand(1262055681, 1474823143);
$date = new \DateTime();
$date->setTimestamp($time);
$timestamp = $this->invokeMethod($this->alphatrader, 'formatTimeStamp', array($date));
$this->assertTrue(is_int($timestamp));
$timestamp = $this->invokeMethod($this->alphatrader, 'formatTimeStamp', array(null));
$this->assertNull($timestamp);
$time = mt_rand(1262055681, 1474823143);

$timestamp = $this->invokeMethod($this->alphatrader, 'formatTimeStamp', array($time));
$this->assertTrue(is_int($timestamp));
}


/**
* @return Bankaccount
*/
Expand Down

0 comments on commit 7d77466

Please sign in to comment.