Sha256: 012ef479f131aec81fc54a0d9d6c54197b2ecb20689550b40ff05c722a2d67b2

Contents?: true

Size: 1.44 KB

Versions: 1

Compression:

Stored size: 1.44 KB

Contents

require File.dirname(__FILE__) + '/../test_helper.rb'

# NOT TESTED:
# add_sigint_handler
# notify
# reset
# run

class TestAutotestforphp < Test::Unit::TestCase

  def setup
    @atp = Autotestforphp.new
  end

  def teardown
    File.delete(File.dirname(__FILE__) + '/sample.php') if File.exist?(File.dirname(__FILE__) + '/sample.php')
    File.delete(File.dirname(__FILE__) + '/sample2.php') if File.exist?(File.dirname(__FILE__) + '/sample2.php')
  end

  def test_detect_file_change
    create_file('sample.php')
    create_file('sample2.php')
    
    @atp.watch(File.dirname(__FILE__) + '/sample*')
    assert !@atp.files_have_changed

    sleep 1
    touch_file('sample2.php')

    assert @atp.files_have_changed
    @atp.last_mtime = Time.now

    sleep 1
    assert !@atp.files_have_changed
  end

  def test_make_test_cmd_linux
    @atp.class.const_set :RUBY_PLATFORM, 'linux'
    assert_equal "phpunit --configuration \"#{@atp.phpunit_config_file_path}\"", @atp.make_test_cmd
  end

  def test_make_test_cmd_windows
    @atp.class.const_set :RUBY_PLATFORM, 'mswin'
    assert_equal "phpunit.bat --configuration \"#{@atp.phpunit_config_file_path}\"", @atp.make_test_cmd
  end

#  def test_make_test_cmd_mac
#
#  end

private
  def create_file(file_name)
    File.new("#{File.dirname(__FILE__)}/#{file_name}", 'w').close
  end
  def touch_file(file_name)
    File.open("#{File.dirname(__FILE__)}/#{file_name}", 'w') do |f|
      f.puts 'test'
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fgrehm-autotestforphp-0.0.1 test/autotestforphp/test_autotestforphp.rb