<commit_before><?php
/**
 * User: @mharrison13
 * Date: 5/5/17
 * Time: 10:25 PM
 **/
namespace Edu\Cnm\PetRescueAbq\Test;
use Edu\Cnm\PetRescueAbq\Profile;
require_once(dirname(__DIR__) . "/autoload.php");

/**
 * Full PHPUnit Test for Profile class
 *
 * This is the complete PHPUnit test of the Profile class. mySQL/PDO enabled methods will be tested for both valid and invalid inputs.
 *
 * @see profile
 * @author <NAME> <<EMAIL>>
 */
class ProfileTest extends PetRescueAbqTest {
	/**
	 * placeholder until account activation is created
	 * @var string $VALID_ACTIVATION
	 **/
	protected $VALID_ACTIVATION;

	/**
	 *valid at handle to use
	 * @var string @VALID_ATHANDLE
	 **/
	protected $VALID_ATHANDLE = "phpunit";

	/**
	 * valid second at handle to use
	 * @var string $VALID_ATHANDLE2
	 **/
	protected $VALID_ATHANDLE2 = "@passingtest";

	/**
	 * valid email to use
	 * @var string $VALID_EMAIL
	 **/
	protected $VALID_EMAIL = "<EMAIL>";

	/**
	 * valid hash to use
	 * @var $VALID_HASH
	 **/
	protected $VALID_HASH;

	/**
	 * valid name to use
	 * @var string $VALID_NAME
	 **/
	protected $VALID_NAME = "mikeh";

	/**
	 * valid salt to use
	 * @var string $VALID_SALT
	 **/
	protected $VALID_SALT;

	/**
	 * run default setup to operation to create salt and hash
	 **/
	public final function setUp() : void {
		parent::setUp();

		//
		$password = "<PASSWORD>";
		$this->VALID_SALT = bin2hex(random_bytes(32));
		$this->VALID_HASH = hash_pbkdf2("sha512", $password, $this->VALID_SALT, 262144);
		$this->VALID_ACTIVATION = bin2hex(random_bytes(16));
	}

	/**
	 * test inserting a valid Profile and the mySQL data matches
	 **/
	public function testInsertValidProfile() : void {
		// count the number of rows and save for later
		$numRows = $this->getConnection()->getRowCount("profile");

		// create a new Profile and insert in mySQL
		$profile = new Profile(null, $this->VALID_ACTIVATION, $this->VALID_ATHANDLE, $this->VALID_EMAIL, $this->VALID_HASH, $this->VALID_NAME, $this->VALID_SALT);

		//var_dump($profile);

		$profile->insert($this->getPDO());

		//grab the data from mySQL and enforce the fields match our expectations
		$pdoProfile = Profile::getProfileByProfileId($this->getPDO(), $profile->getProfileId());
		$this->assertSame($numRows + 1, $this->getConnection()->getRowCount(), $profile->getProfileId());
		$this->assertSame($pdoProfile->getProfileActivationToken(), $this->VALID_ACTIVATION);
		$this->assertSame($pdoProfile->getProfileAtHandle(), $this->VALID_ATHANDLE);
		$this->assertSame($pdoProfile->getProfileEmail(), $this->VALID_EMAIL);
		$this->assertSame($pdoProfile->getProfileHash(), $this->VALID_HASH);
		$this->assertSame($pdoProfile->getProfileName(), $this->VALID_NAME);
		$this->assertSame($pdoProfile->getProfileSalt(), $this->VALID_SALT);<commit_msg>fixed line 91 under: //grab the data from mySQL and enforce the fields match our expectations<commit_after><?php
/**
 * User: @mharrison13
 * Date: 5/5/17
 * Time: 10:25 PM
 **/
namespace Edu\Cnm\PetRescueAbq\Test;
use Edu\Cnm\PetRescueAbq\Profile;
require_once(dirname(__DIR__) . "/autoload.php");

/**
 * Full PHPUnit Test for Profile class
 *
 * This is the complete PHPUnit test of the Profile class. mySQL/PDO enabled methods will be tested for both valid and invalid inputs.
 *
 * @see profile
 * @author <NAME> <<EMAIL>>
 */
class ProfileTest extends PetRescueAbqTest {
	/**
	 * placeholder until account activation is created
	 * @var string $VALID_ACTIVATION
	 **/
	protected $VALID_ACTIVATION;

	/**
	 *valid at handle to use
	 * @var string @VALID_ATHANDLE
	 **/
	protected $VALID_ATHANDLE = "phpunit";

	/**
	 * valid second at handle to use
	 * @var string $VALID_ATHANDLE2
	 **/
	protected $VALID_ATHANDLE2 = "@passingtest";

	/**
	 * valid email to use
	 * @var string $VALID_EMAIL
	 **/
	protected $VALID_EMAIL = "<EMAIL>";

	/**
	 * valid hash to use
	 * @var $VALID_HASH
	 **/
	protected $VALID_HASH;

	/**
	 * valid name to use
	 * @var string $VALID_NAME
	 **/
	protected $VALID_NAME = "mikeh";

	/**
	 * valid salt to use
	 * @var string $VALID_SALT
	 **/
	protected $VALID_SALT;

	/**
	 * run default setup to operation to create salt and hash
	 **/
	public final function setUp() : void {
		parent::setUp();

		//
		$password = "<PASSWORD>";
		$this->VALID_SALT = bin2hex(random_bytes(32));
		$this->VALID_HASH = hash_pbkdf2("sha512", $password, $this->VALID_SALT, 262144);
		$this->VALID_ACTIVATION = bin2hex(random_bytes(16));
	}

	/**
	 * test inserting a valid Profile and the mySQL data matches
	 **/
	public function testInsertValidProfile() : void {
		// count the number of rows and save for later
		$numRows = $this->getConnection()->getRowCount("profile");

		// create a new Profile and insert in mySQL
		$profile = new Profile(null, $this->VALID_ACTIVATION, $this->VALID_ATHANDLE, $this->VALID_EMAIL, $this->VALID_HASH, $this->VALID_NAME, $this->VALID_SALT);

		//var_dump($profile);

		$profile->insert($this->getPDO());

		//grab the data from mySQL and enforce the fields match our expectations
		$pdoProfile = Profile::getProfileByProfileId($this->getPDO(), $profile->getProfileId());
		$this->assertSame($numRows + 1, $this->getConnection()->getRowCount("profile"));
		$this->assertSame($pdoProfile->getProfileActivationToken(), $this->VALID_ACTIVATION);
		$this->assertSame($pdoProfile->getProfileAtHandle(), $this->VALID_ATHANDLE);
		$this->assertSame($pdoProfile->getProfileEmail(), $this->VALID_EMAIL);
		$this->assertSame($pdoProfile->getProfileHash(), $this->VALID_HASH);
		$this->assertSame($pdoProfile->getProfileName(), $this->VALID_NAME);
		$this->assertSame($pdoProfile->getProfileSalt(), $this->VALID_SALT);
{'fraction_non_alphanumeric': 0.15190097259062776, 'fraction_numerical': 0.010610079575596816, 'mean_word_length': 4.448940269749518, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 88, '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': '3496021', 'n_tokens_mistral': 2013, 'n_tokens_neox': 1838, 'n_words': 461}