ePages 7.23.0 - DE_EPAGES/Test/Mock/MockifyServlet.pm

Package DE_EPAGES::Test::Mock::MockifyServlet

framework to mock an epages Servlet based on mockify

Base
DE_EPAGES::Test::Mock::Mockify
Example
my $AddressObject = DE_EPAGES::Test::Mock::EpagesObject->new('DE_EPAGES::Address::API::Object::Address',{})
my $MockifyServlet = DE_EPAGES::Test::Mock::MockifyServlet->new( $AddressObject );
$MockifyServlet->addVar('username', 'mustermann', {'string'=>'mayer'});
my $Servlet = $MockifyServlet->getMockObject();
$Servlet->vars(); # return the whole hash
$Servlet->vars('username'); # return 'mustermann'
$Servlet->vars('username','mayer'); # proof value and return 'mayer'

to add multiple Variables without a value check use:
$MockifyServlet->addVars({'key1'=>'value1', 'key2'=>'value2', ...});

Functions

addVar
addVars
new

addVar

add a variables to servlet the $Validator is optional addVar( 'Key', 'Value' ) addVar( 'Key', 'Value', 'string' ) addVar( 'Key', 'Value', {'string' => 'abcd'} ) The Validator test the value when using the $servlet->vars() as setter

Syntax
addVar( $Key, $Value, $Validator );
Input
$Key (string)
a key
$Value (string)
a value
$Validator (string or refhash)
value for validation

addVars

add the variables to the servlet withVars({'username', 'mustermann'});

Syntax
addVars( $hVars );
Input
$hVars (ref_hash)
hash with variables

new

constructor

Syntax
new( $ObjectInServlet );
Input
$ObjectInServlet (object)
object wich will be injected
Return
$self (DE_EPAGES::Test::Mock::MockifyServlet)
self