<commit_before><?php

/**
 *
 * Test case for the tag_object class
 * 
 * @package alpha::tests
 * @author <NAME> <<EMAIL>>
 * @copyright 2009 <NAME>
 * @version $Id$ 
 * 
 */
class Tag_Test extends PHPUnit_Framework_TestCase {
	/**
	 * An article_object for testing
	 * 
	 * @var article_object
	 */
	private $article;
	
	/**
     * called before the test functions will be executed
     * this function is defined in PHPUnit_TestCase and overwritten
     * here
     */
    protected function setUp() {
    	DAO::begin();
    	$this->article = $this->createArticleObject('unitTestArticle');
        // just making sure no previous test article is in the DB
        $this->article->deleteAllByAttribute('title', 'unitTestArticle');        
    }
    
    /** 
     * called after the test functions are executed
     * this function is defined in PHPUnit_TestCase and overwritten
     * here
     */    
    protected function tearDown() {
    	DAO::rollback();    	
        unset($this->article);
    }
    
    /**
     * creates an article object for testing
     * 
     * @return article_object
     */
    private function createArticleObject($name) {
    	$article = new article_object();
        $article->set('title', $name);
        $article->set('description', 'A test article called unitTestArticle with some stop words and the unitTestArticle title twice');        
        $article->set('keywords', 'blah');
        $article->set('author', 'blah');
        $article->set('content', 'blah');        
        
        return $article;
    }
    
    /**
     * Testing the tag_object::tokenize method returns a tag called "unittestarticle"
     */
    public function testTokenizeForExpectedTag() {
    	$tags = tag_object::tokenize($this->article->get('description'), 'article_object', $this->article->getOID());
    	
    	$found = false;
    	foreach($tags as $tag) {
    		if($tag->get('content') == 'unittestarticle') {
    			$found = true;
    			break;
    		}
    	}
    	$this->assertTrue($found, 'Testing the tag_object::tokenize method returns a tag called "unittestarticle"');
    }
    
    /**
     * Testing the tag_object::tokenize method does not return a tag called "a"
     */
    public function testTokenizeForUnexpectedTag() {
    	$tags = tag_object::tokenize($this->article->get('description'), 'article_object', $this->article->getOID());
    	<commit_msg>Fixing broken setup call which was setting the keywords property on an article_object which is no longer used<commit_after><?php

/**
 *
 * Test case for the tag_object class
 * 
 * @package alpha::tests
 * @author <NAME> <<EMAIL>>
 * @copyright 2009 <NAME>
 * @version $Id$ 
 * 
 */
class Tag_Test extends PHPUnit_Framework_TestCase {
	/**
	 * An article_object for testing
	 * 
	 * @var article_object
	 */
	private $article;
	
	/**
     * called before the test functions will be executed
     * this function is defined in PHPUnit_TestCase and overwritten
     * here
     */
    protected function setUp() {
    	DAO::begin();
    	$this->article = $this->createArticleObject('unitTestArticle');
        // just making sure no previous test article is in the DB
        $this->article->deleteAllByAttribute('title', 'unitTestArticle');        
    }
    
    /** 
     * called after the test functions are executed
     * this function is defined in PHPUnit_TestCase and overwritten
     * here
     */    
    protected function tearDown() {
    	DAO::rollback();    	
        unset($this->article);
    }
    
    /**
     * creates an article object for testing
     * 
     * @return article_object
     */
    private function createArticleObject($name) {
    	$article = new article_object();
        $article->set('title', $name);
        $article->set('description', 'A test article called unitTestArticle with some stop words and the unitTestArticle title twice');
        $article->set('author', 'blah');
        $article->set('content', 'blah');        
        
        return $article;
    }
    
    /**
     * Testing the tag_object::tokenize method returns a tag called "unittestarticle"
     */
    public function testTokenizeForExpectedTag() {
    	$tags = tag_object::tokenize($this->article->get('description'), 'article_object', $this->article->getOID());
    	
    	$found = false;
    	foreach($tags as $tag) {
    		if($tag->get('content') == 'unittestarticle') {
    			$found = true;
    			break;
    		}
    	}
    	$this->assertTrue($found, 'Testing the tag_object::tokenize method returns a tag called "unittestarticle"');
    }
    
    /**
     * Testing the tag_object::tokenize method does not return a tag called "a"
     */
    public function testTokenizeForUnexpectedTag() {
    	$tags = tag_object::tokenize($this->article->get('description'), 'article_object', $this->article->getOID());
    	
{'fraction_non_alphanumeric': 0.12637021716649433, 'fraction_numerical': 0.001654601861427094, 'mean_word_length': 2.6944232238349883, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 50, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2713353', 'n_tokens_mistral': 1412, 'n_tokens_neox': 1360, 'n_words': 373}