public function testInsertDuplicateUserData()
 {
     ob_start();
     $myDb = DBMaker::create('botspacetest');
     Database::clearDB();
     $db = Database::getDB('botspacetest', 'C:\\xampp\\myConfig.ini');
     $beforeCount = count(UserDataDB::getUserDataBy());
     $userDataCopy = UserDataDB::getUserDataRowSetsBy('userDataId', 1);
     $userDataCopy = $userDataCopy[0];
     $s1 = new UserData($userDataCopy);
     $insertedUserData = UserDataDB::addUserData($s1);
     $this->assertGreaterThan(0, $insertedUserData->getErrorCount(), 'Duplicate attempt should return with an error');
     $afterCount = count(UserDataDB::getUserDataBy());
     $this->assertEquals($afterCount, $beforeCount, 'The database should have the same number of elements after the insertion attempt');
     ob_get_clean();
 }
 public static function getUserDataValuesBy($column, $type = null, $value = null)
 {
     $userDataRows = UserDataDB::getUserDataRowSetsBy($type, $value);
     return UserDataDB::getUserDataValues($userDataRows, $column);
 }
 public function testUpdateUserData()
 {
     $myDB = DBMaker::create('botspacetest');
     Database::clearDB();
     $db = Database::getDB('botspacetest', 'C:\\xampp\\myConfig.ini');
     $testUserDataId = 1;
     $userDataArray = UserDataDB::getUserDataBy('userDataId', $testUserDataId);
     $userData = $userDataArray[0];
     $params = $userData->getParameters();
     $this->assertEquals($userData->getUserName(), 'jabituya', 'Before the update it should have username jabituya');
     $testUserDataRowsArray = UserDataDB::getUserDataRowSetsBy('userDataId', $testUserDataId);
     $testUserDataRow = $testUserDataRowsArray[0];
     $params['user_name'] = 'jabituya2000';
     $newUserData = new UserData($params);
     $newUserData->setUserDataId($testUserDataId);
     $userData = UserDataDB::updateUserData($newUserData);
     $this->assertEquals($userData->getUserName(), 'jabituya2000', 'After the update it should have username jabituya2000');
     $this->assertTrue(empty($userData->getErrors()), 'The updated user data should have no errors');
 }