<?php

require_once dirname(__FILE__) . '/../../../../../Tests/config.php';

/**
 * Test class for Syntaxer.
 * Generated by PHPUnit on 2011-02-25 at 09:21:58.
 */
class SyntaxerTest extends PHPUnit_Framework_TestCase {

	/**
	 * @var Syntaxer
	 */
	public $object;

	/**
	 * Sets up the fixture, for example, opens a network connection.
	 * This method is called before a test is executed.
	 */
	protected function setUp() {
		$this->setIdiom();
	}

	/**
	 * Tears down the fixture, for example, closes a network connection.
	 * This method is called after a test is executed.
	 */
	protected function tearDown() {
	}

	public function setIdiom($idiom='en')
	{
		Mind::$currentProject['idiom']= $idiom;
		Mind::$langPath= dirname(__FILE__) . '/../../../../../mind3rd/API/languages/';
		require_once dirname(__FILE__) . '/../../../../../mind3rd/API/languages/'.$idiom.'/IgnoreForms.php';
		require_once dirname(__FILE__) . '/../../../../../mind3rd/API/languages/'.$idiom.'/Verbalizer.php';
		Tokenizer::loadModifiers(dirname(__FILE__) . '/../../../../../mind3rd/API/languages/'.$idiom.'/');
		Mind::$tokenizer= new Tokenizer;
		Mind::$lexer= new Lexer;
		$this->object = new Syntaxer();
	}
	
	public function testSweepWords1() {
		$this->setIdiom();
		Mind::$tokenizer->sweep(Array('child', 'of', 'heart', 'has', 'parent', 'of', 'family'));
		
		$this->object->sweep();
		
		$this->assertEquals(Tokenizer::$words,
						   Array(
								'child_heart',
								'has',
								'parent_family',
						   )
						 );
	}
	
	public function testSweepWords2() {
		Mind::$tokenizer->sweep(Array('child',
									  'of',
									  'heart',
									  'and',
									  'friend',
									  'of',
									  'child',
									  'of',
									  'heart',
									  'has',
									  'parent',
									  'of',
									  'family'));
		$this->object->sweep();
		$this->assertEquals(Tokenizer::$words,
						   Array(
									'child_heart',
									',',
									'friend_child_heart',
									'has',
    								'parent_family'
						   )
						 );
	}
	public function testSweepWords3() {
		Mind::$tokenizer->sweep(Array('child',
									  'of',
									  'heart',
									  ',',
									  'friend',
									  'of',
									  'kid',
									  'of',
									  'heart',
									  'has',
									  'parent',
									  'of',
									  'family'));
		$this->object->sweep();
		$this->assertEquals(Tokenizer::$words,
						   Array(
									'child_heart',
									',',
									'friend_kid_heart',
									'has',
    								'parent_family'
						   )
						 );
	}
	public function testSweepWords4() {
		Mind::$tokenizer->sweep(Array('child',
									  'of',
									  'heart',
									  ',',
									  'friend',
									  'of',
									  'kid',
									  'of',
									  'heart',
									  'has',
									  'parent',
									  'of',
									  'family',
									  ',',
									  'mother',
									  'of',
									  'parent'));
		$this->object->sweep();
		$this->assertEquals(Tokenizer::$words,
						   Array(
									'child_heart',
									',',
									'friend_kid_heart',
									'has',
    								'parent_family',
									',',
									'mother_parent'
						   )
						 );
	}	
	
	public function testSweepWords5() {
		Mind::$tokenizer->sweep(Array('child',
									  'has',
									  'parent'
									  ));
		$this->object->sweep();
		$this->assertEquals(Tokenizer::$words,
						   Array(
									'child',
									'has',
    								'parent'
						   )
						 );
	}
	
	public function testSweepWords6() {
		Mind::$tokenizer->sweep(Array('child',
									  'of',
									  'heart',
									  ',',
									  'friend',
									  'of',
									  'kid',
									  'of',
									  'heart',
									  'has',
									  'name of origin:varchar(250)',
									  ',',
									  'age:int()'));
		$this->object->sweep();
		$this->assertEquals(Tokenizer::$words,
						   Array(
									'child_heart',
									',',
									'friend_kid_heart',
									'has',
    								'name of origin:varchar(250)',
									',',
									'age:int()'
						   )
						 );
	}
	public function testSweepWords7() {
		Mind::$tokenizer->sweep(Array('child',
									  ',',
									  'friend',
									  'has',
									  'name of origin:varchar(250)',
									  ',',
									  'age:int()'));
		$this->object->sweep();
		$this->assertEquals(Tokenizer::$words,
						   Array(
									'child',
									',',
									'friend',
									'has',
    								'name of origin:varchar(250)',
									',',
									'age:int()'
						   )
						 );
	}
	public function testSweepWords8() {
		Mind::$tokenizer->sweep(Array('child',
									  'has',
									  'name of origin:varchar(250)',
									  ',',
									  'age:int()'));
		$this->object->sweep();
		$this->assertEquals(Tokenizer::$words,
						   Array(
									'child',
									'has',
    								'name of origin:varchar(250)',
									',',
									'age:int()'
						   )
						 );
	}
}