Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add tests

  • Loading branch information...
commit 8a8d4ec14642f5dfb964df9edf7d7a7b96e4a36b 1 parent d8a820f
ysasaki authored
View
16 Makefile.PL
@@ -2,12 +2,16 @@ use 5.010000;
use ExtUtils::MakeMaker;
WriteMakefile(
- NAME => 'Apache2::Data::Section::Simple',
- VERSION_FROM => 'lib/Apache2/Data/Section/Simple.pm',
- PREREQ_PM => {
- 'Apache2::RequestUtil' => 0,
- },
+ NAME => 'Apache2::Data::Section::Simple',
+ VERSION_FROM => 'lib/Apache2/Data/Section/Simple.pm',
ABSTRACT_FROM => 'lib/Apache2/Data/Section/Simple.pm',
AUTHOR => 'Yoshihiro Sasaki <ysasaki at cpan.org>',
- LICENSE => 'perl',
+ LICENSE => 'perl',
+ PREREQ_PM => {
+ 'Apache2::RequestUtil' => 0,
+ },
+ BUILD_REQUIRES => {
+ 'Test::MockObject' => 0,
+ 'Data::Section::Simple' => 0,
+ },
);
View
7 t/000_compile.t
@@ -0,0 +1,7 @@
+use strict;
+use warnings;
+use Test::More;
+
+BEGIN { use_ok('Apache2::Data::Section::Simple') };
+
+done_testing;
View
46 t/001_get_data_section.t
@@ -0,0 +1,46 @@
+use strict;
+use warnings;
+use Test::More;
+use Test::MockObject;
+use Data::Section::Simple;
+
+use Apache2::RequestUtil;
+use Apache2::Data::Section::Simple;
+
+my $mock = Test::MockObject->new;
+$mock->fake_module(
+ 'Apache2::RequestUtil',
+ request => sub { bless {}, 'Request::Dummy' }
+);
+
+$mock->fake_module(
+ 'Request::Dummy',
+ filename => sub { $0 }
+);
+
+my $expected = Data::Section::Simple::get_data_section;
+
+subtest 'OO style' => sub {
+ my $dss = new_ok 'Apache2::Data::Section::Simple';
+ my $got = $dss->get_data_section;
+ is_deeply $got, $expected, 'data section ok'
+ or diag explain $got;
+};
+
+subtest 'Functional style' => sub {
+ my $got = Apache2::Data::Section::Simple::get_data_section;
+ is_deeply $got, $expected, 'data section ok'
+ or diag explain $got;
+};
+
+done_testing;
+
+__DATA__
+
+@@ foo
+
+This is foo.
+
+@@ bar
+
+This is bar.
View
18 t/Apache2-Data-Section-Simple.t
@@ -1,18 +0,0 @@
-# Before `make install' is performed this script should be runnable with
-# `make test'. After `make install' it should work as `perl Apache2-Data-Section-Simple.t'
-
-#########################
-
-# change 'tests => 1' to 'tests => last_test_to_print';
-
-use strict;
-use warnings;
-
-use Test::More tests => 1;
-BEGIN { use_ok('Apache2::Data::Section::Simple') };
-
-#########################
-
-# Insert your test code below, the Test::More module is use()ed here so read
-# its man page ( perldoc Test::More ) for help writing this test script.
-
Please sign in to comment.
Something went wrong with that request. Please try again.