<commit_before><?php
/**
 * Created by PhpStorm.
 * User: blue
 * Date: 2/1/17
 * Time: 3:29 PM
 * This is a change.
 */
namespace Edu\Cnm\AbqVast\Test;

use Edu\Cnm\AbqVast\{
	Criteria, Field, Share
};

// TODO: add share and field reference dependency classes (use)
//grab the project test parameters
require_once("AbqVastTest.php");

//grab the class under scrutiny
require_once(dirname(__DIR__) . "/autoload.php");

/**
 * PHPUnit test for the Criteria class.
 * @see Criteria
 * @author <NAME> <<EMAIL>>
 **/
class CriteriaTest extends AbqVastTest {
	/**
	 * content of criteriaId
	 * @var string $VALID_CRITERIAID
	 **/
	protected $VALID_CRITERIAID = null;

	/**
	 * content of criteriaFieldId
	 * @var $CRITERIAFIELDID criteriaFieldId
	 **/
	protected $VALID_CRITERIAFIELDID = null;

	/**
	 * content of criteriaShareId
	 * @var $CRITERIASHAREID criteriaShareId
	 **/
	protected $VALID_CRITERIASHAREID = null;

	/**
	 * content of criteriaOperator
	 * @var string $VALID_CRITERIAOPERATOR
	 **/
	protected $VALID_CRITERIAOPERATOR = "Pass";

	/**
	 * content of criteriaValue
	 * @var int $VALID_CRITERIAVALUE
	 **/
	protected $VALID_CRITERIAVALUE = 500;

	/**
	 * create dependent objects before running each test
	 **/
	public final function setUp() {
		//run the default setup method first
		parent::setUp();

		//create and insert foreign field
		$this->field = new Field(null, "passN", "S");
		$this->field->insert($this->getPDO());
		$this->share = new Share(null, "passShI", "passShU");
		$this->share->insert($this->getPDO());
	}

	/**
	 * test inserting a valid criteria and verify that the mySQL data matches.
	 **/
	public function testInsertValidCriteria() {
		//count the number of rows and save it for later
		$numRows = $this->getConnection()->getRowCount("criteria");

		// create a new criteria and insert into mySQL
		$criteria = new Criteria(null, $this->field->getFieldId(), $this->share->getShareId(), $this->VALID_CRITERIAOPERATOR, $this->VALID_CRITERIAVALUE);
		$criteria->insert($this->getPDO());
	// TODO: ask about why assertEquals instead of assertSame
		//grab the data from mySQL and enforce the fields match our expectations.
		$pdoCriteria = Criteria::getCriteriaIdByCriteriaId($this->getPDO(), $criteria->getCriteriaId());
		$this->assertEquals($numRows + 1, $this->getConnection()->getRowCount("criteria"));
		$this->assertEquals($pdoCriteria->getCriteriaId(), $this->VALID_CRITERIAID);
		$this->assertEquals($pdoCriteria->getCriteriaFieldId(), $this->field->getFieldId());
		$this->assertEquals($pdoCriteria->getCriteriaShareId(), $this->share->getShareId());
		$this->assertEquals($pdoCriteria->getCriteriaOperator(), $this->VALID_CRITERIAOPERATOR);
		$this->assertEquals($pdoCriteria->getCriteriaValue(), $this->VALID_CRITERIAVALUE);
	}

	/**
	 * test inserting a Criteria that already exists
	 * @expectedException PDOException
	 **/
	public function testInsertInvalidCriteria() {
		//create a criteria will a non null criteria id and watch the world burn
		$criteria = new Criteria(AbqVastTest::INVALID_KEY, $this->VALID_CRITERIAID, $this->field->getFieldId, $this->share->getShareId);
		$criteria->insert($this->getPDO());
	}

<commit_msg>started writing testUpdate functions https://app.asana.com/0/252724212774707/260460484968792<commit_after><?php
/**
 * Created by PhpStorm.
 * User: blue
 * Date: 2/1/17
 * Time: 3:29 PM
 * This is a change.
 */
namespace Edu\Cnm\AbqVast\Test;

use Edu\Cnm\AbqVast\{
	Criteria, Field, Share
};

// TODO: add share and field reference dependency classes (use)
//grab the project test parameters
require_once("AbqVastTest.php");

//grab the class under scrutiny
require_once(dirname(__DIR__) . "/autoload.php");

/**
 * PHPUnit test for the Criteria class.
 * @see Criteria
 * @author <NAME> <<EMAIL>>
 **/
class CriteriaTest extends AbqVastTest {
	/**
	 * content of criteriaId
	 * @var string $VALID_CRITERIAID
	 **/
	protected $VALID_CRITERIAID = null;

