From 80c155107974156689255120fa0810c8959206b2 Mon Sep 17 00:00:00 2001 From: hstotelmyer Date: Mon, 8 Mar 2021 13:44:32 -0600 Subject: [PATCH] Update phpunit to get CI running (#315) * update dockerfile and composer file to versions of php and phpunit that will run in CI * setUp and teardown must be void compatible * fixup warning unit tests * address phpunit deprecation warnings * make integration tests setUp void compatible * fix breaking changes in integration tests * update tests to resolve deprecation warnings * Don't create phpunit cache file * add phpunit result cache to gitignore just in case * fixup SSL unit test * fixup failing integration tests --- .gitignore | 3 ++- Dockerfile | 6 +++--- Rakefile | 14 ++++++++------ composer.json | 2 +- tests/Setup.php | 3 +-- tests/integration/ApplePayTest.php | 6 ++---- tests/integration/CustomerTest.php | 4 ++-- tests/integration/DisputeTest.php | 6 +++--- tests/integration/DocumentUploadTest.php | 2 +- tests/integration/HttpTest.php | 14 ++++++-------- tests/integration/MasterpassCardTest.php | 2 +- tests/integration/PaymentMethodTest.php | 16 ++++++++-------- .../PaymentMethodWithUsBankAccountTest.php | 10 +++++----- tests/integration/SamsungPayCardTest.php | 2 +- tests/integration/TestTransactionTest.php | 3 +-- tests/integration/TransactionTest.php | 16 ++++++++-------- .../TransactionWithUsBankAccountTest.php | 8 ++++---- tests/integration/UsBankAccountTest.php | 6 +++--- tests/integration/VisaCheckoutCardTest.php | 2 +- tests/unit/AddressTest.php | 10 +++++----- tests/unit/ConfigurationTest.php | 6 ++---- tests/unit/CreditCardTest.php | 2 +- tests/unit/CustomerTest.php | 2 +- tests/unit/DisputeTest.php | 2 +- tests/unit/GatewayTest.php | 6 ++---- tests/unit/HttpHelpers/CurlTest.php | 3 +-- tests/unit/HttpTest.php | 14 ++++++-------- tests/unit/OAuthTest.php | 3 +-- tests/unit/PayPalAccountTest.php | 2 +- tests/unit/Result/SuccessfulTest.php | 2 +- tests/unit/SanityTest.php | 2 +- tests/unit/TransactionTest.php | 2 +- tests/unit/UtilTest.php | 2 +- tests/unit/WebhookNotificationTest.php | 3 +-- tests/unit/Xml_ParserTest.php | 2 +- 35 files changed, 88 insertions(+), 100 deletions(-) diff --git a/.gitignore b/.gitignore index 97994792..f7838bcf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,8 @@ /vendor /docs /tags +*.tgz +.phpunit.result.cache composer.lock composer.phar -*.tgz tests/fixtures/large_file.png diff --git a/Dockerfile b/Dockerfile index fa1fbb2a..d1dcbc72 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,10 +6,10 @@ RUN apt-get -y install gnupg curl wget # For installing php7 RUN apt -y install lsb-release apt-transport-https ca-certificates RUN wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg -RUN echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php7.2.list +RUN echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php7.3.list RUN apt-get update -RUN apt-get -y install rake php7.2 php7.2-cli php7.2-curl php-pear phpunit php7.2-xml php7.2-mbstring -RUN update-alternatives --set php /usr/bin/php7.2 +RUN apt-get -y install rake php7.3 php7.3-cli php7.3-curl php-pear php7.3-xml php7.3-mbstring +RUN update-alternatives --set php /usr/bin/php7.3 WORKDIR /braintree-php diff --git a/Rakefile b/Rakefile index 760b08b7..443b469f 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,5 @@ +do_not_cache = "--do-not-cache-result" + task :default => :test task :test => %w[test:unit test:integration] @@ -14,11 +16,11 @@ namespace :test do desc "run unit tests" task :unit, [:file_name, :test_name] => :version do |task, args| if args.file_name.nil? - sh "php ./vendor/bin/phpunit --testsuite unit" + sh "php ./vendor/bin/phpunit --testsuite unit #{do_not_cache}" elsif args.test_name.nil? - sh "./vendor/bin/phpunit tests/unit/#{args.file_name}" + sh "./vendor/bin/phpunit #{do_not_cache} tests/unit/#{args.file_name}" else - sh "./vendor/bin/phpunit tests/unit/#{args.file_name} --filter #{args.test_name}" + sh "./vendor/bin/phpunit #{do_not_cache} tests/unit/#{args.file_name} --filter #{args.test_name}" end end @@ -29,11 +31,11 @@ namespace :test do desc "run integration tests" task :integration, [:file_name, :test_name] do |task, args| if args.file_name.nil? - sh "php ./vendor/bin/phpunit --testsuite integration" + sh "php ./vendor/bin/phpunit --testsuite integration #{do_not_cache}" elsif args.test_name.nil? - sh "./vendor/bin/phpunit tests/integration/#{args.file_name}" + sh "./vendor/bin/phpunit #{do_not_cache} tests/integration/#{args.file_name}" else - sh "./vendor/bin/phpunit tests/integration/#{args.file_name} --filter #{args.test_name}" + sh "./vendor/bin/phpunit #{do_not_cache} tests/integration/#{args.file_name} --filter #{args.test_name}" end end diff --git a/composer.json b/composer.json index a3484fcb..cc7802ed 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "ext-xmlwriter": "*" }, "require-dev": { - "phpunit/phpunit": "^7.5" + "phpunit/phpunit": ">=9.0" }, "autoload": { "psr-4": { diff --git a/tests/Setup.php b/tests/Setup.php index b9840d91..87347bf7 100644 --- a/tests/Setup.php +++ b/tests/Setup.php @@ -15,8 +15,7 @@ class Setup extends TestCase { - public function setUp() - { + public function setUp(): void { parent::setUp(); self::integrationMerchantConfig(); diff --git a/tests/integration/ApplePayTest.php b/tests/integration/ApplePayTest.php index d56c0524..780cbba4 100644 --- a/tests/integration/ApplePayTest.php +++ b/tests/integration/ApplePayTest.php @@ -11,13 +11,11 @@ class ApplePayTest extends Setup { private static $gateway; - public static function setUpBeforeClass() - { + public static function setUpBeforeClass(): void { self::$gateway = self::_buildMerchantGateway(); } - public static function tearDownAfterClass() - { + public static function tearDownAfterClass(): void { self::$gateway = null; } diff --git a/tests/integration/CustomerTest.php b/tests/integration/CustomerTest.php index 8735bd90..8a76c2c5 100644 --- a/tests/integration/CustomerTest.php +++ b/tests/integration/CustomerTest.php @@ -411,7 +411,7 @@ public function testCreateCustomerWithUsBankAccount() $this->assertEquals('021000021', $usBankAccount->routingNumber); $this->assertEquals('1234', $usBankAccount->last4); $this->assertEquals('checking', $usBankAccount->accountType); - $this->assertRegexp('/CHASE/', $usBankAccount->bankName); + $this->assertMatchesRegularExpression('/CHASE/', $usBankAccount->bankName); } public function testCreate_withUnicode() @@ -1052,7 +1052,7 @@ public function test_findUsBankAccountGivenPaymentMethodToken() $this->assertEquals('021000021', $usBankAccount->routingNumber); $this->assertEquals('1234', $usBankAccount->last4); $this->assertEquals('checking', $usBankAccount->accountType); - $this->assertRegexp('/CHASE/', $usBankAccount->bankName); + $this->assertMatchesRegularExpression('/CHASE/', $usBankAccount->bankName); } public function testFind_throwsExceptionIfNotFound() diff --git a/tests/integration/DisputeTest.php b/tests/integration/DisputeTest.php index d109f105..1f1441cc 100644 --- a/tests/integration/DisputeTest.php +++ b/tests/integration/DisputeTest.php @@ -10,7 +10,7 @@ class DisputeTest extends Setup { private $gateway; - public function setUp() { + public function setUp():void { parent::setUp(); $this->gateway = new Braintree\Gateway([ @@ -138,7 +138,7 @@ public function testAddTextEvidence_addsTextEvidence() $this->assertTrue($result->success); $this->assertEquals("text evidence", $evidence->comment); $this->assertNotNull($evidence->createdAt); - $this->assertRegExp('/^\w{16,}$/', $evidence->id); + $this->assertMatchesRegularExpression('/^\w{16,}$/', $evidence->id); $this->assertNull($evidence->sentToProcessorAt); $this->assertNull($evidence->url); $this->assertNull($evidence->tag); @@ -161,7 +161,7 @@ public function testAddTaggedTextEvidence_addsTextEvidence() $this->assertTrue($result->success); $this->assertEquals("UPS", $evidence->comment); $this->assertNotNull($evidence->createdAt); - $this->assertRegExp('/^\w{16,}$/', $evidence->id); + $this->assertMatchesRegularExpression('/^\w{16,}$/', $evidence->id); $this->assertNull($evidence->sentToProcessorAt); $this->assertNull($evidence->url); $this->assertEquals("CARRIER_NAME", $evidence->category); diff --git a/tests/integration/DocumentUploadTest.php b/tests/integration/DocumentUploadTest.php index bd0e036c..7a29c22e 100644 --- a/tests/integration/DocumentUploadTest.php +++ b/tests/integration/DocumentUploadTest.php @@ -11,7 +11,7 @@ class DocumentUploadTest extends Setup private $gateway; private $pngFile; - public function setUp() { + public function setUp(): void { parent::setUp(); $this->gateway = new Braintree\Gateway([ diff --git a/tests/integration/HttpTest.php b/tests/integration/HttpTest.php index 337fe513..f5aef943 100644 --- a/tests/integration/HttpTest.php +++ b/tests/integration/HttpTest.php @@ -8,7 +8,7 @@ class HttpTest extends Setup { - public function setUp(){ + public function setUp(): void{ parent::setUp(); Braintree\Configuration::environment('development'); @@ -65,13 +65,11 @@ public function testSandboxSSLFailsWithIncompatibleSSLVersion() public function testSslError() { - try { - Braintree\Configuration::environment('sandbox'); - $http = new Braintree\Http(Braintree\Configuration::$global); - $http->_doUrlRequest('get', '/malformed_url'); - } catch (Braintree\Exception\Connection $e) { - $this->assertEquals(" malformed", $e->getMessage()); - } + $this->expectException('Braintree\Exception\Connection', null, 35); + + Braintree\Configuration::environment('sandbox'); + $http = new Braintree\Http(Braintree\Configuration::$global); + $http->_doUrlRequest('get', '/malformed_url'); } public function testAcceptGzipEncodingSetFalse() diff --git a/tests/integration/MasterpassCardTest.php b/tests/integration/MasterpassCardTest.php index 8af37ecf..e3fc4fa0 100644 --- a/tests/integration/MasterpassCardTest.php +++ b/tests/integration/MasterpassCardTest.php @@ -22,7 +22,7 @@ public function testCreateWithMasterpassCardNonce() $masterpassCard = $result->paymentMethod; $this->assertSame(Braintree\CreditCard::DISCOVER, $masterpassCard->cardType); $this->assertTrue($masterpassCard->default); - $this->assertContains('discover', $masterpassCard->imageUrl); + $this->assertStringContainsString('discover', $masterpassCard->imageUrl); $this->assertTrue(intval($masterpassCard->expirationMonth) > 0); $this->assertTrue(intval($masterpassCard->expirationYear) > 0); $this->assertSame($customer->id, $masterpassCard->customerId); diff --git a/tests/integration/PaymentMethodTest.php b/tests/integration/PaymentMethodTest.php index e74138e7..b00e63ef 100644 --- a/tests/integration/PaymentMethodTest.php +++ b/tests/integration/PaymentMethodTest.php @@ -160,10 +160,10 @@ public function testCreate_fromFakeApplePayNonce() $this->assertNotNull($applePayCard->token); $this->assertNotNull($applePayCard->bin); $this->assertSame(Braintree\ApplePayCard::VISA, $applePayCard->cardType); - $this->assertContains("Visa ", $applePayCard->paymentInstrumentName); - $this->assertContains("Visa ", $applePayCard->sourceDescription); + $this->assertStringContainsString("Visa ", $applePayCard->paymentInstrumentName); + $this->assertStringContainsString("Visa ", $applePayCard->sourceDescription); $this->assertTrue($applePayCard->default); - $this->assertContains('apple_pay', $applePayCard->imageUrl); + $this->assertStringContainsString('apple_pay', $applePayCard->imageUrl); $this->assertTrue(intval($applePayCard->expirationMonth) > 0); $this->assertTrue(intval($applePayCard->expirationYear) > 0); $this->assertSame($customer->id, $applePayCard->customerId); @@ -188,7 +188,7 @@ public function testCreate_fromFakeAndroidPayProxyCardNonce() $this->assertSame("1111", $androidPayCard->sourceCardLast4); $this->assertSame("Discover 1111", $androidPayCard->sourceDescription); $this->assertTrue($androidPayCard->default); - $this->assertContains('android_pay', $androidPayCard->imageUrl); + $this->assertStringContainsString('android_pay', $androidPayCard->imageUrl); $this->assertTrue(intval($androidPayCard->expirationMonth) > 0); $this->assertTrue(intval($androidPayCard->expirationYear) > 0); $this->assertSame($customer->id, $androidPayCard->customerId); @@ -214,7 +214,7 @@ public function testCreate_fromFakeAndroidPayNetworkTokenNonce() $this->assertSame("4444", $androidPayCard->sourceCardLast4); $this->assertSame("MasterCard 4444", $androidPayCard->sourceDescription); $this->assertTrue($androidPayCard->default); - $this->assertContains('android_pay', $androidPayCard->imageUrl); + $this->assertStringContainsString('android_pay', $androidPayCard->imageUrl); $this->assertTrue(intval($androidPayCard->expirationMonth) > 0); $this->assertTrue(intval($androidPayCard->expirationYear) > 0); $this->assertSame($customer->id, $androidPayCard->customerId); @@ -240,7 +240,7 @@ public function testCreate_fromFakeAmexExpressCheckoutCardNonce() $this->assertSame("0005", $amexExpressCheckoutCard->cardMemberNumber); $this->assertSame("American Express", $amexExpressCheckoutCard->cardType); $this->assertNotNull($amexExpressCheckoutCard->sourceDescription); - $this->assertContains(".png", $amexExpressCheckoutCard->imageUrl); + $this->assertStringContainsString(".png", $amexExpressCheckoutCard->imageUrl); $this->assertTrue(intval($amexExpressCheckoutCard->expirationMonth) > 0); $this->assertTrue(intval($amexExpressCheckoutCard->expirationYear) > 0); $this->assertTrue($amexExpressCheckoutCard->default); @@ -262,7 +262,7 @@ public function testCreate_fromFakeVenmoAccountNonce() $this->assertNotNull($venmoAccount->token); $this->assertNotNull($venmoAccount->sourceDescription); - $this->assertContains(".png", $venmoAccount->imageUrl); + $this->assertStringContainsString(".png", $venmoAccount->imageUrl); $this->assertTrue($venmoAccount->default); $this->assertSame($customer->id, $venmoAccount->customerId); $this->assertEquals(array(), $venmoAccount->subscriptions); @@ -1223,7 +1223,7 @@ public function testFind_returnsAndroidPayCards() $this->assertSame("1111", $foundAndroidPayCard->sourceCardLast4); $this->assertSame($customer->id, $foundAndroidPayCard->customerId); $this->assertTrue($foundAndroidPayCard->default); - $this->assertContains('android_pay', $foundAndroidPayCard->imageUrl); + $this->assertStringContainsString('android_pay', $foundAndroidPayCard->imageUrl); $this->assertTrue(intval($foundAndroidPayCard->expirationMonth) > 0); $this->assertTrue(intval($foundAndroidPayCard->expirationYear) > 0); $this->assertFalse($foundAndroidPayCard->isNetworkTokenized); diff --git a/tests/integration/PaymentMethodWithUsBankAccountTest.php b/tests/integration/PaymentMethodWithUsBankAccountTest.php index e11e6d28..5f37bbd4 100644 --- a/tests/integration/PaymentMethodWithUsBankAccountTest.php +++ b/tests/integration/PaymentMethodWithUsBankAccountTest.php @@ -25,7 +25,7 @@ public function testCreate_fromUsBankAccountNonce() $this->assertEquals('1234', $usBankAccount->last4); $this->assertEquals('checking', $usBankAccount->accountType); $this->assertEquals('Dan Schulman', $usBankAccount->accountHolderName); - $this->assertRegexp('/CHASE/', $usBankAccount->bankName); + $this->assertMatchesRegularExpression('/CHASE/', $usBankAccount->bankName); $this->assertEquals(true, $usBankAccount->verified); $this->assertEquals(1, count($usBankAccount->verifications)); @@ -53,7 +53,7 @@ public function testCreate_fromUsBankAccountNonceWithVerification() $this->assertEquals('0000', $usBankAccount->last4); $this->assertEquals('checking', $usBankAccount->accountType); $this->assertEquals('Dan Schulman', $usBankAccount->accountHolderName); - $this->assertRegexp('/CHASE/', $usBankAccount->bankName); + $this->assertMatchesRegularExpression('/CHASE/', $usBankAccount->bankName); $this->assertEquals(true, $usBankAccount->verified); $this->assertEquals(1, count($usBankAccount->verifications)); @@ -81,7 +81,7 @@ public function testCreate_fromPlaidUsBankAccountNonce() $this->assertEquals('0000', $usBankAccount->last4); $this->assertEquals('checking', $usBankAccount->accountType); $this->assertEquals('Dan Schulman', $usBankAccount->accountHolderName); - $this->assertRegexp('/FEDERAL/', $usBankAccount->bankName); + $this->assertMatchesRegularExpression('/FEDERAL/', $usBankAccount->bankName); $this->assertEquals(true, $usBankAccount->verified); $this->assertEquals(1, count($usBankAccount->verifications)); @@ -109,7 +109,7 @@ public function testFind_returnsUsBankAccount() $this->assertEquals('1234', $foundUsBankAccount->last4); $this->assertEquals('checking', $foundUsBankAccount->accountType); $this->assertEquals('Dan Schulman', $foundUsBankAccount->accountHolderName); - $this->assertRegExp('/CHASE/', $foundUsBankAccount->bankName); + $this->assertMatchesRegularExpression('/CHASE/', $foundUsBankAccount->bankName); } public function testCompliantCreate_fromUsBankAccountNonce() @@ -134,7 +134,7 @@ public function testCompliantCreate_fromUsBankAccountNonce() $this->assertEquals('1234', $usBankAccount->last4); $this->assertEquals('checking', $usBankAccount->accountType); $this->assertEquals('Dan Schulman', $usBankAccount->accountHolderName); - $this->assertRegexp('/CHASE/', $usBankAccount->bankName); + $this->assertMatchesRegularExpression('/CHASE/', $usBankAccount->bankName); $this->assertEquals(false, $usBankAccount->verified); $this->assertEquals(0, count($usBankAccount->verifications)); diff --git a/tests/integration/SamsungPayCardTest.php b/tests/integration/SamsungPayCardTest.php index 885bfa18..635faeb4 100644 --- a/tests/integration/SamsungPayCardTest.php +++ b/tests/integration/SamsungPayCardTest.php @@ -38,7 +38,7 @@ public function testCreateWithSamsungPayCardNonce() $this->assertNotNull($samsungPayCard->token); $this->assertSame(Braintree\CreditCard::DISCOVER, $samsungPayCard->cardType); $this->assertTrue($samsungPayCard->default); - $this->assertContains('discover', $samsungPayCard->imageUrl); + $this->assertStringContainsString('discover', $samsungPayCard->imageUrl); $this->assertTrue(intval($samsungPayCard->expirationMonth) > 0); $this->assertTrue(intval($samsungPayCard->expirationYear) > 0); $this->assertSame($customer->id, $samsungPayCard->customerId); diff --git a/tests/integration/TestTransactionTest.php b/tests/integration/TestTransactionTest.php index 9aa305fc..60ed890a 100644 --- a/tests/integration/TestTransactionTest.php +++ b/tests/integration/TestTransactionTest.php @@ -10,8 +10,7 @@ class TestTransactionTest extends Setup { - public function setUp() - { + public function setUp(): void { parent::setUp(); Braintree\Configuration::environment('development'); diff --git a/tests/integration/TransactionTest.php b/tests/integration/TransactionTest.php index 6219cb05..02015efb 100644 --- a/tests/integration/TransactionTest.php +++ b/tests/integration/TransactionTest.php @@ -1726,11 +1726,11 @@ public function testCreateTransactionUsingFakeApplePayNonce() $this->assertEquals('47.00', $transaction->amount); $applePayDetails = $transaction->applePayCardDetails; $this->assertSame(Braintree\ApplePayCard::AMEX, $applePayDetails->cardType); - $this->assertContains("AmEx ", $applePayDetails->sourceDescription); - $this->assertContains("AmEx ", $applePayDetails->paymentInstrumentName); + $this->assertStringContainsString("AmEx ", $applePayDetails->sourceDescription); + $this->assertStringContainsString("AmEx ", $applePayDetails->paymentInstrumentName); $this->assertTrue(intval($applePayDetails->expirationMonth) > 0); $this->assertTrue(intval($applePayDetails->expirationYear) > 0); - $this->assertContains('apple_pay', $applePayDetails->imageUrl); + $this->assertStringContainsString('apple_pay', $applePayDetails->imageUrl); $this->assertNotNull($applePayDetails->cardholderName); $this->assertNotNull($applePayDetails->bin); $this->assertNotNull($applePayDetails->commercial); @@ -1788,7 +1788,7 @@ public function testCreateTransactionUsingRawGooglePayParams() $this->assertSame(Braintree\CreditCard::VISA, $androidPayCardDetails->sourceCardType); $this->assertSame("1881", $androidPayCardDetails->sourceCardLast4); $this->assertSame("Visa 1881", $androidPayCardDetails->sourceDescription); - $this->assertContains('android_pay', $androidPayCardDetails->imageUrl); + $this->assertStringContainsString('android_pay', $androidPayCardDetails->imageUrl); $this->assertSame("10", $androidPayCardDetails->expirationMonth); $this->assertSame("17", $androidPayCardDetails->expirationYear); $this->assertNotNull($androidPayCardDetails->bin); @@ -1821,7 +1821,7 @@ public function testCreateTransactionUsingFakeAndroidPayProxyCardNonce() $this->assertSame(Braintree\CreditCard::DISCOVER, $androidPayCardDetails->sourceCardType); $this->assertSame("1111", $androidPayCardDetails->sourceCardLast4); $this->assertSame("Discover 1111", $androidPayCardDetails->sourceDescription); - $this->assertContains('android_pay', $androidPayCardDetails->imageUrl); + $this->assertStringContainsString('android_pay', $androidPayCardDetails->imageUrl); $this->assertTrue(intval($androidPayCardDetails->expirationMonth) > 0); $this->assertTrue(intval($androidPayCardDetails->expirationYear) > 0); $this->assertNotNull($androidPayCardDetails->bin); @@ -1854,7 +1854,7 @@ public function testCreateTransactionUsingFakeAndroidPayNetworkTokenNonce() $this->assertSame(Braintree\CreditCard::MASTER_CARD, $androidPayCardDetails->sourceCardType); $this->assertSame("4444", $androidPayCardDetails->sourceCardLast4); $this->assertSame("MasterCard 4444", $androidPayCardDetails->sourceDescription); - $this->assertContains('android_pay', $androidPayCardDetails->imageUrl); + $this->assertStringContainsString('android_pay', $androidPayCardDetails->imageUrl); $this->assertTrue(intval($androidPayCardDetails->expirationMonth) > 0); $this->assertTrue(intval($androidPayCardDetails->expirationYear) > 0); $this->assertNotNull($androidPayCardDetails->bin); @@ -1887,7 +1887,7 @@ public function testCreateTransactionUsingFakeAmexExpressCheckoutNonce() $this->assertSame("0005", $amexExpressCheckoutCardDetails->cardMemberNumber); $this->assertNull($amexExpressCheckoutCardDetails->token); $this->assertNotNull($amexExpressCheckoutCardDetails->sourceDescription); - $this->assertContains(".png", $amexExpressCheckoutCardDetails->imageUrl); + $this->assertStringContainsString(".png", $amexExpressCheckoutCardDetails->imageUrl); $this->assertTrue(intval($amexExpressCheckoutCardDetails->expirationMonth) > 0); $this->assertTrue(intval($amexExpressCheckoutCardDetails->expirationYear) > 0); } @@ -1924,7 +1924,7 @@ public function testCreateTransactionUsingFakeVenmoAccountNonce() $this->assertNull($venmoAccountDetails->token); $this->assertNotNull($venmoAccountDetails->sourceDescription); - $this->assertContains(".png", $venmoAccountDetails->imageUrl); + $this->assertStringContainsString(".png", $venmoAccountDetails->imageUrl); $this->assertSame("venmojoe", $venmoAccountDetails->username); $this->assertSame("Venmo-Joe-1", $venmoAccountDetails->venmoUserId); } diff --git a/tests/integration/TransactionWithUsBankAccountTest.php b/tests/integration/TransactionWithUsBankAccountTest.php index e90b24f1..48c9cfe2 100644 --- a/tests/integration/TransactionWithUsBankAccountTest.php +++ b/tests/integration/TransactionWithUsBankAccountTest.php @@ -31,7 +31,7 @@ public function testSaleWithUsBankAccountNonce() $this->assertEquals('1234', $transaction->usBankAccount->last4); $this->assertEquals('checking', $transaction->usBankAccount->accountType); $this->assertEquals('Dan Schulman', $transaction->usBankAccount->accountHolderName); - $this->assertRegExp('/CHASE/', $transaction->usBankAccount->bankName); + $this->assertMatchesRegularExpression('/CHASE/', $transaction->usBankAccount->bankName); $this->assertEquals('cl mandate text', $transaction->usBankAccount->achMandate->text); $this->assertEquals('DateTime', get_class($transaction->usBankAccount->achMandate->acceptedAt)); } @@ -104,7 +104,7 @@ public function testSaleWithPlaidUsBankAccountNonce() $this->assertEquals('0000', $transaction->usBankAccount->last4); $this->assertEquals('checking', $transaction->usBankAccount->accountType); $this->assertEquals('Dan Schulman', $transaction->usBankAccount->accountHolderName); - $this->assertRegExp('/FEDERAL/', $transaction->usBankAccount->bankName); + $this->assertMatchesRegularExpression('/FEDERAL/', $transaction->usBankAccount->bankName); $this->assertEquals('cl mandate text', $transaction->usBankAccount->achMandate->text); $this->assertEquals('DateTime', get_class($transaction->usBankAccount->achMandate->acceptedAt)); } @@ -148,7 +148,7 @@ public function testCompliantMerchantUnverifiedToken() $this->assertEquals('1234', $usBankAccount->last4); $this->assertEquals('checking', $usBankAccount->accountType); $this->assertEquals('Dan Schulman', $usBankAccount->accountHolderName); - $this->assertRegexp('/CHASE/', $usBankAccount->bankName); + $this->assertMatchesRegularExpression('/CHASE/', $usBankAccount->bankName); $this->assertEquals(false, $usBankAccount->verified); $this->assertEquals(0, count($usBankAccount->verifications)); @@ -210,7 +210,7 @@ public function testCompliantMerchantPlaidToken() $this->assertEquals('0000', $usBankAccount->last4); $this->assertEquals('checking', $usBankAccount->accountType); $this->assertEquals('Dan Schulman', $usBankAccount->accountHolderName); - $this->assertRegexp('/FEDERAL/', $usBankAccount->bankName); + $this->assertMatchesRegularExpression('/FEDERAL/', $usBankAccount->bankName); $this->assertEquals(true, $usBankAccount->verified); $this->assertEquals(1, count($usBankAccount->verifications)); diff --git a/tests/integration/UsBankAccountTest.php b/tests/integration/UsBankAccountTest.php index aa0219a5..019d7d1a 100644 --- a/tests/integration/UsBankAccountTest.php +++ b/tests/integration/UsBankAccountTest.php @@ -31,7 +31,7 @@ public function testReturnUsBankAccount() $this->assertEquals('1234', $foundUsBankAccount->last4); $this->assertEquals('checking', $foundUsBankAccount->accountType); $this->assertEquals('Dan Schulman', $foundUsBankAccount->accountHolderName); - $this->assertRegExp('/CHASE/', $foundUsBankAccount->bankName); + $this->assertMatchesRegularExpression('/CHASE/', $foundUsBankAccount->bankName); $this->assertEquals('cl mandate text', $foundUsBankAccount->achMandate->text); $this->assertEquals('DateTime', get_class($foundUsBankAccount->achMandate->acceptedAt)); $this->assertEquals(true, $foundUsBankAccount->default); @@ -57,7 +57,7 @@ public function testFind() $this->assertEquals('1234', $foundUsBankAccount->last4); $this->assertEquals('checking', $foundUsBankAccount->accountType); $this->assertEquals('Dan Schulman', $foundUsBankAccount->accountHolderName); - $this->assertRegExp('/CHASE/', $foundUsBankAccount->bankName); + $this->assertMatchesRegularExpression('/CHASE/', $foundUsBankAccount->bankName); $this->assertEquals('cl mandate text', $foundUsBankAccount->achMandate->text); $this->assertEquals('DateTime', get_class($foundUsBankAccount->achMandate->acceptedAt)); $this->assertEquals(true, $foundUsBankAccount->default); @@ -97,7 +97,7 @@ public function testSale_createsASaleUsingGivenToken() $this->assertEquals('1234', $transaction->usBankAccount->last4); $this->assertEquals('checking', $transaction->usBankAccount->accountType); $this->assertEquals('Dan Schulman', $transaction->usBankAccount->accountHolderName); - $this->assertRegExp('/CHASE/', $transaction->usBankAccount->bankName); + $this->assertMatchesRegularExpression('/CHASE/', $transaction->usBankAccount->bankName); $this->assertEquals('cl mandate text', $transaction->usBankAccount->achMandate->text); $this->assertEquals('DateTime', get_class($transaction->usBankAccount->achMandate->acceptedAt)); } diff --git a/tests/integration/VisaCheckoutCardTest.php b/tests/integration/VisaCheckoutCardTest.php index a081cd62..6d92961a 100644 --- a/tests/integration/VisaCheckoutCardTest.php +++ b/tests/integration/VisaCheckoutCardTest.php @@ -23,7 +23,7 @@ public function testCreateWithVisaCheckoutCardNonce() $this->assertNotNull($visaCheckoutCard->token); $this->assertSame(Braintree\CreditCard::DISCOVER, $visaCheckoutCard->cardType); $this->assertTrue($visaCheckoutCard->default); - $this->assertContains('discover', $visaCheckoutCard->imageUrl); + $this->assertStringContainsString('discover', $visaCheckoutCard->imageUrl); $this->assertTrue(intval($visaCheckoutCard->expirationMonth) > 0); $this->assertTrue(intval($visaCheckoutCard->expirationYear) > 0); $this->assertSame($customer->id, $visaCheckoutCard->customerId); diff --git a/tests/unit/AddressTest.php b/tests/unit/AddressTest.php index 3f5f68d0..7d115d14 100644 --- a/tests/unit/AddressTest.php +++ b/tests/unit/AddressTest.php @@ -10,7 +10,7 @@ class AddressTest extends Setup { public function testGet_givesErrorIfInvalidProperty() { - $this->expectException('PHPUnit\Framework\Error\Error', 'Undefined property on Braintree\Address: foo'); + $this->expectError(); $a = Braintree\Address::factory([]); @@ -57,25 +57,25 @@ public function testCustomerIdNotEqual() public function testFindErrorsOnBlankCustomerId() { - $this->expectException('InvalidArgumentException'); + $this->expectErrorMessage('expected customer id to be set'); Braintree\Address::find('', '123'); } public function testFindErrorsOnBlankAddressId() { - $this->expectException('InvalidArgumentException'); + $this->expectErrorMessage('expected address id to be set'); Braintree\Address::find('123', ''); } public function testFindErrorsOnWhitespaceOnlyId() { - $this->expectException('InvalidArgumentException'); + $this->expectErrorMessage('expected address id to be set'); Braintree\Address::find('123', ' '); } public function testFindErrorsOnWhitespaceOnlyCustomerId() { - $this->expectException('InvalidArgumentException'); + $this->expectErrorMessage('expected customer id to be set'); Braintree\Address::find(' ', '123'); } } diff --git a/tests/unit/ConfigurationTest.php b/tests/unit/ConfigurationTest.php index 7bcc403a..fec2fdb9 100644 --- a/tests/unit/ConfigurationTest.php +++ b/tests/unit/ConfigurationTest.php @@ -8,14 +8,12 @@ class ConfigurationTest extends Setup { - public function setUp() - { + public function setUp(): void { Braintree\Configuration::reset(); $this->config = new Braintree\Configuration(); } - public function teardown() - { + public function teardown(): void { Braintree\Configuration::environment('development'); Braintree\Configuration::merchantId('integration_merchant_id'); Braintree\Configuration::publicKey('integration_public_key'); diff --git a/tests/unit/CreditCardTest.php b/tests/unit/CreditCardTest.php index ad8cf31f..db33cc17 100644 --- a/tests/unit/CreditCardTest.php +++ b/tests/unit/CreditCardTest.php @@ -11,7 +11,7 @@ class CreditCardTest extends Setup { public function testGet_givesErrorIfInvalidProperty() { - $this->expectException('PHPUnit\Framework\Error\Error', 'Undefined property on Braintree\CreditCard: foo'); + $this->expectError(); $cc = Braintree\CreditCard::factory([]); $cc->foo; } diff --git a/tests/unit/CustomerTest.php b/tests/unit/CustomerTest.php index 5a24a02f..0066828d 100644 --- a/tests/unit/CustomerTest.php +++ b/tests/unit/CustomerTest.php @@ -10,7 +10,7 @@ class CustomerTest extends Setup { public function testGet_givesErrorIfInvalidProperty() { - $this->expectException('PHPUnit\Framework\Error\Error', 'Undefined property on Braintree\Customer: foo'); + $this->expectError(); $c = Braintree\Customer::factory([]); $c->foo; } diff --git a/tests/unit/DisputeTest.php b/tests/unit/DisputeTest.php index 80dbc83f..4e4622b8 100644 --- a/tests/unit/DisputeTest.php +++ b/tests/unit/DisputeTest.php @@ -11,7 +11,7 @@ class DisputeTest extends Setup { private $attributes; - public function setUp() { + public function setUp(): void { parent::setUp(); $this->attributes = [ diff --git a/tests/unit/GatewayTest.php b/tests/unit/GatewayTest.php index 01e31777..9fd7df59 100644 --- a/tests/unit/GatewayTest.php +++ b/tests/unit/GatewayTest.php @@ -8,13 +8,11 @@ class GatewayTest extends Setup { - public function setUp() - { + public function setUp(): void { Braintree\Configuration::reset(); } - public function teardown() - { + public function teardown(): void { Braintree\Configuration::environment('development'); Braintree\Configuration::merchantId('integration_merchant_id'); Braintree\Configuration::publicKey('integration_public_key'); diff --git a/tests/unit/HttpHelpers/CurlTest.php b/tests/unit/HttpHelpers/CurlTest.php index 699daaf0..0fef1895 100644 --- a/tests/unit/HttpHelpers/CurlTest.php +++ b/tests/unit/HttpHelpers/CurlTest.php @@ -14,8 +14,7 @@ class CurlTest extends Setup private $_config; private $_mockHttpRequest; - public function setUp() - { + public function setUp(): void { $this->_config = new Braintree\Configuration(); $this->_mockHttpRequest = new MockHttpRequest(); } diff --git a/tests/unit/HttpTest.php b/tests/unit/HttpTest.php index 30bd1570..902aa2df 100644 --- a/tests/unit/HttpTest.php +++ b/tests/unit/HttpTest.php @@ -8,7 +8,7 @@ class HttpTest extends Setup { - public function setUp(){ + public function setUp(): void { parent::setUp(); Braintree\Configuration::environment('development'); Braintree\Configuration::sslVersion(null); @@ -27,13 +27,11 @@ public function testMalformedNoSsl() public function testMalformedUrlUsingSsl() { - try { - Braintree\Configuration::environment('sandbox'); - $http = new Braintree\Http(Braintree\Configuration::$global); - $http->_doUrlRequest('get', '/a_malformed_url_using_ssl'); - } catch (Braintree\Exception\Connection $e) { - $this->assertEquals(" malformed", $e->getMessage()); - } + $this->ExpectException('Braintree\Exception\Connection', null, 3); + + Braintree\Configuration::environment('sandbox'); + $http = new Braintree\Http(Braintree\Configuration::$global); + $http->_doUrlRequest('get', '/a_malformed_url_using_ssl'); } public function testOlderSSLVersionsError() diff --git a/tests/unit/OAuthTest.php b/tests/unit/OAuthTest.php index d7b6e8df..2a5ed6ce 100644 --- a/tests/unit/OAuthTest.php +++ b/tests/unit/OAuthTest.php @@ -10,8 +10,7 @@ class OAuthTest extends Setup { protected $gateway; - public function setUp() - { + public function setUp(): void { $this->gateway = new Braintree\Gateway([ 'clientId' => 'client_id$development$integration_client_id', 'clientSecret' => 'client_secret$development$integration_client_secret' diff --git a/tests/unit/PayPalAccountTest.php b/tests/unit/PayPalAccountTest.php index cbc5357d..49c24d09 100644 --- a/tests/unit/PayPalAccountTest.php +++ b/tests/unit/PayPalAccountTest.php @@ -10,7 +10,7 @@ class PayPalAccountTest extends Setup { public function testGet_givesErrorIfInvalidProperty() { - $this->expectException('PHPUnit\Framework\Error\Error', 'Undefined property on Braintree\PayPalAccount: foo'); + $this->expectError(); $paypalAccount = Braintree\PayPalAccount::factory([]); $paypalAccount->foo; } diff --git a/tests/unit/Result/SuccessfulTest.php b/tests/unit/Result/SuccessfulTest.php index a991ccdb..2caf5b2e 100644 --- a/tests/unit/Result/SuccessfulTest.php +++ b/tests/unit/Result/SuccessfulTest.php @@ -10,7 +10,7 @@ class SuccessfulTest extends Setup { public function testCallingNonExsitingFieldReturnsNull() { - $this->expectException('PHPUnit\Framework\Error\Notice'); + $this->expectError(); $this->expectExceptionMessage('Undefined property on Braintree\Result\Successful: notAProperty'); $result = new Braintree\Result\Successful(1, 'transaction'); diff --git a/tests/unit/SanityTest.php b/tests/unit/SanityTest.php index 686755a6..f14cafa8 100644 --- a/tests/unit/SanityTest.php +++ b/tests/unit/SanityTest.php @@ -13,7 +13,7 @@ public function testCodeFiles_allOmitPHPCloseTag() foreach ($codeFiles as $codeFile) { if ($codeFile == "") continue; $code = file_get_contents($codeFile); - $this->assertNotContains("?>", $code, "$codeFile should not contain a PHP close tag"); + $this->assertStringNotContainsString("?>", $code, "$codeFile should not contain a PHP close tag"); } } } diff --git a/tests/unit/TransactionTest.php b/tests/unit/TransactionTest.php index 34602bf5..125d5c46 100644 --- a/tests/unit/TransactionTest.php +++ b/tests/unit/TransactionTest.php @@ -19,7 +19,7 @@ public function testGet_givesErrorIfInvalidProperty() 'subscription' => ['billingPeriodStartDate' => '1983-07-12'], 'statusHistory' => [] ]); - $this->expectException('PHPUnit\Framework\Error\Error', 'Undefined property on Braintree\Transaction: foo'); + $this->expectError(); $t->foo; } diff --git a/tests/unit/UtilTest.php b/tests/unit/UtilTest.php index bc78f945..4cf7bf08 100644 --- a/tests/unit/UtilTest.php +++ b/tests/unit/UtilTest.php @@ -447,6 +447,6 @@ public function testReturnObject() $this->success = true; $this->transaction = new stdClass(); $t = Braintree\Util::returnObjectOrThrowException('Braintree\Transaction', $this); - $this->assertInternalType('object', $t); + $this->assertIsObject($t); } } diff --git a/tests/unit/WebhookNotificationTest.php b/tests/unit/WebhookNotificationTest.php index f5d496cd..cac5163a 100644 --- a/tests/unit/WebhookNotificationTest.php +++ b/tests/unit/WebhookNotificationTest.php @@ -10,8 +10,7 @@ class WebhookNotificationTest extends Setup { - public function setUp() - { + public function setUp(): void { self::integrationMerchantConfig(); } diff --git a/tests/unit/Xml_ParserTest.php b/tests/unit/Xml_ParserTest.php index eb109995..f3e93385 100644 --- a/tests/unit/Xml_ParserTest.php +++ b/tests/unit/Xml_ParserTest.php @@ -529,7 +529,7 @@ public function testIncludesTheEncodingRoundtrip() 'root' => 'bar', ]]; $xml = Braintree\Xml::buildXmlFromArray($array); - $this->assertRegExp('<\?xml version=\"1.0\" encoding=\"UTF-8\"\?>', $xml); + $this->assertMatchesRegularExpression('<\?xml version=\"1.0\" encoding=\"UTF-8\"\?>', $xml); }