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

Commit

Permalink
- Jenkins pipeline for sonar coverage
Browse files Browse the repository at this point in the history
- Add Phpunit
- Add test
  • Loading branch information
thomasmonext committed Nov 29, 2023
1 parent 4aa56dd commit ce81d07
Show file tree
Hide file tree
Showing 8 changed files with 111,376 additions and 0 deletions.
47 changes: 47 additions & 0 deletions Jenkinsfile
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'
}
}
}
}
}
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
99,312 changes: 99,312 additions & 0 deletions lib/phpunit-10.3.5.phar

Large diffs are not rendered by default.

120 changes: 120 additions & 0 deletions tests/test/Payline/PaylineSDKTest.php
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']);
// }
}
14 changes: 14 additions & 0 deletions tests/test/Payline/SoapVarFactoryTest.php
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()
{

}
}
Loading

0 comments on commit ce81d07

Please sign in to comment.