I'm slowly becoming more familiar with the Bricolage codebase, and have
started to produce some minor patches. I'm at the point where these
patches should really have their own tests, but I have hit a snag.
How do I write tests that cover the multiple possible values of
configuration directives which are assigned to constants in Bric::Config?
I've noticed that Bric::Biz::Asset::Business::Media::Image::DevTest
skips "test_alternate_thumb" if USE_THUMBNAILS is disabled. Another
test module branches depending on the value of QUEUE_PUBLISH_JOBS.
If I want to test the result of `find_or_create_alternate()` with
MEDIA_UNIQUE_FILENAME enabled and then disabled, how can I do that?
I could write a test that checks the config setting, and runs the
appropriate test. But to run both tests would require manually changing
the configuration setting, and re-running the test.
I've experimented with redefining constants, but that didn't work out
well - they are constants after all.
I have also experimented with using AUTOLOAD to create a getter method
for the config variables instead (see attached MyApp example). This
allows me to temporarily redefine the sub on-the-fly so that it returns
the value I want. This works, but would ultimately require all the
config constants to be replaced with calls to their getter method.
Is there a good way to write this type of test?
Regards,
Mike
started to produce some minor patches. I'm at the point where these
patches should really have their own tests, but I have hit a snag.
How do I write tests that cover the multiple possible values of
configuration directives which are assigned to constants in Bric::Config?
I've noticed that Bric::Biz::Asset::Business::Media::Image::DevTest
skips "test_alternate_thumb" if USE_THUMBNAILS is disabled. Another
test module branches depending on the value of QUEUE_PUBLISH_JOBS.
If I want to test the result of `find_or_create_alternate()` with
MEDIA_UNIQUE_FILENAME enabled and then disabled, how can I do that?
I could write a test that checks the config setting, and runs the
appropriate test. But to run both tests would require manually changing
the configuration setting, and re-running the test.
I've experimented with redefining constants, but that didn't work out
well - they are constants after all.
I have also experimented with using AUTOLOAD to create a getter method
for the config variables instead (see attached MyApp example). This
allows me to temporarily redefine the sub on-the-fly so that it returns
the value I want. This works, but would ultimately require all the
config constants to be replaced with calls to their getter method.
Is there a good way to write this type of test?
Regards,
Mike