Skip to content
This repository was archived by the owner on Sep 29, 2023. It is now read-only.

Add PHPUnit ^5.7 to test suite #1160

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"keywords": ["paypal", "payments", "rest", "sdk"],
"type": "library",
"license": "Apache-2.0",
"homepage": "http://paypal.github.io/PayPal-PHP-SDK/",
"homepage": "https://paypal.github.io/PayPal-PHP-SDK/",
"authors": [
{
"name": "PayPal",
Expand All @@ -18,11 +18,16 @@
"psr/log": "^1.0.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8.35"
"phpunit/phpunit": "^4.8.35 || ^5.7"
},
"autoload": {
"psr-0": {
"PayPal": "lib/"
"PayPal\\": "lib/"
}
},
"autoload-dev": {
"psr-0": {
"PayPal\\Test\\": "tests/"
}
}
}
4 changes: 2 additions & 2 deletions lib/PayPal/Api/ShippingInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public function getEmail()
/**
* Address of the invoice recipient.
*
* @param \PayPal\Api\InvoiceAddress $address
* @param \PayPal\Api\ShippingAddress $address
*
* @return $this
*/
Expand All @@ -148,7 +148,7 @@ public function setAddress($address)
/**
* The invoice recipient address.
*
* @return \PayPal\Api\InvoiceAddress
* @return \PayPal\Api\ShippingAddress
*/
public function getAddress()
{
Expand Down
19 changes: 19 additions & 0 deletions lib/PayPal/Api/WebhookEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,25 @@ public function getResource()
return $this->resource;
}

/**
* @param string $status
*
* @return $this
*/
public function setStatus($status)
{
$this->status = $status;
return $this;
}

/**
* @return string
*/
public function getStatus()
{
return $this->status;
}

/**
* Validates Received Event from Webhook, and returns the webhook event object. Because security verifications by verifying certificate chain is not enabled in PHP yet,
* we need to fallback to default behavior of retrieving the ID attribute of the data, and make a separate GET call to PayPal APIs, to retrieve the data.
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
testSuiteLoaderClass="PHPUnit_Runner_StandardTestSuiteLoader">
>

<testsuites>
<testsuite name="All">
Expand Down
7 changes: 0 additions & 7 deletions tests/PayPal/Test/Api/CurrencyConversionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,4 @@ public function testUrlValidationForWebUrl()
$obj = new CurrencyConversion();
$obj->setWebUrl(null);
}

public function testUrlValidationForWebUrlDeprecated()
{
$obj = new CurrencyConversion();
$obj->setWebUrl(null);
$this->assertNull($obj->getWebUrl());
}
}
3 changes: 1 addition & 2 deletions tests/PayPal/Test/Api/HyperSchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function testSerializationDeserialization()
{
$obj = new HyperSchema(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getLinks());
$this->assertNull($obj->getLinks());
$this->assertNotNull($obj->getFragmentResolution());
$this->assertNotNull($obj->getReadonly());
$this->assertNotNull($obj->getContentEncoding());
Expand All @@ -55,7 +55,6 @@ public function testSerializationDeserialization()
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getLinks(), LinksTest::getObject());
$this->assertEquals($obj->getFragmentResolution(), "TestSample");
$this->assertEquals($obj->getReadonly(), true);
$this->assertEquals($obj->getContentEncoding(), "TestSample");
Expand Down
4 changes: 2 additions & 2 deletions tests/PayPal/Test/Api/MerchantInfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class MerchantInfoTest extends TestCase
*/
public static function getJson()
{
return '{"email":"TestSample","first_name":"TestSample","last_name":"TestSample","address":' .AddressTest::getJson() . ',"business_name":"TestSample","phone":' .PhoneTest::getJson() . ',"fax":' .PhoneTest::getJson() . ',"website":"TestSample","tax_id":"TestSample","additional_info_label":"TestSample","additional_info":"TestSample"}';
return '{"email":"TestSample","first_name":"TestSample","last_name":"TestSample","address":' .InvoiceAddressTest::getJson() . ',"business_name":"TestSample","phone":' .PhoneTest::getJson() . ',"fax":' .PhoneTest::getJson() . ',"website":"TestSample","tax_id":"TestSample","additional_info_label":"TestSample","additional_info":"TestSample"}';
}