	/**
	 * content of criteriaFieldId
	 * @var $CRITERIAFIELDID criteriaFieldId
	 **/
	protected $VALID_CRITERIAFIELDID = null;

	/**
	 * content of criteriaShareId
	 * @var $CRITERIASHAREID criteriaShareId
	 **/
	protected $VALID_CRITERIASHAREID = null;

	/**
	 * content of criteriaOperator
	 * @var string $VALID_CRITERIAOPERATOR
	 **/
	protected $VALID_CRITERIAOPERATOR = "Pass";

	/**
	 * content of criteriaValue
	 * @var int $VALID_CRITERIAVALUE
	 **/
	protected $VALID_CRITERIAVALUE = 500;

	/**
	 * create dependent objects before running each test
	 **/
	public final function setUp() {
		//run the default setup method first
		parent::setUp();

		//create and insert foreign field
		$this->field = new Field(null, "passN", "S");
		$this->field->insert($this->getPDO());
		$this->share = new Share(null, "passShI", "passShU");
		$this->share->insert($this->getPDO());
	}

	/**
	 * test inserting a valid criteria and verify that the mySQL data matches.
	 **/
	public function testInsertValidCriteria() {
		//count the number of rows and save it for later
		$numRows = $this->getConnection()->getRowCount("criteria");

		// create a new criteria and insert into mySQL
		$criteria = new Criteria(null, $this->field->getFieldId(), $this->share->getShareId(), $this->VALID_CRITERIAOPERATOR, $this->VALID_CRITERIAVALUE);
		$criteria->insert($this->getPDO());
	// TODO: ask about why assertEquals instead of assertSame
		//grab the data from mySQL and enforce the fields match our expectations.
		$pdoCriteria = Criteria::getCriteriaIdByCriteriaId($this->getPDO(), $criteria->getCriteriaId());
		$this->assertEquals($numRows + 1, $this->getConnection()->getRowCount("criteria"));
		$this->assertEquals($pdoCriteria->getCriteriaId(), $this->VALID_CRITERIAID);
		$this->assertEquals($pdoCriteria->getCriteriaFieldId(), $this->field->getFieldId());
		$this->assertEquals($pdoCriteria->getCriteriaShareId(), $this->share->getShareId());
		$this->assertEquals($pdoCriteria->getCriteriaOperator(), $this->VALID_CRITERIAOPERATOR);
		$this->assertEquals($pdoCriteria->getCriteriaValue(), $this->VALID_CRITERIAVALUE);
	}

	/**
	 * test inserting a Criteria that already exists
	 * @expectedException PDOException
	 **/
	public function testInsertInvalidCriteria() {
		//create a criteria will a non null criteria id and watch the world burn
		$criteria = new Criteria(AbqVastTest::INVALID_KEY, $this->VALID_CRITERIAID, $this->field->getFieldId, $this->share->getShareId);
		$criteria->insert($this->getPDO());
	}

	/**
	 * test updating a criteria, editing it, then updating it
	 **/
	public function testUpdateValidCriteria() {
		//count the number of rows and save it for later
		$numRows = $this->getConnection()->getRowCount("criteria");

		//create a new criteria and insert it into mySQL
		$criteria = new Criteria(null, $this->field->getFieldId(), $this->share->getShareId(), $this->VALID_CRITERIAOPERATOR, $this->VALID_CRITERIAVALUE);
		criteria->insert($this->getPDO());
	}


{'fraction_non_alphanumeric': 0.14548083875632684, 'fraction_numerical': 0.007664497469269704, 'mean_word_length': 4.7299088649544325, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 113, 'https://': 1, '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': '1059446', 'n_tokens_mistral': 2289, 'n_tokens_neox': 2131, 'n_words': 547}