diff --git a/lib/Business/SiteCatalyst/Company.pm b/lib/Business/SiteCatalyst/Company.pm index 5af93b4..a490db0 100644 --- a/lib/Business/SiteCatalyst/Company.pm +++ b/lib/Business/SiteCatalyst/Company.pm @@ -215,8 +215,6 @@ sub get_report_suites =head2 get_tracking_server() Returns the tracking server and namespace for the specified report suite. -If report suite is not specified, 'report_suite_id' in SiteCatalystConfig -(if one exists) will be used. my $tracking_server = $company->get_tracking_server(); my $tracking_server = $company->get_tracking_server( @@ -239,21 +237,9 @@ sub get_tracking_server { my ( $self, %args ) = @_; - # If report suite was not specified as an argument, try to use value from config if ( !defined $args{'report_suite_id'} || $args{'report_suite_id'} eq '' ) { - require SiteCatalystConfig; - my $config = SiteCatalystConfig->new(); - - if ( defined( $config ) && $config->{'report_suite_id'} ne '' ) - { - $args{'report_suite_id'} = $config->{'report_suite_id'}; - } - else - { - croak "Argument 'report_suite_id' is required because 'report_suite_id' is not specified in SiteCatalystConfig.pm" - if !defined( $args{'report_suite_id'} ) || ( $args{'report_suite_id'} eq '' ); - } + croak "Argument 'report_suite_id' is required"; } my $site_catalyst = $self->get_site_catalyst(); diff --git a/t/01-local_config.t b/t/01-local_config.t index 389eabd..8e35a73 100644 --- a/t/01-local_config.t +++ b/t/01-local_config.t @@ -11,7 +11,7 @@ use Business::SiteCatalyst::Report; eval 'use SiteCatalystConfig'; $@ ? plan( skip_all => 'Local connection information for Adobe SiteCatalyst required to run tests.' ) - : plan( tests => 3 ); + : plan( tests => 2 ); my $config = SiteCatalystConfig->new(); @@ -27,10 +27,3 @@ like( 'The shared_secret is defined.', ); -like( - $config->{'report_suite_id'}, - qr/\w/, - 'The report_suite_id is defined.', -); - - diff --git a/t/Company/30-get_report_suites.t b/t/Company/30-get_report_suites.t index 32218fc..9761fd5 100644 --- a/t/Company/30-get_report_suites.t +++ b/t/Company/30-get_report_suites.t @@ -13,7 +13,7 @@ use Business::SiteCatalyst; eval 'use SiteCatalystConfig'; $@ ? plan( skip_all => 'Local connection information for Adobe SiteCatalyst required to run tests.' ) - : plan( tests => 4 ); + : plan( tests => 6 ); my $config = SiteCatalystConfig->new(); @@ -25,7 +25,7 @@ ok( ); ok( - defined( + defined( my $company = $site_catalyst->instantiate_company() ), 'Instantiate a new Business::SiteCatalyst::Company.', @@ -44,3 +44,21 @@ ok( 'Retrieve response.', ) || diag( explain( $response ) ); + +if ( scalar( $response ) > 0 ) +{ + + # Store first item, if anything was returned, into file for use in other tests + ok( + open( FILE, '>', 'business-sitecatalyst-report-report_suite_id.tmp'), + 'Open temp file to store first report suite id for use in other tests' + ); + + print FILE $response->[0]->{'rsid'}; + + ok( + close FILE, + 'Close temp file' + ); + +} diff --git a/t/Company/40-get_tracking_server.t b/t/Company/40-get_tracking_server.t index 05c370a..79ed0e3 100644 --- a/t/Company/40-get_tracking_server.t +++ b/t/Company/40-get_tracking_server.t @@ -13,7 +13,7 @@ use Business::SiteCatalyst; eval 'use SiteCatalystConfig'; $@ ? plan( skip_all => 'Local connection information for Adobe SiteCatalyst required to run tests.' ) - : plan( tests => 6 ); + : plan( tests => 8 ); my $config = SiteCatalystConfig->new(); @@ -32,27 +32,43 @@ ok( ); my $response; + +throws_ok( + sub + { + $response = $company->get_tracking_server( report_suite_id => '' ); + }, + qr/Argument 'report_suite_id' is required/, + 'Request tracking server - empty "report_suite_id"' +); + ok( - defined( - $response = $company->get_tracking_server( report_suite => $config->{'report_suite_id'} ) - ), - 'Request tracking server - report suite specified.', + open( FILE, 'business-sitecatalyst-report-report_suite_id.tmp'), + 'Open temp file to read report suite id' ); +my $report_suite_id; + ok( - Data::Validate::Type::is_string( $response, allow_empty => 0 ), - 'Retrieve tracking server - report suite specified.', -) || diag( explain( $response ) ); + $report_suite_id = do { local $/; }, + 'Read in report suite id' +); + +ok( + close FILE, + 'Close temp file' +); + ok( defined( - $response = $company->get_tracking_server() + $response = $company->get_tracking_server( report_suite_id => $report_suite_id ) ), - 'Request tracking server - report suite not specified.', + 'Request tracking server - report_suite_id specified.', ); ok( Data::Validate::Type::is_string( $response, allow_empty => 0 ), - 'Retrieve tracking server - report suite not specified.', + 'Retrieve tracking server - report_suite_id specified.', ) || diag( explain( $response ) ); diff --git a/t/Report/20-queue.t b/t/Report/20-queue.t index 9263567..a886492 100644 --- a/t/Report/20-queue.t +++ b/t/Report/20-queue.t @@ -13,7 +13,7 @@ use Business::SiteCatalyst; eval 'use SiteCatalystConfig'; $@ ? plan( skip_all => 'Local connection information for Adobe SiteCatalyst required to run tests.' ) - : plan( tests => 8 ); + : plan( tests => 11 ); my $config = SiteCatalystConfig->new(); @@ -25,11 +25,30 @@ ok( ); ok( - defined( + open( FILE, 'business-sitecatalyst-report-report_suite_id.tmp'), + 'Open temp file to read report suite id' +); + +my $report_suite_id; + +ok( + $report_suite_id = do { local $/; }, + 'Read in report suite id' +); + +ok( + close FILE, + 'Close temp file' +); + + + +ok( + defined( my $report = $site_catalyst->instantiate_report( type => 'Ranked', - report_suite_id => $config->{'report_suite_id'} - ) + report_suite_id => $report_suite_id + ) ), 'Instantiate a new Business::SiteCatalyst::Report.', );