/**
Expand Down Expand Up @@ -63,7 +63,7 @@ public function testGetters($obj)
$this->assertEquals($obj->getEmail(), "TestSample");
$this->assertEquals($obj->getFirstName(), "TestSample");
$this->assertEquals($obj->getLastName(), "TestSample");
$this->assertEquals($obj->getAddress(), AddressTest::getObject());
$this->assertEquals($obj->getAddress(), InvoiceAddressTest::getObject());
$this->assertEquals($obj->getBusinessName(), "TestSample");
$this->assertEquals($obj->getPhone(), PhoneTest::getObject());
$this->assertEquals($obj->getFax(), PhoneTest::getObject());
Expand Down
17 changes: 8 additions & 9 deletions tests/PayPal/Test/Api/MerchantPreferencesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,23 +98,22 @@ public function testUrlValidationForNotifyUrl()
$obj = new MerchantPreferences();
$obj->setNotifyUrl(null);
}

/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage CancelUrl is not a fully qualified URL
*/
public function testUrlValidationForCancelUrlDeprecated()
{
$obj = new MerchantPreferences();
$obj->setCancelUrl(null);
$this->assertNull($obj->getCancelUrl());
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage ReturnUrl is not a fully qualified URL
*/
public function testUrlValidationForReturnUrlDeprecated()
{
$obj = new MerchantPreferences();
$obj->setReturnUrl(null);
$this->assertNull($obj->getReturnUrl());
}
public function testUrlValidationForNotifyUrlDeprecated()
{
$obj = new MerchantPreferences();
$obj->setNotifyUrl(null);
$this->assertNull($obj->getNotifyUrl());
}
}
7 changes: 0 additions & 7 deletions tests/PayPal/Test/Api/MetadataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,4 @@ public function testUrlValidationForPayerViewUrl()
$obj = new Metadata();
$obj->setPayerViewUrl(null);
}

public function testUrlValidationForPayerViewUrlDeprecated()
{
$obj = new Metadata();
$obj->setPayer_view_url(null);
$this->assertNull($obj->getPayer_view_url());
}
}
4 changes: 2 additions & 2 deletions tests/PayPal/Test/Api/PaymentCardTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ public function testGetters($obj)
$this->assertEquals($obj->getId(), "TestSample");
$this->assertEquals($obj->getNumber(), "TestSample");
$this->assertEquals($obj->getType(), "TestSample");
$this->assertEquals($obj->getExpireMonth(), "TestSample");
$this->assertEquals($obj->getExpireYear(), "TestSample");
$this->assertEquals($obj->getExpireMonth(), "123");
$this->assertEquals($obj->getExpireYear(), "123");
$this->assertEquals($obj->getStartMonth(), "TestSample");
$this->assertEquals($obj->getStartYear(), "TestSample");
$this->assertEquals($obj->getCvv2(), "TestSample");
Expand Down
3 changes: 1 addition & 2 deletions tests/PayPal/Test/Api/PlanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,8 @@ public function testList($obj, $mockApiContext)
->will($this->returnValue(
PlanListTest::getJson()
));
$params = ParamsTest::getObject();

