当前位置: 首页>>代码示例>>PHP>>正文


PHP Contact::deleteAll方法代码示例

本文整理汇总了PHP中Contact::deleteAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Contact::deleteAll方法的具体用法?PHP Contact::deleteAll怎么用?PHP Contact::deleteAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Contact的用法示例。


在下文中一共展示了Contact::deleteAll方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Eloquent::unguard();
     Contact::deleteAll();
     $this->call('CountriesTableSeeder');
     $this->call('CompaniesTableSeeder');
     $this->call('ContactsTableSeeder');
     $this->call('ContactCompanyTableSeeder');
 }
开发者ID:tldmic,项目名称:admin_demo,代码行数:14,代码来源:DatabaseSeeder.php

示例2: setUp

 public function setUp()
 {
     parent::setUp();
     $this->user = User::getByUsername('super');
     Yii::app()->user->userModel = $this->user;
     Campaign::deleteAll();
     CampaignItem::deleteAll();
     Contact::deleteAll();
     MarketingList::deleteAll();
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:10,代码来源:CampaignQueueMessagesInOutboxJobBenchmarkTest.php

示例3: session_start

<?php

require_once __DIR__ . "/../vendor/autoload.php";
require_once __DIR__ . "/../src/Contact.php";
session_start();
//creates 'list_of_contacts' array if SESSION is empty
if (empty($_SESSION['list_of_contacts'])) {
    $_SESSION['list_of_contacts'] = array();
}
$app = new Silex\Application();
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
//root or homepage route
$app->get("/", function () use($app) {
    return $app['twig']->render('contacts.html.twig', array('contacts' => Contact::getAll()));
});
//saves a new contact and routes the user to /create_contact
$app->post("/create_contact", function () use($app) {
    $contact = new Contact($_POST['create_name'], $_POST['create_phone'], $_POST['create_address']);
    $contact->save();
    return $app['twig']->render('create_contact.html.twig', array('contacts' => Contact::getAll()));
});
//deletes ALL contacts and routes user to /delete_contacts
$app->post('/delete_contacts', function () use($app) {
    Contact::deleteAll();
    return $app['twig']->render('delete_contacts.html.twig');
});
return $app;
开发者ID:bdspen,项目名称:address_book,代码行数:27,代码来源:app.php

示例4: testArePermissionsFlushedOnRemovingParentFromChildRole

 public function testArePermissionsFlushedOnRemovingParentFromChildRole()
 {
     Contact::deleteAll();
     try {
         $role = Role::getByName('Parent');
         $role->delete();
     } catch (NotFoundException $e) {
     }
     try {
         $user = User::getByUsername('jim');
         $user->delete();
     } catch (NotFoundException $e) {
     }
     try {
         $user = User::getByUsername('jane');
         $user->delete();
     } catch (NotFoundException $e) {
     }
     // we could have used helpers to do a lot of the following stuff (such as creating users, roles,
     // etc) but we wanted to mimic user's interaction as closely as possible. Hence using walkthroughs
     // for everything
     // create Parent and Child Roles, Create Jim to be member of Child role
     // create parent role
     $this->resetGetArray();
     $this->setPostArray(array('Role' => array('name' => 'Parent')));
     $this->runControllerWithRedirectExceptionAndGetUrl('/zurmo/role/create');
     $parentRole = Role::getByName('Parent');
     $this->assertNotNull($parentRole);
     $this->assertEquals('Parent', strval($parentRole));
     $parentRoleId = $parentRole->id;
     // create child role
     $this->resetGetArray();
     $this->setPostArray(array('Role' => array('name' => 'Child', 'role' => array('id' => $parentRoleId))));
     $this->runControllerWithRedirectExceptionAndGetUrl('/zurmo/role/create');
     $childRole = Role::getByName('Child');
     $this->assertNotNull($childRole);
     $this->assertEquals('Child', strval($childRole));
     $parentRole->forgetAll();
     $parentRole = Role::getById($parentRoleId);
     $childRoleId = $childRole->id;
     $childRole->forgetAll();
     $childRole = Role::getById($childRoleId);
     $this->assertEquals($childRole->id, $parentRole->roles[0]->id);
     // create jim's user
     $this->resetGetArray();
     $this->setPostArray(array('UserPasswordForm' => array('firstName' => 'Some', 'lastName' => 'Body', 'username' => 'jim', 'newPassword' => 'myPassword123', 'newPassword_repeat' => 'myPassword123', 'officePhone' => '456765421', 'userStatus' => 'Active', 'role' => array('id' => $childRoleId))));
     $this->runControllerWithRedirectExceptionAndGetContent('/users/default/create');
     $jim = User::getByUsername('jim');
     $this->assertNotNull($jim);
     $childRole->forgetAll();
     $childRole = Role::getById($childRoleId);
     $this->assertEquals($childRole->id, $jim->role->id);
     // give jim rights to contact's module
     $jim->setRight('ContactsModule', ContactsModule::getAccessRight());
     $jim->setRight('ContactsModule', ContactsModule::getCreateRight());
     $this->assertTrue($jim->save());
     $jim->forgetAll();
     $jim = User::getByUsername('jim');
     // create jane's user
     $this->resetGetArray();
     $this->setPostArray(array('UserPasswordForm' => array('firstName' => 'Some', 'lastName' => 'Body', 'username' => 'jane', 'newPassword' => 'myPassword123', 'newPassword_repeat' => 'myPassword123', 'officePhone' => '456765421', 'userStatus' => 'Active', 'role' => array('id' => $parentRoleId))));
     $this->runControllerWithRedirectExceptionAndGetContent('/users/default/create');
     $jane = User::getByUsername('jane');
     $this->assertNotNull($jane);
     $parentRole->forgetAll();
     $parentRole = Role::getById($parentRoleId);
     $this->assertEquals($parentRole->id, $jane->role->id);
     // give jane rights to contact's module, we need to do this because once the link between parent and child
     // role is broken jane won't be able to access the listview of contacts
     $jane->setRight('ContactsModule', ContactsModule::getAccessRight());
     $this->assertTrue($jane->save());
     $jane->forgetAll();
     $jane = User::getByUsername('jane');
     // create a contact from jim's account
     // create ContactStates
     ContactsModule::loadStartingData();
     // ensure contact states have been created
     $this->assertEquals(6, count(ContactState::GetAll()));
     $this->logoutCurrentUserLoginNewUserAndGetByUsername('jim');
     // go ahead and create contact with parent role given readwrite.
     $startingState = ContactsUtil::getStartingState();
     $this->resetGetArray();
     $this->setPostArray(array('Contact' => array('firstName' => 'Jim', 'lastName' => 'Doe', 'officePhone' => '456765421', 'state' => array('id' => $startingState->id))));
     $url = $this->runControllerWithRedirectExceptionAndGetUrl('/contacts/default/create');
     $jimDoeContactId = intval(substr($url, strpos($url, 'id=') + 3));
     $jimDoeContact = Contact::getById($jimDoeContactId);
     $this->assertNotNull($jimDoeContact);
     $this->resetPostArray();
     $this->setGetArray(array('id' => $jimDoeContactId));
     $content = $this->runControllerWithNoExceptionsAndGetContent('/contacts/default/details');
     $this->assertContains('Who can read and write Owner', $content);
     // create a contact using jane which she would see at all times
     $this->logoutCurrentUserLoginNewUserAndGetByUsername('jane');
     $this->resetGetArray();
     $this->setPostArray(array('Contact' => array('firstName' => 'Jane', 'lastName' => 'Doe', 'officePhone' => '456765421', 'state' => array('id' => $startingState->id))));
     $url = $this->runControllerWithRedirectExceptionAndGetUrl('/contacts/default/create');
     $janeDoeContactId = intval(substr($url, strpos($url, 'id=') + 3));
     $janeDoeContact = Contact::getById($jimDoeContactId);
     $this->assertNotNull($janeDoeContact);
     $this->resetPostArray();
//.........这里部分代码省略.........
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:101,代码来源:ZurmoNestedRolePermissionsFlushWalkThroughTest.php

示例5: testRunWithCampaignPausedAfterAllItemsGeneratedAndThenUnpaused

 public function testRunWithCampaignPausedAfterAllItemsGeneratedAndThenUnpaused()
 {
     // Cleanup
     Campaign::deleteAll();
     $this->assertEquals(0, Campaign::getCount());
     $this->assertEquals(0, CampaignItem::getCount());
     $this->assertEquals(0, CampaignItemActivity::getCount());
     MarketingList::deleteAll();
     $this->assertEquals(0, MarketingList::getCount());
     $this->assertEquals(0, MarketingListMember::getCount());
     EmailMessage::deleteAll();
     $this->assertEquals(0, EmailMessage::getCount());
     $this->assertEquals(0, EmailMessageContent::getCount());
     $this->assertEquals(0, EmailMessageSender::getCount());
     $this->assertEquals(0, EmailMessageRecipient::getCount());
     Contact::deleteAll();
     $this->assertEquals(0, Contact::getCount());
     // setup an email address for contacts
     $email = new Email();
     $email->emailAddress = 'demo@zurmo.com';
     // create a marketing list with 5 members
     $marketingList = MarketingListTestHelper::createMarketingListByName('marketingList 05');
     $marketingListId = $marketingList->id;
     for ($i = 1; $i <= 5; $i++) {
         $contact = ContactTestHelper::createContactByNameForOwner('campaignContact 0' . $i, $this->user);
         $contact->primaryEmail = $email;
         $this->assertTrue($contact->save());
         MarketingListMemberTestHelper::createMarketingListMember(0, $marketingList, $contact);
     }
     $marketingList->forgetAll();
     // create a due campaign with that marketing list
     $campaign = CampaignTestHelper::createCampaign('campaign 04', 'subject', 'text Content', 'Html Content', null, null, null, null, null, null, MarketingList::getById($marketingListId));
     $campaignId = $campaign->id;
     /*
      * Run 1:
      * CampaignGenerateDueCampaignItemsJob
      * status == processing
      * items generated but unprocessed
      *
      * CampaignQueueMessagesInOutboxJob
      * status == processing
      * items processed with email messages generated and queued
      *
      * ProcessOutboundEmailJob
      * status == processing
      * email items attempted to be sent
      *
      * Run 2:
      * Pause the campaign
      * items are processed and still present
      *
      * Unpause the campaign
      * status == active
      * items are processed and still present
      *
      * CampaignGenerateDueCampaignItemsJob
      * status == processing
      * ensure all items are present and processed
      *
      * CampaignQueueMessagesInOutboxJob
      * status == processing
      * ensure all items are present and processed
      * ensure all email messages are present with correct folder type
      *
      * ProcessOutboundEmailJob
      * ensure all email messages are present with correct folder type
      * status == processing
      *
      *
      * Run 3:
      * Mark Campaign as Completed
      * status == completed
      */
     // we have to do this to ensure when we retrieve the data status is updated from db.
     $campaign->forgetAll();
     $this->assertEmpty(CampaignItem::getAll());
     // Run 1 starts here
     // Run CampaignGenerateDueCampaignItemsJob
     $job = new CampaignGenerateDueCampaignItemsJob();
     $this->assertTrue($job->run());
     $campaign = Campaign::getById($campaignId);
     // ensure status is processing
     $this->assertEquals(Campaign::STATUS_PROCESSING, $campaign->status);
     // ensure 5 campaign items have been generated
     $this->assertEquals(5, CampaignItem::getCount());
     // ensure all 5 campaign items are unprocessed
     $campaignItems = CampaignItem::getByProcessedAndCampaignId(0, $campaignId);
     $this->assertNotEmpty($campaignItems);
     $this->assertCount(5, $campaignItems);
     // Run CampaignQueueMessagesInOutboxJob
     $job = new CampaignQueueMessagesInOutboxJob();
     $this->assertTrue($job->run());
     // Ensure campaign status
     $campaign = Campaign::getById($campaignId);
     $this->assertEquals(Campaign::STATUS_PROCESSING, $campaign->status);
     // ensure all 5 campaign items are processed
     $campaignItems = CampaignItem::getByProcessedAndCampaignId(1, $campaignId);
     $this->assertNotEmpty($campaignItems);
     $this->assertCount(5, $campaignItems);
     // Ensure 5 new email messages
//.........这里部分代码省略.........
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:101,代码来源:CampaignMarkCompletedJobTest.php

示例6: setup

 public function setup()
 {
     $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     Contact::deleteAll();
     $this->clearAllCaches();
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:6,代码来源:ZurmoRecordSharingPerformanceBenchmarkTest.php

示例7: testBasicSearchContacts

 /**
  * @depends testUnprivilegedUserViewUpdateDeleteContacts
  */
 public function testBasicSearchContacts()
 {
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     Contact::deleteAll();
     $authenticationData = $this->login();
     $headers = array('Accept: application/json', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST');
     //Setup test data owned by the super user.
     $account = AccountTestHelper::createAccountByNameForOwner('superAccount', $super);
     $account2 = AccountTestHelper::createAccountByNameForOwner('superAccount2', $super);
     ContactTestHelper::createContactWithAccountByNameForOwner('First Contact', $super, $account);
     ContactTestHelper::createContactWithAccountByNameForOwner('Second Contact', $super, $account);
     ContactTestHelper::createContactWithAccountByNameForOwner('Third Contact', $super, $account);
     ContactTestHelper::createContactWithAccountByNameForOwner('Forth Contact', $super, $account2);
     ContactTestHelper::createContactWithAccountByNameForOwner('Fifth Contact', $super, $account2);
     LeadTestHelper::createLeadWithAccountByNameForOwner('First Lead', $super, $account);
     LeadTestHelper::createLeadWithAccountByNameForOwner('Second Lead', $super, $account2);
     $searchParams = array('pagination' => array('page' => 1, 'pageSize' => 3), 'search' => array('firstName' => ''), 'sort' => 'firstName');
     $searchParamsQuery = http_build_query($searchParams);
     $response = $this->createApiCallWithRelativeUrl('list/filter/' . $searchParamsQuery, 'GET', $headers);
     $response = json_decode($response, true);
     $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
     $this->assertEquals(3, count($response['data']['items']));
     $this->assertEquals(5, $response['data']['totalCount']);
     $this->assertEquals(1, $response['data']['currentPage']);
     $this->assertEquals('Fifth Contact', $response['data']['items'][0]['firstName']);
     $this->assertEquals('First Contact', $response['data']['items'][1]['firstName']);
     $this->assertEquals('Forth Contact', $response['data']['items'][2]['firstName']);
     // Second page
     $searchParams['pagination']['page'] = 2;
     $searchParamsQuery = http_build_query($searchParams);
     $response = $this->createApiCallWithRelativeUrl('list/filter/' . $searchParamsQuery, 'GET', $headers);
     $response = json_decode($response, true);
     $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
     $this->assertEquals(2, count($response['data']['items']));
     $this->assertEquals(5, $response['data']['totalCount']);
     $this->assertEquals(2, $response['data']['currentPage']);
     $this->assertEquals('Second Contact', $response['data']['items'][0]['firstName']);
     $this->assertEquals('Third Contact', $response['data']['items'][1]['firstName']);
     // Search by name
     $searchParams['pagination']['page'] = 1;
     $searchParams['search']['firstName'] = 'First Contact';
     $searchParamsQuery = http_build_query($searchParams);
     $response = $this->createApiCallWithRelativeUrl('list/filter/' . $searchParamsQuery, 'GET', $headers);
     $response = json_decode($response, true);
     $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
     $this->assertEquals(1, count($response['data']['items']));
     $this->assertEquals(1, $response['data']['totalCount']);
     $this->assertEquals(1, $response['data']['currentPage']);
     $this->assertEquals('First Contact', $response['data']['items'][0]['firstName']);
     // No results
     $searchParams['pagination']['page'] = 1;
     $searchParams['search']['firstName'] = 'First Contact 2';
     $searchParamsQuery = http_build_query($searchParams);
     $response = $this->createApiCallWithRelativeUrl('list/filter/' . $searchParamsQuery, 'GET', $headers);
     $response = json_decode($response, true);
     $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
     $this->assertEquals(0, $response['data']['totalCount']);
     $this->assertFalse(isset($response['data']['items']));
     // Search by name desc.
     $searchParams = array('pagination' => array('page' => 1, 'pageSize' => 3), 'search' => array('firstName' => ''), 'sort' => 'firstName.desc');
     $searchParamsQuery = http_build_query($searchParams);
     $response = $this->createApiCallWithRelativeUrl('list/filter/' . $searchParamsQuery, 'GET', $headers);
     $response = json_decode($response, true);
     $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
     $this->assertEquals(3, count($response['data']['items']));
     $this->assertEquals(5, $response['data']['totalCount']);
     $this->assertEquals(1, $response['data']['currentPage']);
     $this->assertEquals('Third Contact', $response['data']['items'][0]['firstName']);
     $this->assertEquals('Second Contact', $response['data']['items'][1]['firstName']);
     $this->assertEquals('Forth Contact', $response['data']['items'][2]['firstName']);
     // Second page
     $searchParams['pagination']['page'] = 2;
     $searchParamsQuery = http_build_query($searchParams);
     $response = $this->createApiCallWithRelativeUrl('list/filter/' . $searchParamsQuery, 'GET', $headers);
     $response = json_decode($response, true);
     $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
     $this->assertEquals(2, count($response['data']['items']));
     $this->assertEquals(5, $response['data']['totalCount']);
     $this->assertEquals(2, $response['data']['currentPage']);
     $this->assertEquals('First Contact', $response['data']['items'][0]['firstName']);
     $this->assertEquals('Fifth Contact', $response['data']['items'][1]['firstName']);
     // Search by custom fields, order by name desc
     $searchParams = array('pagination' => array('page' => 1, 'pageSize' => 3), 'search' => array('account' => array('id' => $account2->id), 'owner' => array('id' => $super->id)), 'sort' => 'firstName.desc');
     $searchParamsQuery = http_build_query($searchParams);
     $response = $this->createApiCallWithRelativeUrl('list/filter/' . $searchParamsQuery, 'GET', $headers);
     $response = json_decode($response, true);
     $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
     $this->assertEquals(2, $response['data']['totalCount']);
     $this->assertEquals(2, count($response['data']['items']));
     $this->assertEquals(1, $response['data']['currentPage']);
     $this->assertEquals('Forth Contact', $response['data']['items'][0]['firstName']);
     $this->assertEquals('Fifth Contact', $response['data']['items'][1]['firstName']);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:97,代码来源:ApiRestContactTest.php

示例8: tearDown

 protected function tearDown()
 {
     Category::deleteAll();
     Contact::deleteAll();
 }
开发者ID:julianstewart,项目名称:address_book,代码行数:5,代码来源:CategoryTest.php

示例9: deleteAll

 static function deleteAll()
 {
     Contact::deleteAll();
 }
开发者ID:jwuerch,项目名称:Address-Book-PHP,代码行数:4,代码来源:contact.php

示例10: testArePermissionsFlushedOnRemovingParentFromChildGroup

 public function testArePermissionsFlushedOnRemovingParentFromChildGroup()
 {
     // cleanup
     Contact::deleteAll();
     try {
         $group = Group::getByName('Child');
         $group->delete();
     } catch (NotFoundException $e) {
     }
     try {
         $user = User::getByUsername('jim');
         $user->delete();
     } catch (NotFoundException $e) {
     }
     // we could have used helpers to do a lot of the following stuff (such as creating users, groups,
     // etc) but we wanted to mimic user's interaction as closely as possible. Hence using walkthroughs
     // for everything
     // create Parent and Child Groups, Create Jim to be member of Child group
     // create parent group
     $this->resetGetArray();
     $this->setPostArray(array('Group' => array('name' => 'Parent')));
     $this->runControllerWithRedirectExceptionAndGetUrl('/zurmo/group/create');
     $parentGroup = Group::getByName('Parent');
     $this->assertNotNull($parentGroup);
     $this->assertEquals('Parent', strval($parentGroup));
     $parentGroupId = $parentGroup->id;
     // create child group
     $this->resetGetArray();
     $this->setPostArray(array('Group' => array('name' => 'Child', 'group' => array('id' => $parentGroupId))));
     $this->runControllerWithRedirectExceptionAndGetUrl('/zurmo/group/create');
     $childGroup = Group::getByName('Child');
     $this->assertNotNull($childGroup);
     $this->assertEquals('Child', strval($childGroup));
     $parentGroup->forgetAll();
     $parentGroup = Group::getById($parentGroupId);
     // give child rights for contacts module
     $childGroup->setRight('ContactsModule', ContactsModule::getAccessRight());
     $childGroup->setRight('ContactsModule', ContactsModule::getCreateRight());
     $this->assertTrue($childGroup->save());
     $childGroupId = $childGroup->id;
     $childGroup->forgetAll();
     $childGroup = Group::getById($childGroupId);
     $this->assertContains($childGroup, $parentGroup->groups);
     // create jim's user
     $this->resetGetArray();
     $this->setPostArray(array('UserPasswordForm' => array('firstName' => 'Some', 'lastName' => 'Body', 'username' => 'jim', 'newPassword' => 'myPassword123', 'newPassword_repeat' => 'myPassword123', 'officePhone' => '456765421', 'userStatus' => 'Active')));
     $this->runControllerWithRedirectExceptionAndGetContent('/users/default/create');
     $jim = User::getByUsername('jim');
     $this->assertNotNull($jim);
     // set jim's group to child group
     $this->setGetArray(array('id' => $childGroup->id));
     $this->setPostArray(array('GroupUserMembershipForm' => array('userMembershipData' => array($jim->id))));
     $this->runControllerWithRedirectExceptionAndGetUrl('/zurmo/group/editUserMembership');
     $jim->forgetAll();
     $jim = User::getByUsername('jim');
     $this->assertNotNull($jim);
     $childGroup->forgetAll();
     $childGroup = Group::getById($childGroupId);
     $this->assertContains($childGroup, $jim->groups);
     // create a contact with permissions to Parent group
     // create ContactStates
     ContactsModule::loadStartingData();
     // ensure contact states have been created
     $this->assertEquals(6, count(ContactState::GetAll()));
     // go ahead and create contact with parent group given readwrite.
     $startingState = ContactsUtil::getStartingState();
     $this->resetGetArray();
     $this->setPostArray(array('Contact' => array('firstName' => 'John', 'lastName' => 'Doe', 'officePhone' => '456765421', 'state' => array('id' => $startingState->id), 'explicitReadWriteModelPermissions' => array('type' => ExplicitReadWriteModelPermissionsUtil::MIXED_TYPE_NONEVERYONE_GROUP, 'nonEveryoneGroup' => $parentGroupId))));
     $url = $this->runControllerWithRedirectExceptionAndGetUrl('/contacts/default/create');
     $johnDoeContactId = intval(substr($url, strpos($url, 'id=') + 3));
     $johnDoeContact = Contact::getById($johnDoeContactId);
     $this->assertNotNull($johnDoeContact);
     $this->resetPostArray();
     $this->setGetArray(array('id' => $johnDoeContactId));
     $content = $this->runControllerWithNoExceptionsAndGetContent('/contacts/default/details');
     $this->assertContains('Who can read and write Parent', $content);
     // create a contact using jim which he would see at all times
     $this->logoutCurrentUserLoginNewUserAndGetByUsername('jim');
     $this->resetGetArray();
     $this->setPostArray(array('Contact' => array('firstName' => 'Jim', 'lastName' => 'Doe', 'officePhone' => '456765421', 'state' => array('id' => $startingState->id))));
     $url = $this->runControllerWithRedirectExceptionAndGetUrl('/contacts/default/create');
     $jimDoeContactId = intval(substr($url, strpos($url, 'id=') + 3));
     $jimDoeContact = Contact::getById($jimDoeContactId);
     $this->assertNotNull($jimDoeContact);
     $this->resetPostArray();
     $this->setGetArray(array('id' => $jimDoeContactId));
     $this->runControllerWithNoExceptionsAndGetContent('/contacts/default/details');
     // ensure jim can see that contact everywhere
     // jim should have access to see contact on list view
     $this->resetGetArray();
     // get the page, ensure the name of contact does show up there.
     $content = $this->runControllerWithNoExceptionsAndGetContent('/contacts/default');
     $this->assertContains('John Doe</a></td><td>', $content);
     $this->assertContains('Jim Doe</a></td><td>', $content);
     // jim should have access to jimDoeContact's detail view
     $this->setGetArray(array('id' => $jimDoeContactId));
     $this->runControllerWithNoExceptionsAndGetContent('/contacts/default/details');
     // jim should have access to jimDoeContact's edit view
     $this->runControllerWithNoExceptionsAndGetContent('/contacts/default/edit');
     // jim should have access to johnDoeContact's detail view
//.........这里部分代码省略.........
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:101,代码来源:ZurmoNestedGroupPermissionsFlushWalkThroughTest.php

示例11: testImportWithLatestActivityDateTime

 public function testImportWithLatestActivityDateTime()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $contacts = Contact::deleteAll();
     $import = new Import();
     $serializedData['importRulesType'] = 'Contacts';
     $serializedData['firstRowIsHeaderRow'] = true;
     $import->serializedData = serialize($serializedData);
     $this->assertTrue($import->save());
     ImportTestHelper::createTempTableByFileNameAndTableName('importWithLatestActivityDateTimeTest.csv', $import->getTempTableName(), true, Yii::getPathOfAlias('application.modules.contacts.tests.unit.files'));
     $mappingData = array('column_0' => ImportMappingUtil::makeStringColumnMappingData('lastName'), 'column_1' => ContactImportTestHelper::makeStateColumnMappingData(), 'column_2' => ImportMappingUtil::makeDateTimeColumnMappingData('latestActivityDateTime'));
     $importRules = ImportRulesUtil::makeImportRulesByType('Contacts');
     $page = 0;
     $config = array('pagination' => array('pageSize' => 50));
     //This way all rows are processed.
     $dataProvider = new ImportDataProvider($import->getTempTableName(), true, $config);
     $dataProvider->getPagination()->setCurrentPage($page);
     $importResultsUtil = new ImportResultsUtil($import);
     $messageLogger = new ImportMessageLogger();
     ImportUtil::importByDataProvider($dataProvider, $importRules, $mappingData, $importResultsUtil, new ExplicitReadWriteModelPermissions(), $messageLogger);
     $importResultsUtil->processStatusAndMessagesForEachRow();
     //Confirm that 2 models where created.
     $contacts = Contact::getAll();
     $this->assertCount(2, $contacts);
     $this->assertEquals('2011-12-22 05:03', substr($contacts[0]->latestActivityDateTime, 0, -3));
     $this->assertNull($contacts[1]->latestActivityDateTime);
     //Confirm 2 rows were processed as 'created'.
     $this->assertEquals(2, ImportDatabaseUtil::getCount($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::CREATED));
     //Confirm that 0 rows were processed as 'updated'.
     $this->assertEquals(0, ImportDatabaseUtil::getCount($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::UPDATED));
     //Confirm 0 rows were processed as 'errors'.
     $this->assertEquals(0, ImportDatabaseUtil::getCount($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::ERROR));
     $beansWithErrors = ImportDatabaseUtil::getSubset($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::ERROR);
     $this->assertEquals(0, count($beansWithErrors));
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:35,代码来源:ContactImportTest.php

示例12: testAsynchronousDownloadDefaultControllerActions

 /**
  * Walkthrough test for synchronous download
  */
 public function testAsynchronousDownloadDefaultControllerActions()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $account = AccountTestHelper::createAccountByNameForOwner('superAccount2', $super);
     $notificationsBeforeCount = Notification::getCount();
     $notificationMessagesBeforeCount = NotificationMessage::getCount();
     Contact::deleteAll();
     $leads = array();
     for ($i = 0; $i <= ExportModule::$asynchronousThreshold + 1; $i++) {
         $leads[] = LeadTestHelper::createLeadWithAccountByNameForOwner('superContact' . $i, $super, $account);
     }
     $this->setGetArray(array('Contact_page' => '1', 'export' => '', 'ajax' => '', 'selectAll' => '1', 'selectedIds' => ''));
     $this->runControllerWithRedirectExceptionAndGetUrl('leads/default/export');
     // Start background job
     $job = new ExportJob();
     $this->assertTrue($job->run());
     $exportItems = ExportItem::getAll();
     $this->assertEquals(1, count($exportItems));
     $fileModel = $exportItems[0]->exportFileModel;
     $this->assertEquals(1, $exportItems[0]->isCompleted);
     $this->assertEquals('csv', $exportItems[0]->exportFileType);
     $this->assertEquals('leads', $exportItems[0]->exportFileName);
     $this->assertTrue($fileModel instanceof ExportFileModel);
     $this->assertEquals($notificationsBeforeCount + 1, Notification::getCount());
     $this->assertEquals($notificationMessagesBeforeCount + 1, NotificationMessage::getCount());
     // Check export job, when many ids are selected.
     // This will probably never happen, but we need test for this case too.
     $notificationsBeforeCount = Notification::getCount();
     $notificationMessagesBeforeCount = NotificationMessage::getCount();
     // Now test case when multiple ids are selected
     ExportItem::deleteAll();
     $selectedIds = "";
     foreach ($leads as $lead) {
         $selectedIds .= $lead->id . ",";
         // Not Coding Standard
     }
     $this->setGetArray(array('LeadsSearchForm' => array('anyMixedAttributesScope' => array(0 => 'All'), 'anyMixedAttributes' => '', 'fullName' => '', 'officePhone' => ''), 'multiselect_ContactsSearchForm_anyMixedAttributesScope' => 'All', 'Contact_page' => '1', 'export' => '', 'ajax' => '', 'selectAll' => '', 'selectedIds' => "{$selectedIds}"));
     $this->runControllerWithRedirectExceptionAndGetUrl('leads/default/export');
     // Start background job
     $job = new ExportJob();
     $this->assertTrue($job->run());
     $exportItems = ExportItem::getAll();
     $this->assertEquals(1, count($exportItems));
     $fileModel = $exportItems[0]->exportFileModel;
     $this->assertEquals(1, $exportItems[0]->isCompleted);
     $this->assertEquals('csv', $exportItems[0]->exportFileType);
     $this->assertEquals('leads', $exportItems[0]->exportFileName);
     $this->assertTrue($fileModel instanceof ExportFileModel);
     $this->assertEquals($notificationsBeforeCount + 1, Notification::getCount());
     $this->assertEquals($notificationMessagesBeforeCount + 1, NotificationMessage::getCount());
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:54,代码来源:LeadsSuperUserExportWalkthroughTest.php

示例13: redirect_to

		</ul>

		<?php 
        break;
        // Delete account
    // Delete account
    case 'delete':
        if (!Config::get('auth.delete_account')) {
            redirect_to('?p=account');
        }
        if (isset($_POST['submit']) && csrf_filter()) {
            $id = Auth::user()->id;
            User::where('id', $id)->limit(1)->delete();
            Usermeta::delete($id);
            Message::newQuery()->where('to_user', $id)->orWhere('from_user', $id)->delete();
            Contact::deleteAll($id);
            Comments::deleteUserComments($id);
            Auth::logout();
            redirect_to(App::url());
        }
        ?>
		<h3 class="page-header"><?php 
        echo _e('main.delete_account');
        ?>
</h3>
		<?php 
        _e('main.delete_account_message');
        ?>
		<form action="" method="POST">
			<?php 
        csrf_input();
开发者ID:vladvoth,项目名称:productclash,代码行数:31,代码来源:settings.php

示例14: ajax_delete_user

function ajax_delete_user()
{
    if (!Auth::userCan('delete_users')) {
        json_message(trans('errors.permission'), false);
    }
    $id = isset($_POST['user_id']) ? (int) $_POST['user_id'] : 0;
    if (Auth::user()->id != $id) {
        User::where('id', $id)->limit(1)->delete();
        Usermeta::newQuery()->where('user_id', $id)->delete();
        Message::newQuery()->where('to_user', $id)->orWhere('from_user', $id)->delete();
        Contact::deleteAll($id);
        Comments::deleteUserComments($id);
    }
    json_message();
}
开发者ID:vladvoth,项目名称:productclash,代码行数:15,代码来源:ajax.php


注:本文中的Contact::deleteAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。