You are here: Foswiki>Tasks Web>Item1131 (19 Jun 2012, PaulHarvey)Edit Attach

Item1131: add a FoswikiFnTestCase::changeSettings

pencil
Priority: Enhancement
Current State: Closed
Released In: n/a
Target Release: n/a
Applies To: Engine
Component: UnitTestContrib
Branches:
Reported By: SvenDowideit
Waiting For: SvenDowideit
Last Change By: PaulHarvey
which would replace the following mess

    $this->SUPER::set_up();

    $Foswiki::cfg{StoreImpl} = "RcsLite";
    $Foswiki::cfg{AutoAttachPubFiles} = 0;
    $Foswiki::cfg{Register}{AllowLoginName} = 1;
    $Foswiki::cfg{Htpasswd}{FileName} = "$Foswiki::cfg{WorkingDir}/htpasswd";
    $Foswiki::cfg{PasswordManager} = 'Foswiki::Users::HtPasswdUser';
    $Foswiki::cfg{UserMappingManager} = 'Foswiki::Users::TopicUserMapping';
    $Foswiki::cfg{LoginManager} = 'Foswiki::LoginManager::TemplateLogin';
    $Foswiki::cfg{Register}{EnableNewUserRegistration} = 1;
    $Foswiki::cfg{RenderLoggedInButUnknownUsers} = 0;

    $Foswiki::cfg{Register}{NeedVerification} = 0;
    $Foswiki::cfg{MinPasswordLength} = 0;
    $Foswiki::cfg{UsersWebName} = $this->{users_web};
    my $query = new Unit::Request("");

with

sub changeSettings {
    my $this = shift;
    $this->SUPER::changeSettings();

    $Foswiki::cfg{StoreImpl} = "RcsLite";
    $Foswiki::cfg{AutoAttachPubFiles} = 0;
    $Foswiki::cfg{Register}{AllowLoginName} = 1;
    $Foswiki::cfg{Htpasswd}{FileName} = "$Foswiki::cfg{WorkingDir}/htpasswd";
    $Foswiki::cfg{PasswordManager} = 'Foswiki::Users::HtPasswdUser';
    $Foswiki::cfg{UserMappingManager} = 'Foswiki::Users::TopicUserMapping';
    $Foswiki::cfg{LoginManager} = 'Foswiki::LoginManager::TemplateLogin';
    $Foswiki::cfg{Register}{EnableNewUserRegistration} = 1;
    $Foswiki::cfg{RenderLoggedInButUnknownUsers} = 0;

    $Foswiki::cfg{Register}{NeedVerification} = 0;
    $Foswiki::cfg{MinPasswordLength} = 0;
    $Foswiki::cfg{UsersWebName} = $this->{users_web};
}
....
sub set_up {
    my $this = shift;
    $this->SUPER::set_up();

    $this->changeSettings();

    my $query = new Unit::Request("");

so that we're not forced to re-finish and re-new the foswiki object at each unit test level. This could actually be used to simplify the verify_ tests too.

-- SvenDowideit - 24 Feb 2009

Presumably you want to override changeSettings in the test cases. How is that any different to overriding set_up? I don't understand what you expect to gain from this.

-- CrawfordCurrie - 24 Feb 2009

when you 'over-ride' set_up you are expected to call its SUPER - which means at each level we need to create a new Unit::Request, Foswiki session object and so on - to change the cfg options, you need to inject it into the middle of what is the current set_up function.

-- SvenDowideit - 25 Feb 2009

Ah, a dawning realisation is coming upon me. You want to be able to set the cfg options after the current state is saved but before the fixture is created? OK, that makes sense. Confirmed.

-- CrawfordCurrie - 25 Feb 2009

There is no bug here. Nothing is broken. Nothing to fix.

Changed to enhancement - so it can be ignored - like it has been for 1.5 years.

-- KennethLavrsen - 31 Jul 2010

Is this the function FoswikiFnTestCase->loadExtraConfig()

ObjectMethod loadExtraConfig()

This method can be overridden (overrides should call up to the base class) to add extra stuff to Foswiki::cfg.

So this can be closed?

-- GeorgeClark - 14 Mar 2011

Making an executive decision that yes, this can be closed now.

-- PaulHarvey - 19 Jun 2012 - 01:29

ItemTemplate edit

Summary add a FoswikiFnTestCase::changeSettings
ReportedBy SvenDowideit
Codebase
SVN Range Foswiki-1.0.0, Thu, 08 Jan 2009, build 1878
AppliesTo Engine
Component UnitTestContrib
Priority Enhancement
CurrentState Closed
WaitingFor SvenDowideit
Checkins
TargetRelease n/a
ReleasedIn n/a
CheckinsOnBranches
trunkCheckins
Release01x01Checkins
Topic revision: r9 - 19 Jun 2012, PaulHarvey
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy