This repository has been archived by the owner on Sep 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Jenkins pipeline for sonar coverage
- Add Phpunit - Add test
- Loading branch information
1 parent
4aa56dd
commit ce81d07
Showing
8 changed files
with
111,376 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
pipeline { | ||
agent any | ||
|
||
stages { | ||
stage('Install Dependencies') { | ||
steps { | ||
// Install Composer dependencies | ||
echo 'Install dependencies...' | ||
echo 'PAth : ${WORKSPACE}' | ||
sh '/usr/bin/php ${WORKSPACE}/composer.phar install' | ||
} | ||
} | ||
stage('Run Tests') { | ||
steps { | ||
echo 'Run tests with phpunit...' | ||
sh 'vendor/bin/phpunit' | ||
xunit([ | ||
thresholds: [ | ||
failed ( failureThreshold: "0" ), | ||
skipped ( unstableThreshold: "0" ) | ||
], | ||
tools: [ | ||
PHPUnit(pattern: 'build/logs/junit.xml', stopProcessingIfError: true, failIfNotNew: true) | ||
] | ||
]) | ||
publishHTML([ | ||
allowMissing: false, | ||
alwaysLinkToLastBuild: false, | ||
keepAll: false, | ||
reportDir: 'build/coverage', | ||
reportFiles: 'index.html', | ||
reportName: 'Coverage Report (HTML)', | ||
reportTitles: '' | ||
]) | ||
publishCoverage adapters: [coberturaAdapter('build/logs/cobertura.xml')] | ||
} | ||
} | ||
stage('SonarQube analysis') { | ||
steps { | ||
echo 'Check Quality with Sonarqube' | ||
withSonarQubeEnv('SonarMonext') { | ||
sh 'mvn org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar' | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,9 @@ | |
"monolog/monolog": "1.* || ~2.0 || ~3.0", | ||
"symfony/cache": ">=3.4" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "10.4.2" | ||
}, | ||
"support": { | ||
"email": "[email protected]", | ||
"docs": "http://support.payline.com" | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
<?php | ||
|
||
namespace test\Payline; | ||
use Monolog\Logger; | ||
use Payline\PaylineSDK; | ||
use PHPUnit\Framework\TestCase; | ||
use SoapClient; | ||
|
||
class PaylineSDKTest extends TestCase | ||
{ | ||
// Given | ||
const merchant_id = '1111111'; | ||
const access_key = 'xxxyyy222'; | ||
const environment = PaylineSDK::ENV_HOMO; | ||
const logLvl = Logger::API; | ||
|
||
public $soapClientMock = null; | ||
|
||
public function testNewPaylineSDKInstance() | ||
{ | ||
// Test - Try to create an instance | ||
$paylineSDK = new PaylineSDK(self::merchant_id, self::access_key, null, null, null, null, | ||
self::environment, $pathLog= null, self::logLvl); | ||
|
||
// Then | ||
$this->assertNotNull($paylineSDK); | ||
} | ||
// | ||
// public function testCallDoAuthorization() | ||
// { | ||
// // Given | ||
// // Create instance | ||
// $paylineSDK = new PaylineSDK(self::merchant_id, self::access_key, null, null, null, null, | ||
// self::environment, $pathLog= null, self::logLvl); | ||
// // Create Call | ||
// | ||
// // Mock SOAP API | ||
//// $soapClientMock = $this->createMock(SoapClient::class); | ||
//// $soapClientMock = $this->getMockBuilder('\pClient'); | ||
//// $soapClientMock = $this->getMockFromWsdl(__DIR__ . '\wsdl\DirectPaymentAPI.wsdl') | ||
//// ->method('__soapCall') | ||
//// ->willReturn($reponseMock); | ||
//// $soapClientMock | ||
//// ->method('__soapCall') | ||
//// ->willReturn(''); | ||
// | ||
// $reponseMock = array(); | ||
// $reponseMock['result']['code'] = '00000'; | ||
// | ||
//// $soapClientMock = $this->getMockBuilder('\SoapClient') | ||
//// ->disableOriginalConstructor() | ||
//// ->getMock(); | ||
// | ||
// | ||
//// $soapClientMock = $this | ||
//// ->getMockBuilder(\SoapClient::class) | ||
//// ->disableOriginalConstructor() | ||
////// ->setMethods(['__soapCall']) | ||
//// ->getMock(); | ||
// | ||
//// $soapClientMock = $this->getMockBuilder('SoapClient') | ||
//// ->disableOriginalConstructor() | ||
//// ->getMock(); | ||
// $soapClientMock = $this->getMockFromWsdl(__DIR__ . '\wsdl\DirectPaymentAPI.wsdl') | ||
// ->method('__soapCall') | ||
// ->willReturn($reponseMock); | ||
// | ||
//// $options = array(); | ||
//// $options['uri'] = 'http://google.com'; | ||
//// | ||
//// $sdkWsdl = __DIR__ . '\wsdl\DirectPaymentAPI.wsdl'; | ||
//// $sdkClient = new SoapClient($sdkWsdl, $options); | ||
// | ||
//// $soapClientMock->expects($this->once()) | ||
//// ->method('__soapCall') | ||
////// ->with([ 'countryCode' => /*Put the value you want here*/, 'vatNumber' => /*Put the value you want here*/ ]) | ||
//// ->willReturn($reponseMock); | ||
//// | ||
//// $soapClientMock->expects($this->once()) | ||
//// ->method('__call') | ||
////// ->with([ 'countryCode' => /*Put the value you want here*/, 'vatNumber' => /*Put the value you want here*/ ]) | ||
//// ->willReturn($reponseMock); | ||
// | ||
// | ||
// // Test - Call doAuthorization | ||
// $doAuthorizationRequest = array(); | ||
// | ||
// $doAuthorizationRequest['cancelURL'] = 'https://Demo_Shop.com/cancelURL.php'; | ||
// $doAuthorizationRequest['returnURL'] = 'https://Demo_Shop.com/returnURL.php'; | ||
// $doAuthorizationRequest['notificationURL'] = 'https://Demo_Shop.com/notificationURL.php'; | ||
// // PAYMENT | ||
// $doAuthorizationRequest['payment']['amount'] = 1000; // this value has to be an integer amount is sent in cents | ||
// $doAuthorizationRequest['payment']['currency'] = 978; // ISO 4217 code for euro | ||
// $doAuthorizationRequest['payment']['action'] = 100; // 101 stand for "authorization+capture" | ||
// $doAuthorizationRequest['payment']['mode'] = 'CPT'; // one shot payment | ||
// $doAuthorizationRequest['payment']['contractNumber'] = 'CB'; | ||
// // ORDER | ||
// $doAuthorizationRequest['order']['ref'] = 'myOrderRef_35656'; // the reference of your order | ||
// $doAuthorizationRequest['order']['amount'] = 1000; // may differ from payment.amount if currency is different | ||
// $doAuthorizationRequest['order']['currency'] = 978; // ISO 4217 code for euro | ||
//// $doAuthorizationRequest['order']['date'] = '15/12/2014 12:20'; | ||
// // CARD | ||
// $doAuthorizationRequest['card']['number'] = '4444333322221111'; | ||
// $doAuthorizationRequest['card']['type'] = 'CB'; | ||
// $doAuthorizationRequest['card']['expirationDate'] = '1235'; | ||
// $doAuthorizationRequest['card']['cvx'] = '123'; | ||
// $doAuthorizationRequest['card']['cardholder'] = 'Marcel Patoulatchi'; | ||
// | ||
// | ||
// $doAuthorizationResponse = $paylineSDK->doAuthorization($doAuthorizationRequest); | ||
// | ||
// | ||
// // Then | ||
// $this->assertNotNull($doAuthorizationResponse); | ||
// // Should get ResultCode OK | ||
// $this->assertEquals('00000', $doAuthorizationResponse['result']['code']); | ||
// $this->assertEquals('ACCEPTED', $doAuthorizationResponse['result']['shortMessage']); | ||
// $this->assertNotNull($doAuthorizationResponse['token']); | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace test\Payline; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
class SoapVarFactoryTest extends TestCase | ||
{ | ||
|
||
public function testCreate() | ||
{ | ||
|
||
} | ||
} |
Oops, something went wrong.