Commit 5c81d6de authored by Michael Iseard's avatar Michael Iseard
Browse files

Update tests

parent 7c44a5ad
......@@ -15,11 +15,15 @@ class SubscriptionEntityTests extends WP_UnitTestCase {
$mapper->save(new DonorEntity([
'customer_id' => 12345,
'email' => 'test@email.com',
'name' => 'Michael'
]));
$subscription = new SubscriptionEntity([
'customer_id' => 12345,
'value' => 20,
'frequency' => '12 months',
'years' => 3
]);
$mapper->save($subscription);
......
......@@ -15,11 +15,17 @@ class TransactionEntityTests extends WP_UnitTestCase {
$mapper->save(new DonorEntity([
'customer_id' => 12345,
'email' => 'test@email.com',
'name' => 'Michael'
]));
$transaction = new TransactionEntity([
'customer_id' => 12345,
'order_id' => 'kdo_12345',
'value' => 20,
'status' => 'open',
'mode' => 'test',
'sequence_type' => 'oneoff'
]);
$mapper->save($transaction);
......
......@@ -6,7 +6,6 @@ use Kudos\Entity\TransactionEntity;
use Kudos\Exceptions\MapperException;
use Kudos\Service\MapperService;
use Kudos\Service\MollieService;
use ReflectionException;
use WP_UnitTestCase;
class MapperServiceTests extends WP_UnitTestCase {
......@@ -47,19 +46,6 @@ class MapperServiceTests extends WP_UnitTestCase {
/**
* @throws MapperException
* @throws ReflectionException
*/
public function test_set_repository_throws_reflection_exception() {
$this->expectException(ReflectionException::class);
$mapper = new MapperService();
$mapper->set_repository('InvalidClass');
}
/**
* @throws MapperException
* @throws ReflectionException
*/
public function test_set_repository_throws_mapper_exception() {
......@@ -71,7 +57,6 @@ class MapperServiceTests extends WP_UnitTestCase {
/**
* @throws MapperException
* @throws ReflectionException
*/
public function test_set_and_get_repository_works_for_entity() {
......@@ -96,7 +81,7 @@ class MapperServiceTests extends WP_UnitTestCase {
$mapper = new MapperService();
$save = $mapper->save($entity);
$this->assertEquals(1, $save );
$this->assertNotFalse($save );
}
......@@ -165,6 +150,25 @@ class MapperServiceTests extends WP_UnitTestCase {
}
public function test_entity_missing_required_properties_on_save() {
$entity = new TransactionEntity([
'currency' => 'EUR',
'customer_id' => 'cst_1234',
'mode' => 'test',
'invalid_property' => 'ignore me',
'sequence_type' => 'oneoff',
// 'value' => 20, // Required and disabled
'status' => 'open',
'transaction_id' => 't_12345',
'order_id' => 'kdo_12345',
]);
$mapper = new MapperService(TransactionEntity::class);
$save = $mapper->save($entity);
$this->assertFalse($save);
}
public function test_invalid_properties_ignored() {
$entity = new TransactionEntity([
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment