Skip to content

Commit

Permalink
Merge pull request #69 from bmeclazcke/master
Browse files Browse the repository at this point in the history
Updated with tests and fixed class paths
  • Loading branch information
delatbabel authored May 28, 2017
2 parents 936bf09 + 66da7f6 commit a19747c
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ public function deletePlan(array $parameters = array())
*/
public function listPlans(array $parameters = array())
{
return $this->createRequest('App\Lib\Omnipay\Stripe\Message\ListPlansRequest', $parameters);
return $this->createRequest('\Omnipay\Stripe\Message\ListPlansRequest', $parameters);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Message/ListPlansRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* Stripe List Plans Request.
*/
namespace App\Lib\Omnipay\Stripe\Message;
namespace Omnipay\Stripe\Message;

// use Omnipay\Common\Message\AbstractRequest;

Expand All @@ -13,7 +13,7 @@
* @see Omnipay\Stripe\Gateway
* @link https://stripe.com/docs/api/curl#list_plans
*/
class ListPlansRequest extends \Omnipay\Stripe\Message\AbstractRequest
class ListPlansRequest extends AbstractRequest
{
public function getData()
{
Expand Down
7 changes: 7 additions & 0 deletions tests/GatewayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,13 @@ public function testDeletePlan()
$this->assertSame('basic', $request->getId());
}

public function testListPlans()
{
$request = $this->gateway->listPlans(array());

$this->assertInstanceOf('Omnipay\Stripe\Message\ListPlansRequest', $request);
}

public function testCreateSubscription()
{
$request = $this->gateway->createSubscription(array('plan' => 'basic'));
Expand Down
38 changes: 38 additions & 0 deletions tests/Message/ListPlansTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace Omnipay\Stripe\Message;

use Omnipay\Tests\TestCase;

class ListInvoicesRequestTest extends TestCase
{
public function setUp()
{
$this->request = new ListPlansRequest($this->getHttpClient(), $this->getHttpRequest());
}

public function testEndpoint()
{
$this->assertSame('https://api.stripe.com/v1/plans', $this->request->getEndpoint());
}

public function testSendSuccess()
{
$this->setMockHttpResponse('ListPlans.txt');
$response = $this->request->send();

$this->assertTrue($response->isSuccessful());
$this->assertFalse($response->isRedirect());
$this->assertNotNull($response->getList());
$this->assertNull($response->getMessage());
}

/**
* According to documentation: https://stripe.com/docs/api/php#list_plans
* This request should never throw an error.
*/
public function testSendFailure()
{
this->assertTrue(true);
}
}
46 changes: 46 additions & 0 deletions tests/Mock/ListPlansSuccess.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
HTTP/1.1 200 OK
Server: nginx
Date: Mon, 29 Feb 2016 02:40:46 GMT
Content-Type: application/json
Content-Length: 6247
Connection: keep-alive
Access-Control-Allow-Credentials: true
Cache-Control: no-cache, no-store

{
"object" => "list",
"url" => "/v1/plans",
"has_more" => false,
"data" => [
{
"id": "test-1",
"object": "plan",
"amount": 29995,
"created": 1483391153,
"currency": "usd",
"interval": "year",
"interval_count": 1,
"livemode": false,
"metadata": {
},
"name": "Test 1",
"statement_descriptor": "Test 1",
"trial_period_days": 14
},
{
"id": "test-2",
"object": "plan",
"amount": 29995,
"created": 1483391153,
"currency": "usd",
"interval": "year",
"interval_count": 1,
"livemode": false,
"metadata": {
},
"name": "Test 1",
"statement_descriptor": "Test 2",
"trial_period_days": 14
}
]
}

0 comments on commit a19747c

Please sign in to comment.