Skip to content

Commit

Permalink
Item13897: Documentation for PlackTestCase.
Browse files Browse the repository at this point in the history
- Added support for non-Foswiki prefixed modules to INCLUDE's doc handler.
It is now handles all modules located in subdirectories for the directory
where Foswiki.pm is located as local documentation. So, for example, if a document
references Unit::TestCase as a plain text doc handler will convert it into
a valid link to Unit/TestCase.pm as it was doing this with modules under
Foswiki:: hieararchy.

- Added support for external modules to INCLUDE's doc handler. If a module
is not located in Foswiki directory tree as described above it is
considered external and a link to CPAN is generated.

- Added some documentation to Unit::FoswikiTestRole.

- Unit::FoswikiTestRole::setupDirs doesn't fail if directory already
exists.

- Unit::FoswikiTestRole::setupDirs throws Foswiki::Exception::FileOp if
mkdir fails.

- Unit::PlackTestCase::initRequest() initializes server application
instance similar to initTest() method. This was a forgotten piece of code.
  • Loading branch information
vrurg committed Aug 29, 2016
1 parent 06435e6 commit a33e0ff
Show file tree
Hide file tree
Showing 8 changed files with 512 additions and 72 deletions.
42 changes: 41 additions & 1 deletion UnitTestContrib/lib/Unit/FoswikiTestRole.pm
Expand Up @@ -15,6 +15,7 @@ use Assert;
use Try::Tiny;
use File::Spec;
use Scalar::Util qw(blessed);
use Foswiki::Exception;

BEGIN {
if (Unit::TestRunner::CHECKLEAK) {
Expand All @@ -32,6 +33,13 @@ use Moo::Role;

our @mails;

=begin TML
---++ ObjectAttribute app
Test case application object.
=cut

has app => (
is => 'rw',
lazy => 1,
Expand All @@ -46,24 +54,50 @@ has app => (
},
handles => [qw(create)],
);

=begin TML
---++ ObjectAttribute test_web
Default test web name.
=cut

has test_web => (
is => 'rw',
lazy => 1,
clearer => 1,
default => sub { return $_[0]->testWebName; },
);

=begin TML
---++ ObjectAttribute test_topic
Default test topic name.
=cut

has test_topic => (
is => 'rw',
lazy => 1,
default => sub { return 'TestTopic' . $_[0]->testSuite; },
);

=begin TML
---++ ObjectAttribute test_topic
Default users web for test.
=cut

has users_web => (
is => 'rw',
lazy => 1,
builder => 'prepareUsersWeb',
);

has _holderStack => ( is => 'rw', lazy => 1, default => sub { [] }, );

# List of webs created with populateNewWeb method.
has _testWebs => (
is => 'rw',
lazy => 1,
Expand Down Expand Up @@ -422,7 +456,12 @@ sub setupDirs {
foreach my $subdir (qw(tmp registration_approvals work_areas requestTmp)) {
my $newDir =
File::Spec->catfile( $this->app->cfg->data->{WorkingDir}, $subdir );
ASSERT( mkdir($newDir), "mkdir($newDir) : $!" );
unless ( -d $newDir || mkdir($newDir) ) {
Foswiki::Exception::FileOp->throw(
file => $newDir,
op => "mkdir",
);
}
}

# Note this does not do much, except for some tests that use it directly.
Expand All @@ -445,6 +484,7 @@ sub setupDirs {

=begin TML
#setupAdminUser
---++ ObjectMethod setupAdminUser(%userData)
Sets this test administrator user data. The =%userData= hash may have the
Expand Down

0 comments on commit a33e0ff

Please sign in to comment.