require('src/apache_conf_file') require('test/unit') class ApacheConfFileTest < Test::Unit::TestCase def test_bad_conf_file_path_raises_error assert_raise(ArgumentError) do acf = ApacheConfFile.new(nil) end assert_raise(ArgumentError) do acf = ApacheConfFile.new('/does/not/exist') end assert_raise(ArgumentError) do # This raises a "different" error than the one above, # but quit giving me empty files! acf = ApacheConfFile.new('test/fixtures/empty_file.txt') end end def test_good_conf_file_loads acf = ApacheConfFile.new('test/fixtures/example.com-boring.conf') # That's all.. end def test_conf_file_with_no_directives acf = ApacheConfFile.new('test/fixtures/example.com-boring.conf') temp_files = acf.get_php_temporary_directory_list() assert_kind_of(Array, temp_files) assert_equal(0, temp_files.length) end def test_get_php_temporary_dirs_non_unique acf = ApacheConfFile.new('test/fixtures/example.com-typical.conf') # There should be two (identical) directories. temp_files = acf.get_php_temporary_directory_list(false) assert_equal(2, temp_files.length) assert_equal(temp_files[0], temp_files[1]) end def test_get_php_temporary_dirs_unique acf = ApacheConfFile.new('test/fixtures/example.com-typical.conf') # There should be just one directory, since the # upload_tmp and session.save paths are identical. temp_files = acf.get_php_temporary_directory_list() assert_equal(1, temp_files.length) assert_not_equal(0, temp_files[0].length) end def test_get_php_temporary_dirs_different_unique acf = ApacheConfFile.new('test/fixtures/example.com-different.conf') temp_files = acf.get_php_temporary_directory_list() assert_equal(2, temp_files.length) assert_not_equal(temp_files[0], temp_files[1]) end def test_get_php_temporary_dirs_multi_unique # Two different vhosts (one SSL), both configured # with the same two (different) tmp directories. acf = ApacheConfFile.new('test/fixtures/example.com-multi.conf') temp_files = acf.get_php_temporary_directory_list() assert_equal(2, temp_files.length) assert_not_equal(temp_files[0], temp_files[1]) end def test_get_php_temporary_dirs_multi_non_unique # Two different vhosts (one SSL), both configured # with the same two (different) tmp directories. acf = ApacheConfFile.new('test/fixtures/example.com-multi.conf') temp_files = acf.get_php_temporary_directory_list(false) assert_equal(4, temp_files.length) end end