Skip to content

Commit

Permalink
add tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
makasim committed Mar 21, 2016
1 parent 4725613 commit 9be62f8
Show file tree
Hide file tree
Showing 5 changed files with 164 additions and 6 deletions.
104 changes: 104 additions & 0 deletions Tests/Action/Api/CreatePlanActionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?php
namespace Payum\Stripe\Tests\Action\Api;

use Payum\Core\Action\ActionInterface;
use Payum\Core\ApiAwareInterface;
use Payum\Stripe\Action\Api\CreatePlanAction;
use Payum\Stripe\Keys;
use Payum\Stripe\Request\Api\CreatePlan;

class CreatePlanActionTest extends \PHPUnit_Framework_TestCase
{
/**
* @test
*/
public function shouldImplementsActionInterface()
{
$rc = new \ReflectionClass(CreatePlanAction::class);

$this->assertTrue($rc->isSubclassOf(ActionInterface::class));
}

/**
* @test
*/
public function shouldImplementsApiAwareInterface()
{
$rc = new \ReflectionClass(CreatePlanAction::class);

$this->assertTrue($rc->isSubclassOf(ApiAwareInterface::class));
}

/**
* @test
*/
public function couldBeConstructedWithoutAnyArguments()
{
new CreatePlanAction();
}

/**
* @test
*/
public function shouldAllowSetKeysAsApi()
{
$action = new CreatePlanAction();

$action->setApi(new Keys('publishableKey', 'secretKey'));
}

/**
* @test
*
* @expectedException \Payum\Core\Exception\UnsupportedApiException
*/
public function throwNotSupportedApiIfNotKeysGivenAsApi()
{
$action = new CreatePlanAction();

$action->setApi('not keys instance');
}

/**
* @test
*/
public function shouldSupportCreatePlanRequestWithArrayAccessModel()
{
$action = new CreatePlanAction();

$this->assertTrue($action->supports(new CreatePlan([])));
}

/**
* @test
*/
public function shouldNotSupportCreatePlanRequestWithNotArrayAccessModel()
{
$action = new CreatePlanAction();

$this->assertFalse($action->supports(new CreatePlan(new \stdClass())));
}

/**
* @test
*/
public function shouldNotSupportNotCreatePlanRequest()
{
$action = new CreatePlanAction();

$this->assertFalse($action->supports(new \stdClass()));
}

/**
* @test
*
* @expectedException \Payum\Core\Exception\RequestNotSupportedException
* @expectedExceptionMessage Action CreatePlanAction is not supported the request stdClass.
*/
public function throwRequestNotSupportedIfNotSupportedGiven()
{
$action = new CreatePlanAction();

$action->execute(new \stdClass());
}
}
7 changes: 4 additions & 3 deletions Tests/Request/Api/CreateChargeTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
namespace Payum\Stripe\Tests\Request\Api;

use Payum\Core\Request\Generic;
use Payum\Stripe\Request\Api\CreateCharge;

class CreateChargeTest extends \PHPUnit_Framework_TestCase
Expand All @@ -10,16 +11,16 @@ class CreateChargeTest extends \PHPUnit_Framework_TestCase
*/
public function shouldBeSubClassOfGeneric()
{
$rc = new \ReflectionClass('Payum\Stripe\Request\Api\CreateCharge');
$rc = new \ReflectionClass(CreateCharge::class);

$this->assertTrue($rc->isSubclassOf('Payum\Core\Request\Generic'));
$this->assertTrue($rc->isSubclassOf(Generic::class));
}

/**
* @test
*/
public function couldBeConstructedWithModelAsFirstArgument()
{
new CreateCharge($model = array());
new CreateCharge($model = []);
}
}
26 changes: 26 additions & 0 deletions Tests/Request/Api/CreateCustomerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
namespace Payum\Stripe\Tests\Request\Api;

use Payum\Core\Request\Generic;
use Payum\Stripe\Request\Api\CreateCustomer;

class CreateCustomerTest extends \PHPUnit_Framework_TestCase
{
/**
* @test
*/
public function shouldBeSubClassOfGeneric()
{
$rc = new \ReflectionClass(CreateCustomer::class);

$this->assertTrue($rc->isSubclassOf(Generic::class));
}

/**
* @test
*/
public function couldBeConstructedWithModelAsFirstArgument()
{
new CreateCustomer($model = []);
}
}
26 changes: 26 additions & 0 deletions Tests/Request/Api/CreatePlanTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
namespace Payum\Stripe\Tests\Request\Api;

use Payum\Core\Request\Generic;
use Payum\Stripe\Request\Api\CreatePlan;

class CreatePlanTest extends \PHPUnit_Framework_TestCase
{
/**
* @test
*/
public function shouldBeSubClassOfGeneric()
{
$rc = new \ReflectionClass(CreatePlan::class);

$this->assertTrue($rc->isSubclassOf(Generic::class));
}

/**
* @test
*/
public function couldBeConstructedWithModelAsFirstArgument()
{
new CreatePlan($model = []);
}
}
7 changes: 4 additions & 3 deletions Tests/Request/Api/ObtainTokenTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
namespace Payum\Stripe\Tests\Request\Api;

use Payum\Core\Request\Generic;
use Payum\Stripe\Request\Api\ObtainToken;

class ObtainTokenTest extends \PHPUnit_Framework_TestCase
Expand All @@ -10,16 +11,16 @@ class ObtainTokenTest extends \PHPUnit_Framework_TestCase
*/
public function shouldBeSubClassOfGeneric()
{
$rc = new \ReflectionClass('Payum\Stripe\Request\Api\ObtainToken');
$rc = new \ReflectionClass(ObtainToken::class);

$this->assertTrue($rc->isSubclassOf('Payum\Core\Request\Generic'));
$this->assertTrue($rc->isSubclassOf(Generic::class));
}

/**
* @test
*/
public function couldBeConstructedWithModelAsFirstArgument()
{
new ObtainToken($model = array());
new ObtainToken($model = []);
}
}

0 comments on commit 9be62f8

Please sign in to comment.