#!/usr/bin/env ruby
# $Id: tc_ext_siteconfig.rb,v 1.2 2004/05/10 06:41:33 eto Exp $
# Copyright (C) 2003-2004 Kouichirou Eto, All rights reserved.
# This is free software with ABSOLUTELY NO WARRANTY.
# You can redistribute it and/or modify it under the terms of the GNU GPL2.

require 'test_common'

class TC_SiteConfig < Test::Unit::TestCase
  include TestSite

  def test_siteconfig
    # test_open
    assert_equal(false, @site.is_open?)
    page = @site.create('SiteConfig')
    page.store(":open:true")
    assert_equal(true, @site.is_open?)
    page.store(":open:false")
    assert_equal(false, @site.is_open?)
    @site.delete('SiteConfig')
    assert_equal(false, @site.is_open?)

    # test_theme
    assert_instance_of(String, @site.siteconfig["theme"])
    page.store(":theme:qwik")

    # test_sitename
    assert_equal('qwik.jp', @site.siteconfig["sitename"])
    assert_equal('qwik.jp/test', @site.title)
    page.store(":sitename:TestSite")
    assert_equal('TestSite', @site.siteconfig["sitename"])
    assert_equal('TestSite', @site.title)

    # test_title
    page = @site.create('TestPage')
    assert_equal('TestPage', page.get_title)
    assert_equal('TestPage - TestSite', @site.title('TestPage'))

    page = @site.create('1')
    assert_equal('1', page.get_title)
    assert_equal('1 - TestSite', @site.title('1'))
    page.store("* TestTitle")
    assert_equal('TestTitle - TestSite', @site.title('1'))

    # test_url
    assert_equal('http://qwik.jp/', @site.domainurl)
    assert_equal('http://qwik.jp/test/', @site.url)
    assert_equal('http://qwik.jp/test/1.html', @site.url('1'))
    assert_equal('test@qwik.jp', @site.ml)
  end
end
