-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added-status-check-myaffiliates (#17)
* added-status-check * removed-tidy-files * trigger tests 2024-10-09 13:41:08 * added-test-case * trigger tests 2024-10-13 14:04:15 * trigger tests 2024-10-16 05:51:30 * status-update * trigger tests 2024-10-17 06:24:01 * trigger tests 2024-10-28 17:19:40 * trigger tests 2024-10-28 17:48:17 * trigger tests 2024-10-28 19:46:48 * trigger tests 2024-10-29 05:45:36
- Loading branch information
1 parent
7d078cb
commit f1e91a2
Showing
7 changed files
with
172 additions
and
83 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
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 |
---|---|---|
|
@@ -20,19 +20,19 @@ $mock_aff->mock( | |
sub { | ||
return +{ | ||
'INIT' => { | ||
'ERROR_COUNT' => 0, | ||
'ERROR_COUNT' => 0, | ||
'WARNING_COUNT' => 0, | ||
}}; | ||
} | ||
}; | ||
|
||
}); | ||
} | ||
); | ||
|
||
ok($aff->create_affiliate({}), 'A hashref is a valid parameter'); | ||
ok( $aff->create_affiliate( {} ), 'A hashref is a valid parameter' ); | ||
|
||
my $hash_params = ( | ||
first_name => 'Dummy' | ||
); | ||
my $hash_params = ( first_name => 'Dummy' ); | ||
|
||
ok($aff->create_affiliate({}), 'A hash is a valid parameter'); | ||
ok( $aff->create_affiliate( {} ), 'A hash is a valid parameter' ); | ||
|
||
$mock_aff->mock( | ||
'request', | ||
|
@@ -43,9 +43,12 @@ $mock_aff->mock( | |
'ERROR' => { | ||
'MSG' => 'An account with this email already exists.', | ||
'DETAIL' => 'email' | ||
}}}; | ||
} | ||
} | ||
}; | ||
|
||
}); | ||
} | ||
); | ||
|
||
my $args = { | ||
'first_name' => 'Charles', | ||
|
@@ -68,28 +71,33 @@ my $args = { | |
|
||
my $res = $aff->create_affiliate($args); | ||
|
||
ok(!$res, 'Returns undef in case of a single error'); | ||
ok( !$res, 'Returns undef in case of a single error' ); | ||
|
||
$mock_aff->mock( | ||
'request', | ||
sub { | ||
return +{ | ||
'INIT' => { | ||
'ERROR_COUNT' => 2, | ||
'ERROR' => [{ | ||
'MSG' => 'An account with this email already exists.', | ||
'ERROR' => [ | ||
{ | ||
'MSG' => 'An account with this email already exists.', | ||
'DETAIL' => 'email' | ||
}, | ||
{ | ||
'DETAIL' => 'username', | ||
'MSG' => 'Username not available' | ||
}]}}; | ||
} | ||
] | ||
} | ||
}; | ||
|
||
}); | ||
} | ||
); | ||
|
||
$res = $aff->create_affiliate($args); | ||
|
||
ok(!$res, 'Returns undef in case of multiple errors'); | ||
ok( !$res, 'Returns undef in case of multiple errors' ); | ||
|
||
$mock_aff->mock( | ||
'request', | ||
|
@@ -100,13 +108,16 @@ $mock_aff->mock( | |
'ERROR' => { | ||
'MSG' => 'An account with this email already exists.', | ||
'DETAIL' => 'email' | ||
}}}; | ||
} | ||
} | ||
}; | ||
|
||
}); | ||
} | ||
); | ||
|
||
$res = $aff->create_affiliate($args); | ||
|
||
ok(!$res, 'Returns undef in case of single error'); | ||
ok( !$res, 'Returns undef in case of single error' ); | ||
|
||
$mock_aff->mock( | ||
'request', | ||
|
@@ -117,7 +128,8 @@ $mock_aff->mock( | |
'WARNING_COUNT' => 1, | ||
'WARNING_DETAIL' => { | ||
'DETAIL' => 'password', | ||
'MSG' => 'Setting a password for a new affiliate is optional and will be deprecated in future' | ||
'MSG' => | ||
'Setting a password for a new affiliate is optional and will be deprecated in future' | ||
}, | ||
'USERNAME' => 'charles_babbage', | ||
'PASSWORD' => 's3cr3t', | ||
|
@@ -126,13 +138,15 @@ $mock_aff->mock( | |
'COUNTRY' => 'GB', | ||
'LANGUAGE' => 0, | ||
'EMAIL' => '[email protected]' | ||
}}; | ||
}); | ||
} | ||
}; | ||
} | ||
); | ||
|
||
$res = $aff->create_affiliate($args); | ||
|
||
ok($res, 'Returns the ref correctly'); | ||
ok(!$res->{PASSWORD}, 'It does not return the password'); | ||
ok( $res, 'Returns the ref correctly' ); | ||
ok( !$res->{PASSWORD}, 'It does not return the password' ); | ||
|
||
done_testing(); | ||
|
||
|
Oops, something went wrong.