-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2f2213e
commit acf7350
Showing
1 changed file
with
63 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,63 @@ | ||
<?php | ||
/** | ||
* Address transformer test | ||
* | ||
* @author Pronamic <[email protected]> | ||
* @copyright 2005-2024 Pronamic | ||
* @license GPL-3.0-or-later | ||
* @package Pronamic\WordPress\Pay | ||
*/ | ||
|
||
namespace Pronamic\WordPress\Pay\Gateways\Mollie; | ||
|
||
use Pronamic\WordPress\Mollie\Address as MollieAddress; | ||
use Pronamic\WordPress\Pay\Address as PronamicAddress; | ||
use Pronamic\WordPress\Pay\ContactName; | ||
use Yoast\PHPUnitPolyfills\TestCases\TestCase; | ||
|
||
/** | ||
* Address transformer test class | ||
*/ | ||
class AddressTransformerTest extends TestCase { | ||
/** | ||
* Test transform. | ||
* | ||
* @param string $phone Phone number. | ||
* @param string $phone_e164 Phone number E164. | ||
* | ||
* @dataProvider transform_provider | ||
*/ | ||
public function test_transform( $phone, $phone_e164 ) { | ||
$name = new ContactName(); | ||
|
||
$name->set_first_name( 'John' ); | ||
$name->set_last_name( 'Doe' ); | ||
|
||
$pronamic_address = new PronamicAddress(); | ||
|
||
$pronamic_address->set_name( $name ); | ||
$pronamic_address->set_email( '[email protected]' ); | ||
$pronamic_address->set_phone( $phone ); | ||
$pronamic_address->set_line_1( 'Kleine Kerkstraat 1' ); | ||
$pronamic_address->set_city( 'Leeuwarden' ); | ||
$pronamic_address->set_country_code( 'NL' ); | ||
|
||
$transformer = new AddressTransformer(); | ||
|
||
$mollie_address = $transformer->transform_wp_to_mollie( $pronamic_address ); | ||
|
||
$this->assertEquals( $phone_e164, $mollie_address->phone ); | ||
} | ||
|
||
/** | ||
* Transform provider. | ||
* | ||
* @return array | ||
*/ | ||
public function transform_provider() { | ||
return [ | ||
[ '1234567890', '+311234567890' ], | ||
[ '+321234567890', '+321234567890' ], | ||
]; | ||
} | ||
} |