本文整理汇总了PHP中RedBeanModel::forgetAll方法的典型用法代码示例。如果您正苦于以下问题:PHP RedBeanModel::forgetAll方法的具体用法?PHP RedBeanModel::forgetAll怎么用?PHP RedBeanModel::forgetAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RedBeanModel
的用法示例。
在下文中一共展示了RedBeanModel::forgetAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
ZurmoDatabaseCompatibilityUtil::dropStoredFunctionsAndProcedures();
SecurityTestHelper::createSuperAdmin();
SecurityTestHelper::createUsers();
SecurityTestHelper::createGroups();
SecurityTestHelper::createRoles();
RedBeanModel::forgetAll();
//do the rebuild to ensure the tables get created properly.
ReadPermissionsOptimizationUtil::rebuild();
//Manually build the test model munge tables.
ReadPermissionsOptimizationUtil::recreateTable(ReadPermissionsOptimizationUtil::getMungeTableName('OwnedSecurableTestItem'));
ReadPermissionsOptimizationUtil::recreateTable(ReadPermissionsOptimizationUtil::getMungeTableName('OwnedSecurableTestItem2'));
$benny = User::getByUsername('benny');
$model = new OwnedSecurableTestItem();
$model->member = 'test';
assert($model->save());
// Not Coding Standard
$model = new OwnedSecurableTestItem();
$model->member = 'test2';
assert($model->save());
// Not Coding Standard
$model = new OwnedSecurableTestItem();
$model->member = 'test3';
$model->owner = $benny;
assert($model->save());
// Not Coding Standard
assert(OwnedSecurableTestItem::getCount() == 3);
// Not Coding Standard
$model = new OwnedSecurableTestItem2();
$model->member = 'test5';
assert($model->save());
// Not Coding Standard
}
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:35,代码来源:OwnedSecurableItemReadPermissionOptimizationTest.php
示例2: setUp
public function setUp()
{
parent::setUp();
RedBeanModel::forgetAll();
$this->setupServerUrl();
if (!$this->isApiTestUrlConfigured()) {
$this->markTestSkipped(Zurmo::t('ApiModule', 'API test url is not configured in perInstanceTest.php file.'));
}
}
示例3: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
$super = SecurityTestHelper::createSuperAdmin();
self::$emailMessage = EmailMessageTestHelper::createDraftSystemEmail('a test message', $super);
SecurityTestHelper::createUsers();
SecurityTestHelper::createGroups();
SecurityTestHelper::createRoles();
RedBeanModel::forgetAll();
//do the rebuild to ensure the tables get created properly.
ReadPermissionsOptimizationUtil::rebuild();
}
示例4: testAttributesTranslateToAllSupportedLanguagesCorrectly
public function testAttributesTranslateToAllSupportedLanguagesCorrectly()
{
$this->assertEquals('en', Yii::app()->language);
$account = new Account(false);
$this->assertEquals('Office Phone', $account->getAttributeLabel('officePhone'));
$this->assertEquals('Billing Address', $account->getAttributeLabel('billingAddress'));
Yii::app()->language = 'fr';
$this->assertEquals('Téléphone de bureau', $account->getAttributeLabel('officePhone'));
$this->assertEquals('Adresse de facturation', $account->getAttributeLabel('billingAddress'));
Yii::app()->language = 'it';
$this->assertEquals('Telefono Ufficio', $account->getAttributeLabel('officePhone'));
$this->assertEquals('Indirizzo di Fatturazione', $account->getAttributeLabel('billingAddress'));
Yii::app()->language = 'es';
$this->assertEquals('Teléfono de la Oficina', $account->getAttributeLabel('officePhone'));
$this->assertEquals('Dirección de facturación', $account->getAttributeLabel('billingAddress'));
Yii::app()->language = 'de';
$this->assertEquals('Bürotelefon', $account->getAttributeLabel('officePhone'));
$this->assertEquals('Rechnungsadresse', $account->getAttributeLabel('billingAddress'));
//Set language back to english.
Yii::app()->language = 'en';
//Now customize both labels for all supported languages.
$metadata = Account::getMetadata();
$metadata['Account']['labels']['officePhone'] = array('de' => 'GermanSomething', 'en' => 'EnglishSomething', 'es' => 'SpanishSomething', 'fr' => 'FrenchSomething', 'it' => 'ItalianSomething');
$metadata['Account']['labels']['billingAddress'] = array('de' => 'GermanSomethingElse', 'en' => 'EnglishSomethingElse', 'es' => 'SpanishSomethingElse', 'fr' => 'FrenchSomethingElse', 'it' => 'ItalianSomethingElse');
Account::setMetadata($metadata);
RedBeanModel::forgetAll();
//Set language back to english.
Yii::app()->language = 'en';
$this->assertEquals('EnglishSomething', $account->getAttributeLabel('officePhone'));
$this->assertEquals('EnglishSomethingElse', $account->getAttributeLabel('billingAddress'));
Yii::app()->language = 'fr';
$this->assertEquals('FrenchSomething', $account->getAttributeLabel('officePhone'));
$this->assertEquals('FrenchSomethingElse', $account->getAttributeLabel('billingAddress'));
Yii::app()->language = 'it';
$this->assertEquals('ItalianSomething', $account->getAttributeLabel('officePhone'));
$this->assertEquals('ItalianSomethingElse', $account->getAttributeLabel('billingAddress'));
Yii::app()->language = 'es';
$this->assertEquals('SpanishSomething', $account->getAttributeLabel('officePhone'));
$this->assertEquals('SpanishSomethingElse', $account->getAttributeLabel('billingAddress'));
Yii::app()->language = 'de';
$this->assertEquals('GermanSomething', $account->getAttributeLabel('officePhone'));
$this->assertEquals('GermanSomethingElse', $account->getAttributeLabel('billingAddress'));
//Set language back to english.
Yii::app()->language = 'en';
//Retrieve all the language labels for a particular attribute.
$officePhoneLabels = $account->getAttributeLabelsForAllActiveLanguagesByAttributeName('officePhone');
$billingAddressLabels = $account->getAttributeLabelsForAllActiveLanguagesByAttributeName('billingAddress');
$comparePhoneLabels = array('de' => 'GermanSomething', 'en' => 'EnglishSomething', 'es' => 'SpanishSomething', 'fr' => 'FrenchSomething', 'it' => 'ItalianSomething');
$compareAddressLabels = array('de' => 'GermanSomethingElse', 'en' => 'EnglishSomethingElse', 'es' => 'SpanishSomethingElse', 'fr' => 'FrenchSomethingElse', 'it' => 'ItalianSomethingElse');
$this->assertEquals($comparePhoneLabels, $officePhoneLabels);
$this->assertEquals($compareAddressLabels, $compareAddressLabels);
}
示例5: tearDownAfterClass
public static function tearDownAfterClass()
{
if (RedBeanDatabase::isFrozen()) {
TestDatabaseUtil::deleteRowsFromAllTablesExceptLog();
} else {
TestDatabaseUtil::deleteAllTablesExceptLog();
}
RedBeanModel::forgetAll();
RedBeanDatabase::close();
assert('!RedBeanDatabase::isSetup()');
// Not Coding Standard
GeneralCache::forgetAll();
}
示例6: testListContactStateAttributes
public function testListContactStateAttributes()
{
RedBeanModel::forgetAll();
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
$authenticationData = $this->login();
$headers = array('Accept: application/json', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST');
$allAttributes = ApiRestTestHelper::getModelAttributes(new ContactState());
$response = $this->createApiCallWithRelativeUrl('listAttributes/', 'GET', $headers);
$response = json_decode($response, true);
$this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
$this->assertEquals($allAttributes, $response['data']['items']);
}
示例7: tearDownAfterClass
public static function tearDownAfterClass()
{
if (static::$activateDefaultLanguages) {
Yii::app()->languageHelper->deactivateLanguagesForTesting();
}
TestDatabaseUtil::deleteRowsFromAllTablesExceptLog();
PermissionsCache::forgetAll();
AllPermissionsOptimizationCache::forgetAll();
RedBeanModel::forgetAll();
RedBeanDatabase::close();
assert('!RedBeanDatabase::isSetup()');
// Not Coding Standard
GeneralCache::forgetAll();
BeanModelCache::forgetAll();
}
示例8: testCreateWithScenario
public function testCreateWithScenario()
{
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
$authenticationData = $this->login();
$headers = array('Accept: application/json', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST');
$data['name'] = 'ABCD';
$data['createdDateTime'] = '2014-06-12 15:22:41';
$data['modifiedDateTime'] = '2014-06-12 15:28:41';
$response = $this->createApiCallWithRelativeUrl('create/', 'POST', $headers, array('data' => $data));
$response = json_decode($response, true);
$this->assertEquals(ApiResponse::STATUS_FAILURE, $response['status']);
$this->assertEquals('It is not allowed to set read only attribute: createdDateTime.', $response['message']);
// Now try to use some invalid scenario name
$data['modelScenario'] = 'dummyScenarioName';
$response = $this->createApiCallWithRelativeUrl('create/', 'POST', $headers, array('data' => $data));
$response = json_decode($response, true);
$this->assertEquals(ApiResponse::STATUS_FAILURE, $response['status']);
$this->assertEquals('It is not allowed to set read only attribute: createdDateTime.', $response['message']);
// Now use scenario name that allow us to set all values
$data['modelScenario'] = 'importModel';
$response = $this->createApiCallWithRelativeUrl('create/', 'POST', $headers, array('data' => $data));
$response = json_decode($response, true);
$this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
RedBeanModel::forgetAll();
$account = Account::getById($response['data']['id']);
$this->assertEquals($account->name, $response['data']['name']);
$this->assertEquals($account->createdDateTime, $response['data']['createdDateTime']);
}
示例9: testCreateWithRelations
public function testCreateWithRelations()
{
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
$everyoneGroup = Group::getByName(Group::EVERYONE_GROUP_NAME);
$this->assertTrue($everyoneGroup->save());
$john = UserTestHelper::createBasicUser('John');
$john->setRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API);
$john->setRight('MeetingsModule', MeetingsModule::getAccessRight());
$john->setRight('MeetingsModule', MeetingsModule::getCreateRight());
$saved = $john->save();
$this->assertTrue($saved);
$contact = ContactTestHelper::createContactByNameForOwner('Simon', $super);
$contact2 = ContactTestHelper::createContactByNameForOwner('Simona', $john);
$contactItemId = $contact->getClassId('Item');
$contact2ItemId = $contact2->getClassId('Item');
$authenticationData = $this->login();
$headers = array('Accept: application/json', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST');
$categories = array('Meeting', 'Call');
$categoryFieldData = CustomFieldData::getByName('MeetingCategories');
$categoryFieldData->serializedData = serialize($categories);
$this->assertTrue($categoryFieldData->save());
$startStamp = DateTimeUtil::convertTimestampToDbFormatDateTime(time() + 10000);
$endStamp = DateTimeUtil::convertTimestampToDbFormatDateTime(time() + 11000);
$data['name'] = "Meeting with relations for super user";
$data['startDateTime'] = $startStamp;
$data['endDateTime'] = $endStamp;
$data['category']['value'] = $categories[1];
$data['modelRelations'] = array('activityItems' => array(array('action' => 'add', 'modelId' => $contact->id, 'modelClassName' => 'Contact')), 'userAttendees' => array(array('action' => 'add', 'modelId' => $john->id, 'modelClassName' => 'User')));
$response = $this->createApiCallWithRelativeUrl('create/', 'POST', $headers, array('data' => $data));
$response = json_decode($response, true);
$this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
$this->assertEquals($data['name'], $response['data']['name']);
$this->assertEquals($data['startDateTime'], $response['data']['startDateTime']);
$this->assertEquals($data['endDateTime'], $response['data']['endDateTime']);
RedBeanModel::forgetAll();
$meeting = Meeting::getById($response['data']['id']);
$this->assertEquals(1, count($meeting->activityItems));
$this->assertEquals($contactItemId, $meeting->activityItems[0]->id);
$this->assertEquals(1, count($meeting->userAttendees));
$this->assertEquals($john->id, $meeting->userAttendees[0]->id);
// Now test with regular user
$authenticationData = $this->login('john', 'john');
$headers = array('Accept: application/json', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST');
$data = array();
$data['name'] = "Meeting with relations for regular user";
$data['startDateTime'] = $startStamp;
$data['endDateTime'] = $endStamp;
$data['category']['value'] = $categories[1];
$data['modelRelations'] = array('activityItems' => array(array('action' => 'add', 'modelId' => $contact2->id, 'modelClassName' => 'Contact')), 'userAttendees' => array(array('action' => 'add', 'modelId' => $super->id, 'modelClassName' => 'User')));
$response = $this->createApiCallWithRelativeUrl('create/', 'POST', $headers, array('data' => $data));
$response = json_decode($response, true);
$this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
$this->assertEquals($data['name'], $response['data']['name']);
$this->assertEquals($data['startDateTime'], $response['data']['startDateTime']);
$this->assertEquals($data['endDateTime'], $response['data']['endDateTime']);
RedBeanModel::forgetAll();
$meeting = Meeting::getById($response['data']['id']);
$this->assertEquals(1, count($meeting->activityItems));
$this->assertEquals($contact2ItemId, $meeting->activityItems[0]->id);
$this->assertEquals(1, count($meeting->userAttendees));
$this->assertEquals($super->id, $meeting->userAttendees[0]->id);
}
示例10: testUpdateUser
/**
* @depends testCreateUser
*/
public function testUpdateUser()
{
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
$authenticationData = $this->login();
$headers = array('Accept: application/json', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST');
$user = User::getByUsername('diggy011');
$compareData = $this->getModelToApiDataUtilData($user);
$user->forget();
$data['firstName'] = "John";
$data['password'] = "aswe019";
$response = $this->createApiCallWithRelativeUrl('update/' . $compareData['id'], 'PUT', $headers, array('data' => $data));
$response = json_decode($response, true);
$this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
// We need to unset some empty values from response and dates.
unset($response['data']['modifiedDateTime']);
unset($compareData['modifiedDateTime']);
unset($response['data']['lastLoginDateTime']);
unset($compareData['lastLoginDateTime']);
$compareData['firstName'] = "John";
ksort($compareData);
ksort($response['data']);
$this->assertEquals($compareData, $response['data']);
// Check if password is updated
RedBeanModel::forgetAll();
$updatedUser = User::getByUsername('diggy011');
$this->assertNotEquals($user->hash, $updatedUser->hash);
$response = $this->createApiCallWithRelativeUrl('read/' . $user->id, 'GET', $headers);
$response = json_decode($response, true);
$this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
unset($response['data']['modifiedDateTime']);
unset($response['data']['lastLoginDateTime']);
ksort($response['data']);
$this->assertEquals($compareData, $response['data']);
}
示例11: testUpdateWithRelations
/**
* @depends testCreateWithRelations
*/
public function testUpdateWithRelations()
{
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
$authenticationData = $this->login();
$headers = array('Accept: application/json', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST');
$contact = ContactTestHelper::createContactByNameForOwner('Mark', $super);
$contactItemId = $contact->getClassId('Item');
$note = NoteTestHelper::createNoteByNameForOwner('Note update test.', $super);
$redBeanModelToApiDataUtil = new RedBeanModelToApiDataUtil($note);
$compareData = $redBeanModelToApiDataUtil->getData();
$this->assertEquals(0, count($note->activityItems));
$note->forget();
$data['modelRelations'] = array('activityItems' => array(array('action' => 'add', 'modelId' => $contact->id, 'modelClassName' => 'Contact')));
$data['description'] = "Updated note description";
$response = ApiRestTestHelper::createApiCall($this->serverUrl . '/test.php/notes/note/api/update/' . $compareData['id'], 'PUT', $headers, array('data' => $data));
$response = json_decode($response, true);
unset($response['data']['modifiedDateTime']);
unset($compareData['modifiedDateTime']);
$compareData['description'] = "Updated note description";
$this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
$this->assertEquals($compareData, $response['data']);
RedBeanModel::forgetAll();
$note = Note::getById($compareData['id']);
$this->assertEquals(1, count($note->activityItems));
$this->assertEquals($contactItemId, $note->activityItems[0]->id);
// Now test remove relations
$data['modelRelations'] = array('activityItems' => array(array('action' => 'remove', 'modelId' => $contact->id, 'modelClassName' => 'Contact')));
$response = ApiRestTestHelper::createApiCall($this->serverUrl . '/test.php/notes/note/api/update/' . $compareData['id'], 'PUT', $headers, array('data' => $data));
$response = json_decode($response, true);
$this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
RedBeanModel::forgetAll();
$note = Note::getById($compareData['id']);
$this->assertEquals(0, count($note->activityItems));
}
示例12: testDeleteSecurableItemDeletesItsPermissions
public function testDeleteSecurableItemDeletesItsPermissions()
{
$user = User::getByUsername('billy');
$account = new Account();
$account->name = 'Waxamatronic';
$account->addPermissions($user, Permission::READ);
$this->assertTrue($account->save());
$this->assertEquals(1, count($account->permissions));
$this->assertEquals(Permission::READ, $account->getEffectivePermissions($user));
$account->delete();
unset($account);
$userId = $user->id;
unset($user);
RedBeanModel::forgetAll();
$this->assertEquals(0, count(Permission::getAll()));
}
示例13: testResolveContactToSenderOrRecipientForReceivedEmail
public function testResolveContactToSenderOrRecipientForReceivedEmail()
{
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
$message1 = self::$message1;
$contact = new Contact();
$contact->firstName = 'Jason';
$contact->lastName = 'Green';
$contact->state = ContactsUtil::getStartingState();
$saved = $contact->save();
$this->assertTrue($saved);
$contactId = $contact->id;
$contact->forget();
$contact = Contact::getById($contactId);
$this->assertNull($contact->primaryEmail->emailAddress);
ArchivedEmailMatchingUtil::resolveContactToSenderOrRecipient($message1, $contact);
$saved = $message1->save();
$this->assertTrue($saved);
$messageId = $message1->id;
$message1->forget();
$contact->forget();
RedBeanModel::forgetAll();
//simulates crossing page requests
$message1 = EmailMessage::getById($messageId);
$contact = Contact::getById($contactId);
$this->assertEquals(1, $message1->sender->personsOrAccounts->count());
$castedDownModel = EmailMessageMashableActivityRules::castDownItem($message1->sender->personsOrAccounts[0]);
$this->assertEquals('Contact', get_class($castedDownModel));
$this->assertEquals($contact->id, $castedDownModel->id);
}
示例14: testSetNewAttributeFromAttributeForm
/**
* @depends testMakeAttributeFormByAttributeName
*/
public function testSetNewAttributeFromAttributeForm()
{
Yii::app()->user->userModel = User::getByUsername('super');
$values = array('Automotive', 'Adult Entertainment', 'Financial Services', 'Mercenaries & Armaments');
$industryFieldData = CustomFieldData::getByName('Industries');
$industryFieldData->forget();
unset($industryFieldData);
$industryFieldData = CustomFieldData::getByName('Industries');
$industryFieldData->serializedData = serialize($values);
$this->assertTrue($industryFieldData->save());
$account = new Account();
$attributeForm = new DropDownAttributeForm($account, 'industry');
$attributeForm->attributeLabels = array('de' => 'Industry de', 'en' => 'Industry', 'es' => 'Industry es', 'fr' => 'Industry fr', 'it' => 'Industry it');
$attributeForm->isAudited = true;
$attributeForm->isRequired = false;
$this->assertEquals($values, $attributeForm->customFieldDataData);
$modelAttributesAdapterClassName = $attributeForm::getModelAttributeAdapterNameForSavingAttributeFormData();
$adapter = new $modelAttributesAdapterClassName(new Account());
try {
$adapter->setAttributeMetadataFromForm($attributeForm);
} catch (FailedDatabaseSchemaChangeException $e) {
echo $e->getMessage();
$this->fail();
}
RedBeanModel::forgetAll();
$account = new Account();
$attributeForm = AttributesFormFactory::createAttributeFormByAttributeName($account, 'industry');
$this->assertEquals('industry', $attributeForm->attributeName);
$compareAttributeLabels = array('de' => 'Industry de', 'en' => 'Industry', 'es' => 'Industry es', 'fr' => 'Industry fr', 'it' => 'Industry it');
$this->assertEquals($compareAttributeLabels, $attributeForm->attributeLabels);
$this->assertEquals(true, $attributeForm->isAudited);
$this->assertEquals(false, $attributeForm->isRequired);
$this->assertEquals($values, $attributeForm->customFieldDataData);
}
示例15: testSuperUserAllDefaultControllerActions
public function testSuperUserAllDefaultControllerActions()
{
$super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
$imageFile = ImageFileModel::getById($this->imageFile1Id);
if (file_exists($imageFile->getImageCachePath())) {
unlink($imageFile->getImageCachePath());
}
if (file_exists($imageFile->getImageCachePath(true))) {
unlink($imageFile->getImageCachePath(true));
}
//Test all default controller actions that do not require any POST/GET variables to be passed.
//This does not include portlet controller actions.
$content = $this->runControllerWithNoExceptionsAndGetContent('zurmo/imageModel/getUploaded');
$returnedObject = CJSON::decode($content);
$this->assertContains('zurmo/imageModel/getImage?fileName=' . $imageFile->getImageCacheFileName(), $returnedObject[0]['image']);
$this->assertContains('zurmo/imageModel/getThumb?fileName=' . $imageFile->getImageCacheFileName(), $returnedObject[0]['thumb']);
$this->assertFalse(file_exists($imageFile->getImageCachePath()));
$this->assertFalse(file_exists($imageFile->getImageCachePath(true)));
//Test getting the image
$this->setGetArray(array('fileName' => $imageFile->getImageCacheFileName()));
@$this->runControllerWithExitExceptionAndGetContent('zurmo/imageModel/getImage');
$this->assertTrue(file_exists($imageFile->getImageCachePath()));
$this->assertFalse(file_exists($imageFile->getImageCachePath(true)));
//Test getting the image thumb
$this->setGetArray(array('fileName' => $imageFile->getImageCacheFileName()));
@$this->runControllerWithExitExceptionAndGetContent('zurmo/imageModel/getThumb');
$this->assertTrue(file_exists($imageFile->getImageCachePath()));
$this->assertTrue(file_exists($imageFile->getImageCachePath(true)));
//Test uploading invalid image
$pathToFiles = Yii::getPathOfAlias('application.modules.zurmo.tests.unit.files');
$filePath = $pathToFiles . DIRECTORY_SEPARATOR . 'testNote.txt';
self::resetAndPopulateFilesArrayByFilePathAndName('file', $filePath, 'testNote.txt');
$content = $this->runControllerWithNoExceptionsAndGetContent('zurmo/imageModel/upload');
$returnedObject = CJSON::decode($content);
$this->assertEquals('Error uploading the image', $returnedObject[0]['error']);
//Test uploading valid image
$pathToFiles = Yii::getPathOfAlias('application.modules.zurmo.tests.unit.files');
$fileContents = file_get_contents($pathToFiles . DIRECTORY_SEPARATOR . 'testImage.png');
$filePath = $pathToFiles . DIRECTORY_SEPARATOR . 'testImage.png';
self::resetAndPopulateFilesArrayByFilePathAndName('file', $filePath, 'testImage.png');
$content = $this->runControllerWithNoExceptionsAndGetContent('zurmo/imageModel/upload');
$returnedObject = CJSON::decode($content);
$this->assertContains('zurmo/imageModel/getImage?fileName=2_testImage.png', $returnedObject[0]['filelink']);
// Not Coding Standard
$createdImageFile = ImageFileModel::getById(2);
$this->assertEquals($fileContents, $createdImageFile->fileContent->content);
//Test deleting image
$createdImageFile->inactive = false;
$this->setGetArray(array('id' => 2));
$this->runControllerWithNoExceptionsAndGetContent('zurmo/imageModel/delete', true);
RedBeanModel::forgetAll();
$deletedImageFile = ImageFileModel::getById(2);
$deletedImageFile->inactive = true;
}