-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from ivodvb/unit-tests
Added unit tests
- Loading branch information
Showing
7 changed files
with
139 additions
and
1 deletion.
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,27 @@ | ||
language: php | ||
|
||
sudo: false | ||
|
||
# whitelist for building branches | ||
branches: | ||
only: | ||
- master | ||
- stable | ||
|
||
matrix: | ||
include: | ||
- php: 5.3 | ||
- php: 5.4 | ||
- php: 5.5 | ||
- php: 5.6 | ||
- php: 7 | ||
fast_finish: true | ||
|
||
before_install: | ||
- composer self-update | ||
|
||
before_script: | ||
- composer install | ||
|
||
script: | ||
- vendor/bin/phpunit --bootstrap vendor/autoload.php tests/ |
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
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
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
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
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,41 @@ | ||
<?php | ||
|
||
class ConfigTest extends PHPUnit_Framework_TestCase | ||
{ | ||
public function testCAInfoLocation() | ||
{ | ||
\Paynl\Config::setCAInfoLocation('test/location'); | ||
|
||
$this->assertEquals('test/location', | ||
\Paynl\Config::getCAInfoLocation()); | ||
} | ||
|
||
public function testApiToken() | ||
{ | ||
\Paynl\Config::setApiToken('my-api-token'); | ||
|
||
$this->assertEquals('my-api-token', \Paynl\Config::getApiToken()); | ||
} | ||
|
||
public function testServiceId() | ||
{ | ||
\Paynl\Config::setServiceId('my-service-id'); | ||
|
||
$this->assertEquals('my-service-id', \Paynl\Config::getServiceId()); | ||
} | ||
|
||
public function testApiVersion() | ||
{ | ||
\Paynl\Config::setServiceId('api-version'); | ||
|
||
$this->assertEquals('api-version', \Paynl\Config::getServiceId()); | ||
} | ||
|
||
public function testApiUrl() | ||
{ | ||
$this->assertEquals( | ||
'https://rest-api.pay.nl/v5/transaction/json', | ||
\Paynl\Config::getApiUrl('transaction', 5) | ||
); | ||
} | ||
} |
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,37 @@ | ||
<?php | ||
|
||
class HelperTest extends PHPUnit_Framework_TestCase | ||
{ | ||
public function testRequireApiTokenException() | ||
{ | ||
$this->setExpectedException('\Paynl\Error\Required\ApiToken'); | ||
|
||
\Paynl\Config::setApiToken(''); | ||
\Paynl\Helper::requireApiToken(); | ||
} | ||
|
||
public function testRequireServiceIdException() | ||
{ | ||
$this->setExpectedException('\Paynl\Error\Required\ServiceId'); | ||
|
||
\Paynl\Config::setServiceId(''); | ||
\Paynl\Helper::requireServiceId(); | ||
} | ||
|
||
public function testCalculateTaxClass() | ||
{ | ||
$calculatedTaxClass = \Paynl\Helper::calculateTaxClass(10, 0.6); | ||
|
||
$this->assertEquals('L', $calculatedTaxClass); | ||
} | ||
|
||
public function testSplitAddress() | ||
{ | ||
$splittedAddress = \Paynl\Helper::splitAddress('Voorstraat 2'); | ||
|
||
$this->assertEquals(array( | ||
'Voorstraat', | ||
'2' | ||
), $splittedAddress); | ||
} | ||
} |