Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Michael Iseard
Kudos-Donations
Commits
5c81d6de
Commit
5c81d6de
authored
Oct 26, 2020
by
Michael Iseard
Browse files
Update tests
parent
7c44a5ad
Changes
3
Hide whitespace changes
Inline
Side-by-side
tests/Entity/SubscriptionEntityTests.php
View file @
5c81d6de
...
...
@@ -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
);
...
...
tests/Entity/TransactionEntityTests.php
View file @
5c81d6de
...
...
@@ -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
);
...
...
tests/Service/MapperServiceTests.php
View file @
5c81d6de
...
...
@@ -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
->
assert
Equals
(
1
,
$save
);
$this
->
assert
NotFalse
(
$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
([
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment