mirror of
https://github.com/salesagility/SuiteCRM.git
synced 2025-02-22 13:08:39 +00:00

- File: '... /tests/unit/phpunit/include/MVC/View/views/view.quickTest.php' - Replaced 2 occurrence(s) of 'new User()' - File: '... /tests/unit/phpunit/include/MVC/View/views/view.sugarpdfTest.php' - Replaced 1 occurrence(s) of 'new User()' - File: '... /tests/unit/phpunit/include/MVC/View/views/view.ajaxTest.php' - Replaced 1 occurrence(s) of 'new User()' - File: '... /tests/unit/phpunit/include/MVC/View/views/view.quickcreateTest.php' - Replaced 1 occurrence(s) of 'new Account()' - Replaced 1 occurrence(s) of 'new User()' - File: '... /tests/unit/phpunit/include/MVC/View/views/view.multieditTest.php' - Replaced 1 occurrence(s) of 'new User()' - File: '... /tests/unit/phpunit/include/MVC/View/views/view.popupTest.php' - Replaced 1 occurrence(s) of 'new User()' - File: '... /tests/unit/phpunit/include/MVC/View/views/view.vcardTest.php' - Replaced 1 occurrence(s) of 'new Contact()' - Replaced 1 occurrence(s) of 'new User()' - File: '... /tests/unit/phpunit/include/MVC/View/views/view.serializedTest.php' - Replaced 1 occurrence(s) of 'new User()' - File: '... /tests/unit/phpunit/include/MVC/View/views/view.classicTest.php' - Replaced 2 occurrence(s) of 'new User()' - File: '... /tests/unit/phpunit/include/MVC/View/views/view.jsonTest.php' - Replaced 1 occurrence(s) of 'new User()'
138 lines
3.7 KiB
PHP
138 lines
3.7 KiB
PHP
<?php
|
|
|
|
use SuiteCRM\Test\SuitePHPUnitFrameworkTestCase;
|
|
|
|
class ViewPopupTest extends SuitePHPUnitFrameworkTestCase
|
|
{
|
|
public function setUp()
|
|
{
|
|
parent::setUp();
|
|
|
|
global $current_user;
|
|
get_sugar_config_defaults();
|
|
$current_user = BeanFactory::newBean('Users');
|
|
}
|
|
|
|
public function testViewPopup()
|
|
{
|
|
// Execute the constructor and check for the Object type and type attribute
|
|
$view = new ViewPopup();
|
|
$this->assertInstanceOf('ViewPopup', $view);
|
|
$this->assertInstanceOf('SugarView', $view);
|
|
$this->assertAttributeEquals('list', 'type', $view);
|
|
|
|
unset($view);
|
|
}
|
|
|
|
public function testdisplay()
|
|
{
|
|
if (isset($_SESSION)) {
|
|
$session = $_SESSION;
|
|
}
|
|
|
|
//execute the method with required child objects preset. it should return some html.
|
|
$view = new ViewPopup();
|
|
$view->module = 'Accounts';
|
|
|
|
try {
|
|
$view->bean = BeanFactory::getBean('Accounts');
|
|
self::assertTrue(false);
|
|
} catch (Exception $e) {
|
|
self::assertTrue(true);
|
|
}
|
|
|
|
if (isset($session)) {
|
|
$_SESSION = $session;
|
|
} else {
|
|
unset($_SESSION);
|
|
}
|
|
}
|
|
|
|
public function testdisplayGetModulePopupPickerIfNoListviewsSearchDefs()
|
|
{
|
|
$view = new ViewPopup();
|
|
$view->module = 'Audit'; // Confirms has no listview/searchdefs
|
|
|
|
$customPath = 'custom/modules/' . $view->module . '/Popup_picker.php';
|
|
$modulePath = 'modules/' . $view->module . '/Popup_picker.php';
|
|
|
|
// test no custom module Popup picker
|
|
// test module Popup picker exists
|
|
|
|
$this->assertFileNotExists($customPath);
|
|
|
|
$result = get_custom_file_if_exists($modulePath);
|
|
|
|
$this->assertSame($modulePath, $result);
|
|
|
|
// Now add a custom module Popup picker
|
|
|
|
// Create mock file
|
|
// @TODO set up vfsStream and test get_custom_file_if_exists
|
|
|
|
$dirname = dirname($customPath);
|
|
if (!is_dir($dirname)) {
|
|
mkdir($dirname, 0755, true);
|
|
}
|
|
|
|
file_put_contents($customPath, '');
|
|
|
|
$this->assertFileExists($customPath);
|
|
|
|
$result = get_custom_file_if_exists($modulePath);
|
|
|
|
$this->assertSame($customPath, $result);
|
|
|
|
// Cleanup
|
|
unlink($customPath);
|
|
rmdir($dirname);
|
|
}
|
|
|
|
public function testdisplayGetCustomDefaultPopupPickerIdNoModulePopupPicker()
|
|
{
|
|
$view = new ViewPopup();
|
|
$view->module = 'Accounts'; // Confirms has no Popup_picker
|
|
|
|
$modulePath = 'modules/' . $view->module . '/Popup_picker.php';
|
|
$customPath = 'custom/include/Popups/Popup_picker.php';
|
|
$defaultPath = 'include/Popups/Popup_picker.php';
|
|
|
|
// test no module Popup picker
|
|
// test default Popup picker exists
|
|
// test no custom default Popup picker exists
|
|
|
|
$result1 = get_custom_file_if_exists($modulePath);
|
|
$result2 = file_exists($result1);
|
|
|
|
$this->assertFalse($result2);
|
|
|
|
$this->assertFileNotExists($customPath);
|
|
$this->assertFileExists($defaultPath);
|
|
|
|
$result = get_custom_file_if_exists($defaultPath);
|
|
|
|
$this->assertSame($defaultPath, $result);
|
|
|
|
// Now add a custom Popup picker
|
|
|
|
// Create mock file
|
|
// @TODO set up vfsStream and test get_custom_file_if_exists
|
|
|
|
$dirname = dirname($customPath);
|
|
if (!is_dir($dirname)) {
|
|
mkdir($dirname, 0755, true);
|
|
}
|
|
|
|
file_put_contents($customPath, '');
|
|
|
|
$this->assertFileExists($customPath);
|
|
|
|
$result = get_custom_file_if_exists($defaultPath);
|
|
|
|
$this->assertSame($customPath, $result);
|
|
|
|
// Cleanup
|
|
unlink($customPath);
|
|
rmdir($dirname);
|
|
}
|
|
}
|