/*************************************************************************
 * @author Ali Echihabi (ali_echihabi@ieee.org, ali.echihabi@souss.ca)
 *
 * Plugin for PHP unit Testing.
 * www.phpeclipse.de
 * 
 *************************************************************************/

package net.sourceforge.phpeclipse.phpunit.testpool;

public class TestCase {

	public static final String PASS = "PASS";

	public static final String FAIL = "FAIL";

	public static final String ERROR = "ERROR";

	private TestSuite parentSuite;

	private String testName;

	private String testID;

	private String verdict;

	private String parentTestSuiteName;

	/**
	 * @param testName
	 * @param testID
	 */
	public TestCase(String testID, String testName, String parentTestSuiteName) {

		this.testName = testName;
		this.testID = testID;
		this.parentTestSuiteName = parentTestSuiteName;
	}

	/**
	 * @return
	 */
	public String getTestID() {
		return testID;
	}

	/**
	 * @return
	 */
	public String getTestName() {
		return testName;
	}

	/**
	 * @return
	 */
	public String getVerdict() {
		return verdict;
	}

	/**
	 * @param string
	 */
	public void setTestID(String string) {
		testID = string;

	}

	/**
	 * @param string
	 */
	public void setTestName(String string) {
		testName = string;
	}

	/**
	 * @param string
	 */
	public void setVerdict(String string) {
		verdict = string;

		if (isFailure())
			parentSuite.setHasFailure();
		if (isError())
			parentSuite.setHasError();

	}

	/**
	 * @param suite
	 */
	public void setParentSuite(TestSuite suite) {
		this.parentSuite = suite;
		suite.setName(parentTestSuiteName);

	}

	/**
	 * @return
	 */
	public Object getParentSuite() {

		return parentSuite;
	}

	/**
	 * @return
	 */
	public boolean isError() {

		return getVerdict().equals(TestCase.ERROR);
	}

	/**
	 * @return
	 */
	public boolean isFailure() {

		return getVerdict().equals(TestCase.FAIL);

	}

	/**
	 * @return
	 */
	public boolean isPass() {

		return getVerdict().equals(TestCase.PASS);

	}

}