Skip to content

Commit

Permalink
Create AddressTransformerTest.php
Browse files Browse the repository at this point in the history
  • Loading branch information
remcotolsma committed Oct 18, 2024
1 parent 2f2213e commit acf7350
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions tests/src/AddressTransformerTest.php
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' ],
];
}
}

0 comments on commit acf7350

Please sign in to comment.