0
0
Fork 0
mirror of https://github.com/salesagility/SuiteCRM.git synced 2025-03-17 23:02:43 +00:00
salesagility_SuiteCRM/tests/unit/phpunit/include/MVC/View/views/view.quickcreateTest.php

87 lines
2.2 KiB
PHP
Raw Normal View History

2016-02-22 10:29:34 +00:00
<?php
use SuiteCRM\Tests\SuiteCRM\Test\SuitePHPUnitFrameworkTestCase;
class ViewQuickcreateTest extends SuitePHPUnitFrameworkTestCase
2016-02-22 10:29:34 +00:00
{
protected function setUp(): void
2018-03-26 14:35:40 +00:00
{
parent::setUp();
global $current_user;
get_sugar_config_defaults();
$current_user = BeanFactory::newBean('Users');
}
2016-03-18 16:33:43 +00:00
public function testpreDisplay()
2016-02-22 10:29:34 +00:00
{
2018-12-20 13:04:52 +00:00
if (isset($_REQUEST)) {
2018-03-29 16:05:49 +00:00
$_request = $_REQUEST;
}
2016-03-18 16:33:43 +00:00
//check without setting any values, it should execute without any issues.
$view = new ViewQuickcreate();
$view->preDisplay();
self::assertCount(0, $_REQUEST);
2016-03-18 16:33:43 +00:00
//check with values preset but without a valid bean id, it sould not change Request parameters
$_REQUEST['source_module'] = 'Users';
$_REQUEST['module'] = 'Users';
$_REQUEST['record'] = '';
$request = $_REQUEST;
$view->preDisplay();
self::assertSame($request, $_REQUEST);
2016-03-18 16:33:43 +00:00
//check with values preset, it sould set some addiiotnal Request parameters
$_REQUEST['record'] = 1;
$view->preDisplay();
self::assertNotSame($request, $_REQUEST);
2019-09-05 12:29:00 +00:00
2018-12-20 13:04:52 +00:00
if (isset($_request)) {
2018-03-29 16:05:49 +00:00
$_REQUEST = $_request;
} else {
unset($_REQUEST);
}
2016-03-18 16:33:43 +00:00
}
2016-02-22 10:29:34 +00:00
public function testdisplay()
{
2018-12-20 13:04:52 +00:00
if (isset($_SESSION)) {
2018-03-29 16:05:49 +00:00
$_session = $_SESSION;
}
2018-12-20 13:04:52 +00:00
if (isset($_REQUEST)) {
2018-03-29 16:05:49 +00:00
$_request = $_REQUEST;
}
2016-03-18 16:33:43 +00:00
//execute the method with required child objects and parameters preset. it will return some html.
$view = new ViewQuickcreate();
$_REQUEST['module'] = 'Accounts';
$view->bean = BeanFactory::newBean('Accounts');
2016-03-18 16:33:43 +00:00
ob_start();
$view->display();
$renderedContent = ob_get_contents();
ob_end_clean();
self::assertGreaterThan(0, strlen($renderedContent));
self::assertEquals(false, json_decode($renderedContent)); //check that it doesn't return json.
2019-09-05 12:29:00 +00:00
2018-12-20 13:04:52 +00:00
if (isset($_session)) {
2018-03-29 16:05:49 +00:00
$_SESSION = $_session;
} else {
unset($_SESSION);
}
2018-12-20 13:04:52 +00:00
if (isset($_request)) {
2018-03-29 16:05:49 +00:00
$_REQUEST = $_request;
} else {
unset($_REQUEST);
}
2016-03-18 16:33:43 +00:00
}
}