<commit_before><?php
namespace Edu\Cnm\DdcAaaa\Test;

use Edu\Cnm\DdcAaaa\{ApplicationCohort, Application};

// grab the project test parameters
require_once("AaaaTest.php");

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

/**
 * Full PHPUnit test for the Placard class
 *
 * This is a complete PHPUnit test of the Placard class. It is complete because *ALL* mySQL/PDO enabled methods
 * are tested for both invalid and valid inputs.
 *
 * @see Placard
 * @author <NAME> <<EMAIL>>
 **/
class ApplicationCohortTest extends AaaaTest {

	private $VALID_APPLICATIONCOHORTAPPLICATIONID = 1;
	private $VALID_APPLICATIONCOHORTCOHORTID = 2;

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

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

		// create a new Placard and insert to into mySQL
		$applicationCohort = new ApplicationCohort(null, $this->VALID_APPLICATIONCOHORTAPPLICATIONID, $this->VALID_APPLICATIONCOHORTCOHORTID);
		$applicationCohort->insert($this->getPDO());

		// grab the data from mySQL and enforce the fields match our expectations
		$pdoApplicationCohort = applicationCohort::getApplicationCohortByApplicationCohortId($this->getPDO(), $applicationCohort->getApplicationCohortId());
		$this->assertEquals($numRows + 1, $this->getConnection()->getRowCount("applicationCohort"));
		$this->assertEquals($pdoApplicationCohort->getApplicationCohortApplicationId(), $this->VALID_APPLICATIONCOHORTAPPLICATIONID);
		$this->assertEquals($pdoApplicationCohort->getApplicationCohortCohortId(), $this->VALID_APPLICATIONCOHORTCOHORTID);
	}

	/**
	 * test inserting a ApplicationCohort that already exists
	 *
	 * @expectedException \PDOException
	 **/
	public function testInsertInvalidApplicationCohort() {
		// create a Placard with a non null placard id and watch it fail
		$placard = new ApplicationCohort(AaaaTest::INVALID_KEY, $this->VALID_APPLICATIONCOHORTAPPLICATIONID, $this->VALID_APPLICATIONCOHORTCOHORTID);
		$placard->insert($this->getPDO());
	}
}<commit_msg>created an application to fill dependency<commit_after><?php
namespace Edu\Cnm\DdcAaaa\Test;

use Edu\Cnm\DdcAaaa\{ApplicationCohort, Application};

// grab the project test parameters
require_once("AaaaTest.php");

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

/**
 * Full PHPUnit test for the Placard class
 *
 * This is a complete PHPUnit test of the Placard class. It is complete because *ALL* mySQL/PDO enabled methods
 * are tested for both invalid and valid inputs.
 *
 * @see Placard
 * @author <NAME> <<EMAIL>>
 **/
class ApplicationCohortTest extends AaaaTest {

	private $application = null;
	private $VALID_APPLICATIONCOHORTCOHORTID = 2;

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

		// create an application
		$this->application = new Application(null, "john", "doe", "<EMAIL>", "555-555-5555", "source",
			1, "about you", "hope", "exp", "utmC", "utmM", "utmS");
		$this->application->insert($this->getPDO());
	}

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

		// create a new ApplicationCohort and insert to into mySQL
		$applicationCohort = new ApplicationCohort(null, $this->application->getApplicationId(), $this->VALID_APPLICATIONCOHORTCOHORTID);
		$applicationCohort->insert($this->getPDO());

		// grab the data from mySQL and enforce the fields match our expectations
		$pdoApplicationCohort = applicationCohort::getApplicationCohortByApplicationCohortId($this->getPDO(), $applicationCohort->getApplicationCohortId());
		$this->assertEquals($numRows + 1, $this->getConnection()->getRowCount("applicationCohort"));
		$this->assertEquals($pdoApplicationCohort->getApplicationCohortApplicationId(), $this->application->getApplicationId());
		$this->assertEquals($pdoApplicationCohort->getApplicationCohortCohortId(), $this->VALID_APPLICATIONCOHORTCOHORTID);
	}

	/**
	 * test inserting a ApplicationCohort that already exists
	 *
	 * @expectedException \PDOException
	 **/
	public function testInsertInvalidApplicationCohort() {
		// create a Placard with a non null placard id and watch it fail
		$placard = new ApplicationCohort(AaaaTest::INVALID_KEY, $this->VALID_APPLICATIONCOHORTAPPLICATIONID, $this->VALID_APPLICATIONCOHORTCOHORTID);
		$placard->insert($this->getPDO());
	}
}
{'fraction_non_alphanumeric': 0.11736237144585603, 'fraction_numerical': 0.003226456946965114, 'mean_word_length': 5.526315789473684, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 58, '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': '1451991', 'n_tokens_mistral': 1595, 'n_tokens_neox': 1482, 'n_words': 387}