Skip to content

Commit

Permalink
Added a whole lot of AeroGearPush phpunit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ramlev committed Mar 21, 2016
1 parent a1ab217 commit 95ad17f
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/AeroGearPush.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class AeroGearPush
/**
* AeroGearPush constructor.
*/
public function __construct($serverUrl, $options = [])
public function __construct($serverUrl = false, $options = [])
{
if (false == $serverUrl || false == parse_url($serverUrl)) {
throw new AeroGearPushException('No, or malformed serverUrl available');
Expand Down
97 changes: 97 additions & 0 deletions tests/AeroGearPush/Tests/AeroGearPushTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?php
/**
* This file is part of the AeroGearPush package.
*
* (c) NAPP <http://napp.dk>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace AeroGearPush\Tests;

use Napp\AeroGearPush\AeroGearPush;
use Napp\AeroGearPush\Request\GetMetricsDashboardRequest;
use Napp\AeroGearPush\Request\GetMetricsMessagesRequest;
use Napp\AeroGearPush\Request\GetSysInfoHealthRequest;

/**
* Class AeroGearPushTest
*
* @package AeroGearPush\Tests
* @author Hasse Ramlev Hansen <[email protected]>
*/
class AeroGearPushTest extends \PHPUnit_Framework_TestCase
{
/**
* @expectedException \Napp\AeroGearPush\Exception\AeroGearPushException
*/
public function testServerUrlException()
{
new AeroGearPush();
}

public function testAeroGearPushClass()
{
$serverUrl = 'http://host.com';
$masterSecret = uniqid();
$applicationId = uniqid();
$validateSSL = true;

$aerogear = new AeroGearPush($serverUrl);

$aerogear->setApplicationId($applicationId);
$aerogear->setMasterSecret($masterSecret);
$aerogear->setValidateSSL($validateSSL);

$this->assertEquals($serverUrl, $aerogear->serverUrl);
$this->assertEquals($masterSecret, $aerogear->masterSecret);
$this->assertEquals($applicationId, $aerogear->applicationId);
$this->assertTrue($aerogear->verifySSL);
}

/**
* @expectedException \Napp\AeroGearPush\Exception\AeroGearMissingOAuthTokenException
*/
public function testSysInfoHealthException()
{
$serverUrl = 'http://host.com/';

$request = new GetSysInfoHealthRequest();
$aerogear = new AeroGearPush($serverUrl);
$aerogear->sysInfoHealth($request);
}

public function testSysInfoHealth()
{
$serverUrl = 'http://host.com/';
$aerogear = new AeroGearPush($serverUrl);

$request = new GetSysInfoHealthRequest();
$request->setOAuthToken(uniqid());

$aerogear->sysInfoHealth($request);
}

public function testMetricsDashboard()
{
$serverUrl = 'http://host.com/';
$aerogear = new AeroGearPush($serverUrl);

$request = new GetMetricsDashboardRequest();
$request->setOAuthToken(uniqid());

$aerogear->metricsDashboard($request);
}

public function testMetricsMessages()
{
$serverUrl = 'http://host.com/';
$aerogear = new AeroGearPush($serverUrl);

$request = new GetMetricsMessagesRequest(uniqid());
$request->setOAuthToken(uniqid());

$aerogear->metricsMessages($request);
}
}

0 comments on commit 95ad17f

Please sign in to comment.