From 12ebaa7cd5f201cd28d35d425a45300d2ac63f6d Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Wed, 31 May 2023 12:12:34 +0000 Subject: [PATCH] Bug 33870: Fix indentation in subtest Test plan: git diff -w HEAD~1.. t/db_dependent/Sitemapper.t Signed-off-by: Marcel de Rooy Signed-off-by: Pedro Amorim --- t/db_dependent/Sitemapper.t | 198 ++++++++++++++++++------------------ 1 file changed, 99 insertions(+), 99 deletions(-) diff --git a/t/db_dependent/Sitemapper.t b/t/db_dependent/Sitemapper.t index d1b36f1f72..f62c71fbe1 100755 --- a/t/db_dependent/Sitemapper.t +++ b/t/db_dependent/Sitemapper.t @@ -42,33 +42,33 @@ $schema->storage->txn_begin; subtest 'Sitemapper' => sub { plan tests => 12; -my $now = dt_from_string()->ymd; - -# FIXME Would be nice to remove both deletes again -Koha::Checkouts->delete; -Koha::Biblios->delete; -my $biblio1 = $builder->build_sample_biblio; -$biblio1->set({ datecreated => '2013-11-15', timestamp => '2013-11-15' })->store; -my $id1 = $biblio1->id; -my $biblio2 = $builder->build_sample_biblio; -$biblio2->set({ datecreated => '2015-08-31', timestamp => '2015-08-31' })->store; -my $id2 = $biblio2->id; - -my $dir = C4::Context::temporary_directory; - -# Create a sitemap for a catalog containg 2 biblios, with option 'long url' -my $sitemapper = Koha::Sitemapper->new( - verbose => 0, - url => 'http://www.mylibrary.org', - dir => $dir, - short => 0, -); -$sitemapper->run(); - -my $file = "$dir/sitemapindex.xml"; -ok( -e "$dir/sitemapindex.xml", 'File sitemapindex.xml created' ); -my $file_content = read_file($file); -my $expected_content = <<"EOS"; + my $now = dt_from_string()->ymd; + + # FIXME Would be nice to remove both deletes again + Koha::Checkouts->delete; + Koha::Biblios->delete; + my $biblio1 = $builder->build_sample_biblio; + $biblio1->set({ datecreated => '2013-11-15', timestamp => '2013-11-15' })->store; + my $id1 = $biblio1->id; + my $biblio2 = $builder->build_sample_biblio; + $biblio2->set({ datecreated => '2015-08-31', timestamp => '2015-08-31' })->store; + my $id2 = $biblio2->id; + + my $dir = C4::Context::temporary_directory; + + # Create a sitemap for a catalog containg 2 biblios, with option 'long url' + my $sitemapper = Koha::Sitemapper->new( + verbose => 0, + url => 'http://www.mylibrary.org', + dir => $dir, + short => 0, + ); + $sitemapper->run(); + + my $file = "$dir/sitemapindex.xml"; + ok( -e "$dir/sitemapindex.xml", 'File sitemapindex.xml created' ); + my $file_content = read_file($file); + my $expected_content = <<"EOS"; @@ -78,13 +78,13 @@ my $expected_content = <<"EOS"; EOS -chop $expected_content; -is( $file_content, $expected_content, 'Its content is valid' ); + chop $expected_content; + is( $file_content, $expected_content, 'Its content is valid' ); -$file = "$dir/sitemap0001.xml"; -ok( -e $file, 'File sitemap0001.xml created' ); -$file_content = read_file($file); -$expected_content = <<"EOS"; + $file = "$dir/sitemap0001.xml"; + ok( -e $file, 'File sitemap0001.xml created' ); + $file_content = read_file($file); + $expected_content = <<"EOS"; @@ -98,22 +98,22 @@ $expected_content = <<"EOS"; EOS -is( $file_content, $expected_content, 'Its content is valid' ); - -# Create a sitemap for a catalog containg 2 biblios, with option 'short url'. -# Test that 2 files are created. -$sitemapper = Koha::Sitemapper->new( - verbose => 0, - url => 'http://www.mylibrary.org', - dir => $dir, - short => 1, -); -$sitemapper->run(); - -$file = "$dir/sitemap0001.xml"; -ok( -e $file, 'File sitemap0001.xml with short URLs created' ); -$file_content = read_file($file); -$expected_content = <<"EOS"; + is( $file_content, $expected_content, 'Its content is valid' ); + + # Create a sitemap for a catalog containg 2 biblios, with option 'short url'. + # Test that 2 files are created. + $sitemapper = Koha::Sitemapper->new( + verbose => 0, + url => 'http://www.mylibrary.org', + dir => $dir, + short => 1, + ); + $sitemapper->run(); + + $file = "$dir/sitemap0001.xml"; + ok( -e $file, 'File sitemap0001.xml with short URLs created' ); + $file_content = read_file($file); + $expected_content = <<"EOS"; @@ -127,27 +127,27 @@ $expected_content = <<"EOS"; EOS -is( $file_content, $expected_content, 'Its content is valid' ); - -# No need to create 75000 biblios here. Let's create 10 with $MAX == 6. -# Expecting 3 files: index plus 2 url files with 6 and 4 urls. -$Koha::Sitemapper::Writer::MAX = 6; -for my $count ( 3..10 ) { - my $biblio2 = $builder->build_sample_biblio->set({ datecreated => '2015-08-31', timestamp => '2015-08-31' })->store; -} - -$sitemapper = Koha::Sitemapper->new( - verbose => 0, - url => 'http://www.mylibrary.org', - dir => $dir, - short => 1, -); -$sitemapper->run(); - -$file = "$dir/sitemapindex.xml"; -ok( -e "$dir/sitemapindex.xml", 'File sitemapindex.xml for 10 bibs created' ); -$file_content = read_file($file); -$expected_content = <<"EOS"; + is( $file_content, $expected_content, 'Its content is valid' ); + + # No need to create 75000 biblios here. Let's create 10 with $MAX == 6. + # Expecting 3 files: index plus 2 url files with 6 and 4 urls. + $Koha::Sitemapper::Writer::MAX = 6; + for my $count ( 3..10 ) { + my $biblio2 = $builder->build_sample_biblio->set({ datecreated => '2015-08-31', timestamp => '2015-08-31' })->store; + } + + $sitemapper = Koha::Sitemapper->new( + verbose => 0, + url => 'http://www.mylibrary.org', + dir => $dir, + short => 1, + ); + $sitemapper->run(); + + $file = "$dir/sitemapindex.xml"; + ok( -e "$dir/sitemapindex.xml", 'File sitemapindex.xml for 10 bibs created' ); + $file_content = read_file($file); + $expected_content = <<"EOS"; @@ -161,34 +161,34 @@ $expected_content = <<"EOS"; EOS -chop $expected_content; -is( $file_content, $expected_content, 'Its content is valid' ); - -$file = "$dir/sitemap0001.xml"; -ok( -e $file, 'File sitemap0001.xml created' ); - -open my $fh, '<', $file or croak; -my $count = 0; -while (<$fh>) { - if ( $_ =~ //xsm ) { $count++; } -} -close $fh; -is( $count, 6, 'It contains 6 URLs' ); - -$file = "$dir/sitemap0002.xml"; -ok( -e $file, 'File sitemap0002.xml created' ); - -open $fh, '<', $file or croak; -$count = 0; -while (<$fh>) { - if ( $_ =~ //xsm ) { $count++; } -} -close $fh; -is( $count, 4, 'It contains 4 URLs' ); - -# Cleanup -for my $file (qw/sitemapindex.xml sitemap0001.xml sitemap0002.xml/) { - unlink "$dir/$file"; -} + chop $expected_content; + is( $file_content, $expected_content, 'Its content is valid' ); + + $file = "$dir/sitemap0001.xml"; + ok( -e $file, 'File sitemap0001.xml created' ); + + open my $fh, '<', $file or croak; + my $count = 0; + while (<$fh>) { + if ( $_ =~ //xsm ) { $count++; } + } + close $fh; + is( $count, 6, 'It contains 6 URLs' ); + + $file = "$dir/sitemap0002.xml"; + ok( -e $file, 'File sitemap0002.xml created' ); + + open $fh, '<', $file or croak; + $count = 0; + while (<$fh>) { + if ( $_ =~ //xsm ) { $count++; } + } + close $fh; + is( $count, 4, 'It contains 4 URLs' ); + + # Cleanup + for my $file (qw/sitemapindex.xml sitemap0001.xml sitemap0002.xml/) { + unlink "$dir/$file"; + } }; $schema->storage->txn_rollback; -- 2.30.2