@@ -1,22 +1,24 @@
use strict;

package SeleniumConfigTests;

use FoswikiSeleniumTestCase;
our @ISA = qw( FoswikiSeleniumTestCase );
use v5.14;

use Foswiki::Func;

sub new {
my $self = shift()->SUPER::new( 'SeleniumConfig', @_ );
return $self;
}
use Moo;
use namespace::clean;
extends qw( FoswikiSeleniumTestCase );

around BUILDARGS => sub {
my $orig = shift;
return $orig->( @_, testSuite => 'SeleniumConfig' );
};

sub verify_SeleniumRc_config {
my $this = shift;
$this->selenium->open_ok(
Foswiki::Func::getScriptUrl(
$this->{test_web}, $this->{test_topic}, 'view'
$this->test_web, $this->test_topic, 'view'
)
);
$this->login();
@@ -38,7 +40,7 @@ sub verify_SeleniumRc_like_failure_reporting {
my $this = shift;
$this->selenium->open_ok(
Foswiki::Func::getScriptUrl(
$this->{test_web}, $this->{test_topic}, 'view'
$this->test_web, $this->test_topic, 'view'
)
);
eval {
@@ -1,13 +1,13 @@
package SemiAutomaticTestCaseTests;
use strict;
use warnings;

use FoswikiFnTestCase();
our @ISA = qw( FoswikiFnTestCase );
use v5.14;

use Foswiki();
use Foswiki::UI::View();
use Error qw( :try );
use Try::Tiny;

use Moo;
use namespace::clean;
extends qw( FoswikiFnTestCase );

my $VIEW_UI_FN;

@@ -128,9 +128,10 @@ text
@
T3

sub set_up {
around set_up => sub {
my $orig = shift;
my $this = shift;
$this->SUPER::set_up();
$orig->( $this, @_ );

# Testcases are written using good anchors
$Foswiki::cfg{RequireCompatibleAnchors} = 0;
@@ -149,17 +150,24 @@ sub set_up {

# This user is used in some testcases. All we need to do is make sure
# their topic exists in the test users web
if ( !$this->{session}
->topicExists( $Foswiki::cfg{UsersWebName}, 'WikiGuest' ) )
if (
!$this->session->topicExists(
$Foswiki::cfg{UsersWebName}, 'WikiGuest'
)
)
{
my ($to) =
Foswiki::Func::readTopic( $Foswiki::cfg{UsersWebName}, 'WikiGuest' );
$to->text('This user is used in some testcases');
$to->save();
$to->finish();
}
if ( !$this->{session}
->topicExists( $Foswiki::cfg{UsersWebName}, 'UnknownUser' ) )
if (
!$this->session->topicExists(
$Foswiki::cfg{UsersWebName},
'UnknownUser'
)
)
{
my ($to) =
Foswiki::Func::readTopic( $Foswiki::cfg{UsersWebName},
@@ -168,25 +176,25 @@ sub set_up {
$to->save();
$to->finish();
}
};

return;
}

sub tear_down {
around tear_down => sub {
my $orig = shift;
my $this = shift;
for ( my $i = 1 ; $i <= scalar @test_comma_v ; $i++ ) {
my $f = "$Foswiki::cfg{DataDir}/TestCases/SearchTestTopic$i.txt,v";
unlink $f if -e $f;
}
$this->SUPER::tear_down();
}
$orig->($this);
};

sub list_tests {
around list_tests => sub {
my $orig = shift;
my ( $this, $suite ) = @_;
my @set = $this->SUPER::list_tests(@_);
my @set = $orig->( $this, @_ );

$this->createNewFoswikiSession();
unless ( $this->{session}->webExists('TestCases') ) {
unless ( $this->session->webExists('TestCases') ) {
print STDERR
"Cannot run semi-automatic test cases; TestCases web not found";
return;
@@ -207,7 +215,7 @@ sub list_tests {
}
$this->finishFoswikiSession();
return @set;
}
};

sub run_testcase {
my ( $this, $testcase ) = @_;
@@ -224,21 +232,21 @@ sub run_testcase {
$Foswiki::cfg{Plugins}{TestFixturePlugin}{Enabled} = 1;
$Foswiki::cfg{Plugins}{TestFixturePlugin}{Module} =
'Foswiki::Plugins::TestFixturePlugin';
$this->createNewFoswikiSession( $this->{test_user_login}, $query );
$this->createNewFoswikiSession( $this->test_user_login, $query );
my ($topicObject) =
Foswiki::Func::readTopic( $this->{users_web}, 'ProjectContributor' );
Foswiki::Func::readTopic( $this->users_web, 'ProjectContributor' );
$topicObject->text('none');
$topicObject->save();
$topicObject->finish();
my ($text) = $this->capture( $VIEW_UI_FN, $this->{session} );
my ($text) = $this->capture( $VIEW_UI_FN, $this->session );

unless ( $text =~ m#<font color="green">ALL TESTS PASSED</font># ) {
$this->assert(
open( my $F, '>:encoding(utf8)', "${testcase}_run.html" ) );
print $F $text;
$this->assert( close $F );
$query->delete('test');
($text) = $this->capture( $VIEW_UI_FN, $this->{session} );
($text) = $this->capture( $VIEW_UI_FN, $this->session );
$this->assert( open( $F, '>:encoding(utf8)', "${testcase}.html" ) );
print $F $text;
$this->assert( close $F );
@@ -6,12 +6,7 @@
# initially they test the ancient Embedded code

package SerialiseTests;
use strict;
use warnings;
require 5.006;

use FoswikiFnTestCase();
our @ISA = qw( FoswikiFnTestCase );
use v5.14;

use Assert;
use Foswiki;
@@ -20,23 +15,10 @@ use Foswiki::Plugin();
use Foswiki::Func();
use File::Temp();
use Foswiki::AccessControlException();
use Error qw( :try );

sub set_up {
my $this = shift;

$this->SUPER::set_up();

return;
}

sub tear_down {
my $this = shift;

$this->SUPER::tear_down();

return;
}
use Moo;
use namespace::clean;
extends qw( FoswikiFnTestCase );

sub skip {
my ( $this, $test ) = @_;
@@ -98,7 +80,7 @@ sub test_SimpleMetaTopic {
my $this = shift;

my $meta =
Foswiki::Meta->new( $this->{session}, $this->{test_web}, 'TestTopic' );
Foswiki::Meta->new( $this->session, $this->test_web, 'TestTopic' );

$meta->text("\n\n onceler \n \n\n \n\n\n");
$meta->putKeyed( 'FIELD', { name => 'fieldname', value => 'meta' } );
@@ -111,8 +93,11 @@ sub test_SimpleMetaTopic {

my $text = $meta->getEmbeddedStoreForm();

my $metaFromSerialised =
Foswiki::Meta->new( $this->{session}, $this->{test_web}, 'TestTopic' );
my $metaFromSerialised = Foswiki::Meta->new(
session => $this->session,
web => $this->test_web,
topic => 'TestTopic'
);
$metaFromSerialised->setEmbeddedStoreForm($text);

my $textAgain = $metaFromSerialised->getEmbeddedStoreForm();
@@ -126,15 +111,21 @@ sub test_SimpleMetaTopic {
sub test_SimpleTopic {
my $this = shift;

my $meta =
Foswiki::Meta->new( $this->{session}, $this->{test_web}, 'TestTopic' );
my $meta = Foswiki::Meta->new(
session => $this->session,
web => $this->test_web,
topic => 'TestTopic'
);

$meta->text("Onceler\njumped");

my $text = $meta->getEmbeddedStoreForm();

my $metaFromSerialised =
Foswiki::Meta->new( $this->{session}, $this->{test_web}, 'TestTopic' );
my $metaFromSerialised = Foswiki::Meta->new(
sesison => $this->session,
web => $this->test_web,
topic => 'TestTopic'
);
$metaFromSerialised->setEmbeddedStoreForm($text);

my $textAgain = $metaFromSerialised->getEmbeddedStoreForm();
@@ -148,8 +139,11 @@ sub test_SimpleTopic {
sub test_SimpleTopicSave {
my $this = shift;

my $meta =
Foswiki::Meta->new( $this->{session}, $this->{test_web}, 'TestTopic' );
my $meta = Foswiki::Meta->new(
session => $this->session,
web => $this->test_web,
topic => 'TestTopic'
);

$meta->text("Onceler\njumped");

@@ -158,23 +152,22 @@ sub test_SimpleTopicSave {
$meta->save();
$meta->finish();

my $rawFirst =
Foswiki::Func::readTopicText( $this->{test_web}, 'TestTopic' );
my $rawFirst = Foswiki::Func::readTopicText( $this->test_web, 'TestTopic' );

#remove the TOPICINFO
$rawFirst =~ s/^%META:TOPICINFO\{.*?\}%\n//m;

$this->assert_equals( $text, $rawFirst );

my ( $newmeta, $t ) =
Foswiki::Func::readTopic( $this->{test_web}, 'TestTopic' );
Foswiki::Func::readTopic( $this->test_web, 'TestTopic' );
$this->assert_equals( $text, $newmeta->text() );

$newmeta->save();
$newmeta->finish();

my ( $three, $t3 ) =
Foswiki::Func::readTopic( $this->{test_web}, 'TestTopic' );
Foswiki::Func::readTopic( $this->test_web, 'TestTopic' );
$this->assert_equals( $text, $three->text() );

return;
@@ -187,35 +180,33 @@ sub test_Meta_CopyAll {
my $query;

my ( $meta, $text ) =
Foswiki::Func::readTopic( $this->{test_web}, 'MergeSave' );
Foswiki::Func::readTopic( $this->test_web, 'MergeSave' );
$meta->text("Smelly\ncat");
$meta->save();
$meta->finish();

#my $rawFirst =
# Foswiki::Func::readTopicText( $this->{test_web}, 'MergeSave' );
# Foswiki::Func::readTopicText( $this->test_web, 'MergeSave' );

( $meta, $text ) =
Foswiki::Func::readTopic( $this->{test_web}, 'MergeSave' );
( $meta, $text ) = Foswiki::Func::readTopic( $this->test_web, 'MergeSave' );
$this->assert_equals( "Smelly\ncat", $text );

# A saves again, reprev triggers to create rev 1 again
$query = Unit::Request->new(
initializer => {
action => ['save'],
text => ["Sweaty\ncat"],
topic => [ $this->{test_web} . '.MergeSave' ]
topic => [ $this->test_web . '.MergeSave' ]
}
);
$this->createNewFoswikiSession( $this->{test_user_login}, $query );
$this->createNewFoswikiSession( $this->test_user_login, $query );
my $UI_FN ||= $this->getUIFn('save');
$this->captureWithKey( save => $UI_FN, $this->{session} );
$this->captureWithKey( save => $UI_FN, $this->session );

#my $rawSecond =
# Foswiki::Func::readTopicText( $this->{test_web}, 'MergeSave' );
# Foswiki::Func::readTopicText( $this->test_web, 'MergeSave' );

( $meta, $text ) =
Foswiki::Func::readTopic( $this->{test_web}, 'MergeSave' );
( $meta, $text ) = Foswiki::Func::readTopic( $this->test_web, 'MergeSave' );

# Foswiki::UI::buildNewTopic explicitly makes sure there is
# one \n at the end of each text submitted

Large diffs are not rendered by default.

Large diffs are not rendered by default.

@@ -51,6 +51,8 @@ use Foswiki::Configure::Load ();
use Scalar::Util ();
use Foswiki::Exception;

#use Foswiki::Store::PlainFile ();

# Item13331 - use CGI::ENCODE_ENTITIES introduced in CGI>=4.14 to restrict encoding
# in CGI's html rendering code to only these; note that CGI's default values
# still breaks some unicode byte strings
@@ -320,8 +322,9 @@ has store => (
has _baseStoreClass => (
is => 'rw',
clearer => 1,
default => 'Foswiki::Store::PlainFile',
isa => sub {

#default => 'Foswiki::Store::PlainFile',
isa => sub {
ASSERT( defined( $_[0] ), "Foswiki::_baseStoreClass cannot be undef" );
},
);
@@ -1134,8 +1137,6 @@ sub BUILD {
# are being processed.
$Foswiki::Plugins::SESSION = $this;

# SMELL XXX Test to avoid circular dependencies. Dangerous!
Scalar::Util::weaken($Foswiki::Plugins::SESSION);
ASSERT( $Foswiki::Plugins::SESSION->isa('Foswiki') ) if DEBUG;

# construct the store object
@@ -2368,7 +2369,7 @@ See http://blog.fox.geek.nz/2010/11/searching-design-spec-for-ultimate.html for
=cut

sub load_package {
sub _package_loaded {
my $fullname = shift;

# See if package is already defined in the main symbol table.
@@ -2377,7 +2378,13 @@ sub load_package {
no strict 'refs';
my $pkgLoaded = defined $namePref->{"${nameSuff}::"};
use strict 'refs';
return if $pkgLoaded;
return $pkgLoaded;
}

sub load_package {
my $fullname = shift;

return if _package_loaded($fullname);

my $filename = File::Spec->catfile( split /::/, $fullname ) . '.pm';
#
@@ -149,7 +149,9 @@ our $CHANGES_SUMMARY_PLAINTRUNC = 70;
has session => (
is => 'ro',
clearer => 1,
isa => Foswiki::Object::isaCLASS( 'session', 'Foswiki', noUndef => 1 ),

#weak_ref => 1,
isa => Foswiki::Object::isaCLASS( 'session', 'Foswiki', noUndef => 1 ),
);
has web => (
is => 'rw',
@@ -149,7 +149,7 @@ sub buildNewTopic {
$text = '' if $query->param('newtopic'); # created by edit
$topicObject->text($text);

foreach my $k ( keys %$ttom ) {
foreach my $k ( keys %{ $ttom->metaData } ) {

# Skip internal fields and TOPICINFO, TOPICMOVED
unless ( $k =~ m/^(_|TOPIC)/ ) {
@@ -158,7 +158,7 @@ sub buildNewTopic {

# attachments to be copied later
if ( $k eq 'FILEATTACHMENT' ) {
foreach my $a ( @{ $ttom->{$k} } ) {
foreach my $a ( @{ $ttom->metaData->{$k} } ) {
push(
@attachments,
{