Skip to content

Commit

Permalink
Item13897: Another work-in-progress commit.
Browse files Browse the repository at this point in the history
- Moo-fication of Foswiki.pm involved inevitably series of patches to other
classes.

- Fixed a bug with undef parameter passed to Foswiki::Object BUILDARGS.
  • Loading branch information
vrurg committed Jan 31, 2016
1 parent 0f8803f commit 0d7c7ea
Show file tree
Hide file tree
Showing 22 changed files with 1,502 additions and 1,420 deletions.
4 changes: 3 additions & 1 deletion PreferencesPlugin/lib/Foswiki/Plugins/PreferencesPlugin.pm
Expand Up @@ -56,7 +56,9 @@ sub beforeCommonTagsHandler {

# SMELL: Unpublished API. No choice, though :-(
require Foswiki::Form; # SMELL
$formDef = Foswiki::Form->loadCached( $Foswiki::Plugins::SESSION, $formWeb, $form );
$formDef =
Foswiki::Form->loadCached( $Foswiki::Plugins::SESSION, $formWeb,
$form );
}

my $query = Foswiki::Func::getCgiQuery();
Expand Down
7 changes: 4 additions & 3 deletions UnitTestContrib/lib/Unit/TestRunner.pm
Expand Up @@ -618,9 +618,10 @@ sub runOne {
}
}
catch {
# If for some reason any code within try just dies then why stringify what's not
# an exception object?
my $exceptionMessage = ref($_) ? $_->stringify : $_;
# If for some reason any code within try just dies then why
# stringify what's not an exception object?
my $exceptionMessage =
ref($_) && $_->can('stringify') ? $_->stringify : $_;
safe_print "*** ", $exceptionMessage, "\n";
if ( $tester->expecting_failure ) {
$action .=
Expand Down
4 changes: 2 additions & 2 deletions UnitTestContrib/test/unit/FoswikiFnTestCase.pm
Expand Up @@ -147,7 +147,7 @@ around set_up => sub {
$this->test_user_surname, $this->test_user_email
);
$this->test_user_cuid(
$this->session->{users}->getCanonicalUserID( $this->test_user_login ) );
$this->session->users->getCanonicalUserID( $this->test_user_login ) );
};

around tear_down => sub {
Expand Down Expand Up @@ -199,7 +199,7 @@ Can be used by subclasses to register test users.

sub registerUser {
my ( $this, $loginname, $forename, $surname, $email ) = @_;
my $q = $this->session->{request};
my $q = $this->session->request;

my $params = {
'TopicName' => ['UserRegistration'],
Expand Down
23 changes: 15 additions & 8 deletions UnitTestContrib/test/unit/FoswikiTestCase.pm
Expand Up @@ -726,7 +726,7 @@ s/((\$Foswiki::cfg\{.*?\})\s*=.*?;)(?:\n|$)/push(@moreConfig, $1) unless (eval "
# This must be done before moving the logging.
my $query = new Unit::Request();
$Foswiki::cfg{Store}{Implementation} = 'Foswiki::Store::PlainFile';
my $tmp = new Foswiki( undef, $query );
my $tmp = Foswiki->new( user => undef, request => $query );
ASSERT( defined $Foswiki::Plugins::SESSION ) if SINGLE_SINGLETONS;
undef $tmp; # finish() will be called automatically.
ASSERT( !defined $Foswiki::Plugins::SESSION ) if SINGLE_SINGLETONS;
Expand Down Expand Up @@ -849,13 +849,20 @@ sub removeWebFixture {
my ( $this, $session, $web ) = @_;

try {
my $webObject = Foswiki::Meta->new( $session, $web );
my $webObject = Foswiki::Meta->new( session => $session, web => $web );
$webObject->removeFromStore();
}
catch {
my $e = $_;
print STDERR "Unexpected exception while removing web $web\n";
print STDERR $e->stringify(), "\n" if $e;
if ($e) {
if ( ref($e) && $e->can('stringify') ) {
say STDERR $e->stringify;
}
else {
say STDERR $e;
}
}
};
}

Expand Down Expand Up @@ -887,7 +894,7 @@ sub capture {
ASSERT( ref($session) || ref($Foswiki::Plugins::SESSION) );
my $response =
UNIVERSAL::isa( $session, 'Foswiki' )
? $session->{response}
? $session->response
: $Foswiki::Plugins::SESSION->{response};

my $responseText = '';
Expand Down Expand Up @@ -1007,11 +1014,11 @@ sub getUIFn {

=begin TML
---++ ObjectMethod createNewFoswikiSession(params) -> ref to new Foswiki obj
---++ ObjectMethod createNewFoswikiSession($user, $query, params) -> ref to new Foswiki obj
cleans up the existing Foswiki object, and creates a new one
params are passed directly to the new Foswiki() call
params have to be key/value pairs and are passed directly to the new Foswiki() call
typically called to force a full re-initialisation either with new preferences, topics, users, groups or CFG
Expand All @@ -1026,8 +1033,8 @@ sub createNewFoswikiSession {
$this->clear_session if $this->session;
ASSERT( !defined $Foswiki::Plugins::SESSION ) if SINGLE_SINGLETONS;
$Foswiki::cfg{Store}{Implementation} ||= 'Foswiki::Store::PlainFile';
$this->session( Foswiki->new( $user, $query, @args ) );
$this->request( $this->session->{request} );
$this->session( Foswiki->new( user => $user, request => $query, @args ) );
$this->request( $this->session->request );
ASSERT( defined $Foswiki::Plugins::SESSION ) if SINGLE_SINGLETONS;
if ( $this->test_web && $this->test_topic ) {
$this->test_topicObject(
Expand Down

0 comments on commit 0d7c7ea

Please sign in to comment.