$result = $obj->all($params, $mockApiContext, $mockPayPalRestCall);
$result = $obj->all(array(), $mockApiContext, $mockPayPalRestCall);
$this->assertNotNull($result);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/PayPal/Test/Api/RefundDetailTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function testSerializationDeserialization()
$obj = new RefundDetail(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getType());
$this->assertNotNull($obj->getTransactionId());
$this->assertNull($obj->getTransactionId());
$this->assertNotNull($obj->getDate());
$this->assertNotNull($obj->getNote());
$this->assertNotNull($obj->getAmount());
Expand All @@ -55,7 +55,7 @@ public function testSerializationDeserialization()
public function testGetters($obj)
{
$this->assertEquals($obj->getType(), "TestSample");
$this->assertEquals($obj->getTransactionId(), "TestSample");
$this->assertNull($obj->getTransactionId());
$this->assertEquals($obj->getDate(), "TestSample");
$this->assertEquals($obj->getNote(), "TestSample");
$this->assertEquals($obj->getAmount(), CurrencyTest::getObject());
Expand Down
4 changes: 2 additions & 2 deletions tests/PayPal/Test/Api/ShippingInfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ShippingInfoTest extends TestCase
*/
public static function getJson()
{
return '{"first_name":"TestSample","last_name":"TestSample","business_name":"TestSample","address":' .AddressTest::getJson() . '}';
return '{"first_name":"TestSample","last_name":"TestSample","business_name":"TestSample","address":' .ShippingAddressTest::getJson() . '}';
}

/**
Expand Down Expand Up @@ -56,6 +56,6 @@ public function testGetters($obj)
$this->assertEquals($obj->getFirstName(), "TestSample");
$this->assertEquals($obj->getLastName(), "TestSample");
$this->assertEquals($obj->getBusinessName(), "TestSample");
$this->assertEquals($obj->getAddress(), AddressTest::getObject());
$this->assertEquals($obj->getAddress(), ShippingAddressTest::getObject());
}
}
7 changes: 2 additions & 5 deletions tests/PayPal/Test/Api/WebhookEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class WebhookEventTest extends TestCase
*/
public static function getJson()
{
return '{"id":"TestSample","create_time":"TestSample","resource_type":"TestSample","event_version":"TestSample","event_type":"TestSample","summary":"TestSample","resource":"TestSampleObject","status":"TestSample","transmissions":"TestSampleObject","links":' .LinksTest::getJson() . '}';
return '{"id":"TestSample","create_time":"TestSample","resource_type":"TestSample","event_version":"TestSample","event_type":"TestSample","summary":"TestSample","resource":"TestSampleObject","status":"TestSample","links":' .LinksTest::getJson() . '}';
}

/**
Expand Down Expand Up @@ -51,7 +51,6 @@ public function testSerializationDeserialization()
$this->assertNotNull($obj->getSummary());
$this->assertNotNull($obj->getResource());
$this->assertNotNull($obj->getStatus());
$this->assertNotNull($obj->getTransmissions());
$this->assertNotNull($obj->getLinks());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
Expand All @@ -71,7 +70,6 @@ public function testGetters($obj)
$this->assertEquals($obj->getSummary(), "TestSample");
$this->assertEquals($obj->getResource(), "TestSampleObject");
$this->assertEquals($obj->getStatus(), "TestSample");
$this->assertEquals($obj->getTransmissions(), "TestSampleObject");
$this->assertEquals($obj->getLinks(), LinksTest::getObject());
}

Expand Down Expand Up @@ -109,9 +107,8 @@ public function testResend($obj, $mockApiContext)
->will($this->returnValue(
self::getJson()
));
$eventResend = EventResendTest::getObject();

$result = $obj->resend($eventResend, $mockApiContext, $mockPPRestCall);
$result = $obj->resend($mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
/**
Expand Down
3 changes: 1 addition & 2 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
date_default_timezone_set('GMT');
}
// Include the composer autoloader
$loader = require dirname(__DIR__) . '/vendor/autoload.php';
$loader->add('PayPal\\Test', __DIR__);
require dirname(__DIR__) . '/vendor/autoload.php';
if (!defined("PP_CONFIG_PATH")) {
define("PP_CONFIG_PATH", __DIR__);
}