|
| 1 | +use strict; |
| 2 | +use warnings; |
| 3 | +use FindBin; |
| 4 | +use Cwd; |
| 5 | + |
| 6 | +use lib Cwd::realpath("./t/lib"), "$FindBin::Bin/lib"; |
| 7 | +use Test::More; |
| 8 | +use Test::Deep; |
| 9 | +use File::Spec; |
| 10 | +use File::Temp qw( tempdir ); |
| 11 | +use MT::Test::Env; |
| 12 | + |
| 13 | +our $test_env; |
| 14 | +our $profiler_path; |
| 15 | + |
| 16 | +BEGIN { |
| 17 | + $profiler_path = tempdir( CLEANUP => 1 ); |
| 18 | + $test_env = MT::Test::Env->new( |
| 19 | + PerformanceProfilerPath => $profiler_path, |
| 20 | + PerformanceProfilerFrequency => 0, |
| 21 | + PluginPath => [ Cwd::realpath("$FindBin::Bin/../../../addons") ], |
| 22 | + ); |
| 23 | + |
| 24 | + $ENV{MT_APP} = 'MT::App::CMS'; |
| 25 | + $ENV{MT_CONFIG} = $test_env->config_file; |
| 26 | +} |
| 27 | + |
| 28 | +use MT; |
| 29 | +use MT::Test; |
| 30 | +use MT::Test::Fixture; |
| 31 | +use MT::Test::Permission; |
| 32 | +use MT::Association; |
| 33 | + |
| 34 | +MT::Test->init_app; |
| 35 | + |
| 36 | +$test_env->prepare_fixture('db'); |
| 37 | + |
| 38 | +my $blog1_name = 'PerformanceProfiler-' . time(); |
| 39 | +my $super = 'super'; |
| 40 | + |
| 41 | +my $objs = MT::Test::Fixture->prepare( |
| 42 | + { author => [ { 'name' => $super }, ], |
| 43 | + blog => [ { name => $blog1_name, }, ], |
| 44 | + entry => [ |
| 45 | + map { |
| 46 | + my $name = 'PerformanceProfilerEntry-' . $_ . time(); |
| 47 | + +{ basename => $name, |
| 48 | + title => $name, |
| 49 | + author => $super, |
| 50 | + status => 'publish', |
| 51 | + authored_on => '20190703121110', |
| 52 | + }, |
| 53 | + } ( 1 .. 10 ) |
| 54 | + ], |
| 55 | + } |
| 56 | +); |
| 57 | + |
| 58 | +my $blog1 = MT->model('blog')->load( { name => $blog1_name } ) or die; |
| 59 | + |
| 60 | +MT->instance->rebuild_indexes( Blog => $blog1 ); |
| 61 | +my @profiles_for_index = glob( File::Spec->catfile( $profiler_path, '*' ) ); |
| 62 | +is scalar(@profiles_for_index), 0; |
| 63 | + |
| 64 | +done_testing; |
0 commit comments