mirror of
https://github.com/salesagility/SuiteCRM.git
synced 2024-11-25 00:56:49 +00:00
328 lines
12 KiB
PHP
328 lines
12 KiB
PHP
<?php
|
|
/**
|
|
* SugarCRM Community Edition is a customer relationship management program developed by
|
|
* SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
|
|
*
|
|
* SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd.
|
|
* Copyright (C) 2011 - 2021 SalesAgility Ltd.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify it under
|
|
* the terms of the GNU Affero General Public License version 3 as published by the
|
|
* Free Software Foundation with the addition of the following permission added
|
|
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
|
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
|
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
|
*
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
|
* details.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public License along with
|
|
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
|
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
* 02110-1301 USA.
|
|
*
|
|
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
|
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
|
*
|
|
* The interactive user interfaces in modified source and object code versions
|
|
* of this program must display Appropriate Legal Notices, as required under
|
|
* Section 5 of the GNU Affero General Public License version 3.
|
|
*
|
|
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
|
* these Appropriate Legal Notices must retain the display of the "Powered by
|
|
* SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not
|
|
* reasonably feasible for technical reasons, the Appropriate Legal Notices must
|
|
* display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM".
|
|
*/
|
|
|
|
use Faker\Generator;
|
|
use SuiteCRM\Enumerator\SugarObjectType;
|
|
|
|
#[\AllowDynamicProperties]
|
|
class FileModuleCest
|
|
{
|
|
/**
|
|
* @var Generator $fakeData
|
|
*/
|
|
protected $fakeData;
|
|
|
|
/**
|
|
* @var integer $fakeDataSeed
|
|
*/
|
|
protected $fakeDataSeed;
|
|
|
|
/**
|
|
* @param AcceptanceTester $I
|
|
*/
|
|
public function _before(AcceptanceTester $I)
|
|
{
|
|
if (!$this->fakeData) {
|
|
$this->fakeData = Faker\Factory::create();
|
|
$this->fakeDataSeed = mt_rand(0, 2048);
|
|
}
|
|
$this->fakeData->seed($this->fakeDataSeed);
|
|
}
|
|
|
|
/**
|
|
* @param AcceptanceTester $I
|
|
*/
|
|
public function _after(AcceptanceTester $I)
|
|
{
|
|
}
|
|
|
|
// Tests
|
|
/**
|
|
* @param \AcceptanceTester $I
|
|
* @param \Step\Acceptance\ModuleBuilder $moduleBuilder
|
|
*
|
|
* As an administrator I want to create and deploy a file module so that I can test
|
|
* that the file functionality is working. Given that I have already created a module I expect to deploy
|
|
* the module before testing.
|
|
*/
|
|
public function testScenarioCreateFileModule(
|
|
\AcceptanceTester $I,
|
|
\Step\Acceptance\ModuleBuilder $moduleBuilder
|
|
) {
|
|
$I->wantTo('Create a file module for testing');
|
|
|
|
$I->loginAsAdmin();
|
|
|
|
$moduleBuilder->createModule(
|
|
\Page\FileModule::$PACKAGE_NAME,
|
|
\Page\FileModule::$NAME,
|
|
SugarObjectType::file
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @param \AcceptanceTester $I
|
|
* @param \Step\Acceptance\NavigationBarTester $navigationBar
|
|
* @param \Step\Acceptance\ListView $listView
|
|
*
|
|
* As administrative user I want to view my file test module so that I can see if it has been
|
|
* deployed correctly.
|
|
*/
|
|
public function testScenarioViewFileTestModule(
|
|
\AcceptanceTester $I,
|
|
\Step\Acceptance\NavigationBarTester $navigationBar,
|
|
\Step\Acceptance\ListView $listView
|
|
) {
|
|
$I->wantTo('View File Test Module');
|
|
$I->loginAsAdmin();
|
|
|
|
// Navigate to module
|
|
$navigationBar->clickAllMenuItem(\Page\FileModule::$NAME);
|
|
|
|
$listView->waitForListViewVisible();
|
|
}
|
|
|
|
/**
|
|
* @param \AcceptanceTester $I
|
|
* @param \Step\Acceptance\NavigationBarTester $navigationBar
|
|
* @param \Step\Acceptance\ListView $listView
|
|
* @param \Step\Acceptance\DetailView $detailview
|
|
* @param \Step\Acceptance\EditView $editView
|
|
*
|
|
* As administrative user I want to create a record with my file test module so that I can test
|
|
* the standard fields.
|
|
*/
|
|
public function testScenarioCreateRecord(
|
|
\AcceptanceTester $I,
|
|
\Step\Acceptance\NavigationBarTester $navigationBar,
|
|
\Step\Acceptance\ListView $listView,
|
|
\Step\Acceptance\DetailView $detailview,
|
|
\Step\Acceptance\EditView $editView
|
|
) {
|
|
$I->wantTo('Create File Test Module Record');
|
|
$I->loginAsAdmin();
|
|
|
|
// Go to File Test Module
|
|
$navigationBar->clickAllMenuItem(\Page\FileModule::$NAME);
|
|
$listView->waitForListViewVisible();
|
|
|
|
// Select create File Test Module form the current menu
|
|
$navigationBar->clickCurrentMenuItem('Create ' . \Page\FileModule::$NAME);
|
|
|
|
// Create a record
|
|
$this->fakeData->seed($this->fakeDataSeed);
|
|
$editView->waitForEditViewVisible();
|
|
$fileDir = 'tests/_data/';
|
|
$fileName = $this->fakeData->lastName.'.test.txt';
|
|
$I->writeToFile($fileDir.$fileName, 'test file');
|
|
$editView->attachFile('#uploadfile_file', $fileName);
|
|
$I->wait(1);
|
|
$editView->seeInField('#document_name', $fileName);
|
|
$editView->fillField('#description', $this->fakeData->paragraph);
|
|
// TODO: other fields
|
|
$editView->clickSaveButton();
|
|
$detailview->waitForDetailViewVisible();
|
|
$detailview->see($fileName, '#uploadfile');
|
|
|
|
$I->deleteFile($fileDir.$fileName);
|
|
}
|
|
|
|
/**
|
|
* @param \AcceptanceTester $I
|
|
* @param \Step\Acceptance\NavigationBarTester $navigationBar
|
|
* @param \Step\Acceptance\ListView $listView
|
|
* @param \Step\Acceptance\DetailView $detailView
|
|
*
|
|
* As administrative user I want to view the record by selecting it in the list view
|
|
*/
|
|
public function testScenarioViewRecordFromListView(
|
|
\AcceptanceTester $I,
|
|
\Step\Acceptance\NavigationBarTester $navigationBar,
|
|
\Step\Acceptance\ListView $listView,
|
|
\Step\Acceptance\DetailView $detailView
|
|
) {
|
|
$I->wantTo('Select Record from list view');
|
|
|
|
$I->loginAsAdmin();
|
|
|
|
// Go to File Test Module
|
|
$navigationBar->clickAllMenuItem(\Page\FileModule::$NAME);
|
|
$listView->waitForListViewVisible();
|
|
|
|
$this->fakeData->seed($this->fakeDataSeed);
|
|
$listView->clickFilterButton();
|
|
$listView->click('Quick Filter');
|
|
$this->fakeData->seed($this->fakeDataSeed);
|
|
$listView->fillField('#document_name_basic', $this->fakeData->lastName . '.test.txt');
|
|
$listView->click('Search', '.submitButtons');
|
|
$listView->wait(1);
|
|
|
|
$this->fakeData->seed($this->fakeDataSeed);
|
|
$listView->clickNameLink($this->fakeData->lastName . '.test.txt');
|
|
$detailView->waitForDetailViewVisible();
|
|
}
|
|
|
|
/**
|
|
* @param \AcceptanceTester $I
|
|
* @param \Step\Acceptance\NavigationBarTester $navigationBar
|
|
* @param \Step\Acceptance\ListView $listView
|
|
* @param \Step\Acceptance\DetailView $detailView
|
|
* @param \Step\Acceptance\EditView $editView
|
|
*
|
|
* As administrative user I want to edit the record by selecting it in the detail view
|
|
*/
|
|
public function testScenarioEditRecordFromDetailView(
|
|
\AcceptanceTester$I,
|
|
\Step\Acceptance\NavigationBarTester $navigationBar,
|
|
\Step\Acceptance\ListView $listView,
|
|
\Step\Acceptance\DetailView $detailView,
|
|
\Step\Acceptance\EditView $editView
|
|
) {
|
|
$I->wantTo('Edit File Test Module Record from detail view');
|
|
$I->loginAsAdmin();
|
|
|
|
// Go to File Test Module
|
|
$navigationBar->clickAllMenuItem(\Page\FileModule::$NAME);
|
|
$listView->waitForListViewVisible();
|
|
|
|
// Select record from list view
|
|
$listView->clickFilterButton();
|
|
$listView->click('Quick Filter');
|
|
$this->fakeData->seed($this->fakeDataSeed);
|
|
$listView->fillField('#document_name_basic', $this->fakeData->lastName . '.test.txt');
|
|
$listView->click('Search', '.submitButtons');
|
|
$listView->wait(1);
|
|
$this->fakeData->seed($this->fakeDataSeed);
|
|
$listView->clickNameLink($this->fakeData->lastName . '.test.txt');
|
|
// Edit Record
|
|
$detailView->clickActionMenuItem('Edit');
|
|
|
|
// Save record
|
|
$editView->click('Save');
|
|
|
|
$detailView->waitForDetailViewVisible();
|
|
}
|
|
|
|
/**
|
|
* @param \AcceptanceTester $I
|
|
* @param \Step\Acceptance\NavigationBarTester $navigationBar
|
|
* @param \Step\Acceptance\ListView $listView
|
|
* @param \Step\Acceptance\DetailView $detailView
|
|
* @param \Step\Acceptance\EditView $editView
|
|
*
|
|
* As administrative user I want to duplicate the record
|
|
*/
|
|
public function testScenarioDuplicateRecordFromDetailView(
|
|
\AcceptanceTester $I,
|
|
\Step\Acceptance\NavigationBarTester $navigationBar,
|
|
\Step\Acceptance\ListView $listView,
|
|
\Step\Acceptance\DetailView $detailView,
|
|
\Step\Acceptance\EditView $editView
|
|
) {
|
|
$I->wantTo('Duplicate File Test Module Record from detail view');
|
|
$I->loginAsAdmin();
|
|
|
|
// Go to File Test Module
|
|
$navigationBar->clickAllMenuItem(\Page\FileModule::$NAME);
|
|
$listView->waitForListViewVisible();
|
|
|
|
// Select record from list view
|
|
$listView->clickFilterButton();
|
|
$listView->click('Quick Filter');
|
|
$this->fakeData->seed($this->fakeDataSeed);
|
|
$listView->fillField('#document_name_basic', $this->fakeData->lastName . '.test.txt');
|
|
$listView->click('Search', '.submitButtons');
|
|
$listView->wait(1);
|
|
$this->fakeData->seed($this->fakeDataSeed);
|
|
$listView->clickNameLink($this->fakeData->lastName . '.test.txt');
|
|
|
|
// Edit Record
|
|
$detailView->clickActionMenuItem('Duplicate');
|
|
|
|
$this->fakeData->seed($this->fakeDataSeed);
|
|
$editView->fillField('#document_name', $this->fakeData->lastName.'.test.txt' . '1');
|
|
|
|
// Save record
|
|
$editView->click('Save');
|
|
|
|
$detailView->waitForDetailViewVisible();
|
|
$detailView->clickActionMenuItem('Delete');
|
|
$detailView->acceptPopup();
|
|
|
|
$listView->waitForListViewVisible();
|
|
}
|
|
|
|
/**
|
|
* @param \AcceptanceTester $I
|
|
* @param \Step\Acceptance\NavigationBarTester $navigationBar
|
|
* @param \Step\Acceptance\ListView $listView
|
|
* @param \Step\Acceptance\DetailView $detailView
|
|
*
|
|
* As administrative user I want to delete the record by selecting it in the detail view
|
|
*/
|
|
public function testScenarioDeleteRecordFromDetailView(
|
|
\AcceptanceTester $I,
|
|
\Step\Acceptance\NavigationBarTester $navigationBar,
|
|
\Step\Acceptance\ListView $listView,
|
|
\Step\Acceptance\DetailView $detailView
|
|
) {
|
|
$I->wantTo('Delete File Test Module Record from detail view');
|
|
$I->loginAsAdmin();
|
|
|
|
// Go to File Test Module
|
|
$navigationBar->clickAllMenuItem(\Page\FileModule::$NAME);
|
|
$listView->waitForListViewVisible();
|
|
|
|
// Select record from list view
|
|
$listView->clickFilterButton();
|
|
$listView->click('Quick Filter');
|
|
$this->fakeData->seed($this->fakeDataSeed);
|
|
$listView->fillField('#document_name_basic', $this->fakeData->lastName);
|
|
$listView->click('Search', '.submitButtons');
|
|
$listView->wait(1);
|
|
$this->fakeData->seed($this->fakeDataSeed);
|
|
$listView->clickNameLink($this->fakeData->lastName . '.test.txt');
|
|
// Delete Record
|
|
$detailView->clickActionMenuItem('Delete');
|
|
$detailView->acceptPopup();
|
|
|
|
$listView->waitForListViewVisible();
|
|
}
|
|
}
|