view release on metacpan or search on metacpan
t/010_IOC_test.t view on Meta::CPAN
363738394041424344454647484950515253545556575859606162
use_ok(
'IOC::Visitor::SearchForContainer'
);
}
# test our simple example
{
sub
new {
my
(
$class
,
$log_file
) =
@_
;
(
$log_file
eq
'logfile.log'
) ||
die
"Got wrong log file"
;
bless
{
log_file
=>
$log_file
} =>
$class
;
}
sub
new {
my
$class
=
shift
;
bless
{
logger
=>
undef
} =>
$class
}
sub
logger {
my
(
$self
,
$logger
) =
@_
;
(UNIVERSAL::isa(
$logger
,
'FileLogger'
)) ||
die
"Got wrong logger type"
;
$self
->{logger} =
$logger
;
}
sub
run {}
}
lives_ok {
t/010_IOC_test.t view on Meta::CPAN
78798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
}
'... our simple example ran successfully'
;
# and now test out our complex example
{
sub
new {
my
(
$class
,
$log_file
) =
@_
;
(UNIVERSAL::isa(
$log_file
,
'OPEN'
)) ||
die
"Incorrect Log File"
;
bless
{
log_file
=>
$log_file
} =>
$class
;
}
sub
new {
my
$class
=
shift
;
bless
{ } =>
$class
}
sub
openFile {
my
(
$self
,
$name
) =
@_
;
return
bless
\
$name
,
'OPEN'
;
}
sub
connect
{
my
(
$class
,
$dsn
,
$u
,
$p
) =
@_
;
(
defined
(
$dsn
) &&
defined
(
$u
) &&
defined
(
$p
)) ||
die
"Database not initialized"
;
bless
{
dsn
=>
$dsn
,
u
=>
$u
,
p
=>
$p
} =>
$class
;
}
sub
new {
my
(
$class
) =
@_
;
bless
{
logger
=>
undef
,
database
=>
undef
} =>
$class
}
t/030_IOC_Service_test.t view on Meta::CPAN
8910111213141516171819202122232425262728BEGIN {
use_ok(
'IOC::Service'
);
use_ok(
'IOC::Container'
);
}
{
# create a package for a dummy service
sub
new {
my
$class
=
shift
;
return
bless
{} =>
$class
;
}
}
# this function will test that
# we got a container in our
# construction block
sub
create_logger {
my
(
$container
) =
@_
;
isa_ok(
$container
,
'IOC::Container'
);
return
Logger->new();
t/032_IOC_Service_SetterInjection_test.t view on Meta::CPAN
8910111213141516171819202122232425262728BEGIN {
use_ok(
'IOC::Service::SetterInjection'
);
use_ok(
'IOC::Container'
);
}
{
# create a package for a dummy service
sub
new {
my
(
$class
) =
@_
;
return
bless
{} =>
$class
;
}
sub
setLogFileHandle {
my
(
$self
,
$file_handle
) =
@_
;
Test::More::is(
$file_handle
,
'LogFileHandle'
,
'... got the right log file handle'
);
}
sub
setLogFileFormat {
my
(
$self
,
$file_format
) =
@_
;
Test::More::is(
$file_format
,
'LogFileFormat'
,
'... got the right log file format'
);
t/033_IOC_Service_Prototype_test.t view on Meta::CPAN
8910111213141516171819202122232425262728BEGIN {
use_ok(
'IOC::Service::Prototype'
);
use_ok(
'IOC::Container'
);
}
{
# create a package for a dummy service
sub
new {
my
$class
=
shift
;
return
bless
{} =>
$class
;
}
our
$DESTROYED_Loggers
= 0;
sub
DESTROY {
$DESTROYED_Loggers
++;
}
}
# this function will test that
# we got a container in our
t/034_IOC_Service_Prototype_ConstructorInjection_test.t view on Meta::CPAN
171819202122232425262728293031323334353637
my
(
$class
,
$file
,
$format_string
) =
@_
;
return
bless
{
file
=>
$file
,
format_string
=>
$format_string
} =>
$class
;
}
sub
new {
my
$class
=
shift
;
bless
{} =>
$class
;
}
}
can_ok(
"IOC::Service::Prototype::ConstructorInjection"
,
'new'
);
my
$service
= IOC::Service::Prototype::ConstructorInjection->new(
'logger'
=>
(
'Logger'
,
'new'
=> [
IOC::Service::Prototype::ConstructorInjection->ComponentParameter(
'file'
),
"Log %d %s"
]));
t/035_IOC_Service_Prototype_SetterInjection_test.t view on Meta::CPAN
8910111213141516171819202122232425262728BEGIN {
use_ok(
'IOC::Service::Prototype::SetterInjection'
);
use_ok(
'IOC::Container'
);
}
{
# create a package for a dummy service
sub
new {
my
(
$class
) =
@_
;
return
bless
{} =>
$class
;
}
sub
setLogFileHandle {
my
(
$self
,
$file_handle
) =
@_
;
Test::More::is(
$file_handle
,
'LogFileHandle'
,
'... got the right log file handle'
);
}
sub
setLogFileFormat {
my
(
$self
,
$file_format
) =
@_
;
Test::More::is(
$file_format
,
'LogFileFormat'
,
'... got the right log file format'
);
t/055_IOC_Proxy_Interfaces_test.t view on Meta::CPAN
1516171819202122232425262728293031323334
sub
get {}
sub
set {}
sub
keys
{}
sub
values
{}
sub
new {
my
(
$class
,
%hash
) =
@_
;
bless
\
%hash
=>
$class
;
}
sub
get { (
shift
)->{(
shift
)} }
sub
set { (
shift
)->{(
shift
)} =
shift
}
sub
keys
{
keys
%{(
shift
)} }
sub
values
{
values
%{(
shift
)} }
sub
misc_method {
return
'misc_method'
}
}
t/070_IOC_Parameterized.t view on Meta::CPAN
1213141516171819202122232425262728293031}
{
sub
new {
my
(
$class
,
$locale
) =
@_
;
bless
\
$locale
=>
$class
;
}
sub
locale { ${
$_
[0]} }
}
my
$s
= IOC::Service::Parameterized->new(
'localized_obj'
=>
sub
{
my
(
$c
,
%params
) =
@_
;
Localized::Object->new(
$params
{locale});
});
t/071_IOC_Parameterized_w_Registry.t view on Meta::CPAN
1314151617181920212223242526272829303132}
{
sub
new {
my
(
$class
,
$locale
) =
@_
;
bless
\
$locale
=>
$class
;
}
sub
locale { ${
$_
[0]} }
}
my
$s
= IOC::Service::Parameterized->new(
'localized_obj'
=>
sub
{
my
(
$c
,
%params
) =
@_
;
Localized::Object->new(
$params
{locale});
});
t/100_Test_IOC.t view on Meta::CPAN
10111213141516171819202122232425262728293031323334353637}
use
IOC;
{
sub
new {
my
(
$class
,
$log_file
) =
@_
;
(
$log_file
eq
'logfile.log'
) ||
die
"Got wrong log file"
;
bless
{
log_file
=>
$log_file
} =>
$class
;
}
sub
log_file { (
shift
)->{log_file} }
sub
new {
my
$class
=
shift
;
bless
{
logger
=>
undef
} =>
$class
}
sub
logger {
my
(
$self
,
$logger
) =
@_
;
(UNIVERSAL::isa(
$logger
,
'FileLogger'
)) ||
die
"Got wrong logger type"
;
$self
->{logger} =
$logger
;
}
sub
run {}
}
my
$container
= IOC::Container->new(
'moose'
);