0
0
Fork 0
mirror of https://github.com/salesagility/SuiteCRM.git synced 2025-02-22 13:08:39 +00:00
salesagility_SuiteCRM/tests/unit/phpunit/include/MVC/View/views/view.classicTest.php
j.dang 47c18d731c Replace explicit bean instantiations in files 81 - 90
- 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()'
2020-01-22 13:50:54 +00:00

82 lines
2.5 KiB
PHP

<?php
use SuiteCRM\Test\SuitePHPUnitFrameworkTestCase;
class ViewClassicTest extends SuitePHPUnitFrameworkTestCase
{
public function setUp()
{
parent::setUp();
global $current_user;
get_sugar_config_defaults();
$current_user = BeanFactory::newBean('Users');
}
public function test__construct()
{
// Execute the constructor and check for the Object type and type attribute
//test with no parameters
$view = new ViewClassic();
$this->assertInstanceOf('ViewClassic', $view);
$this->assertInstanceOf('SugarView', $view);
$this->assertAttributeEquals('', 'type', $view);
//test with bean parameter;
$bean = BeanFactory::newBean('Users');
$view = new ViewClassic($bean);
$this->assertInstanceOf('ViewClassic', $view);
$this->assertInstanceOf('SugarView', $view);
$this->assertAttributeEquals('', 'type', $view);
}
public function testdisplay()
{
if (isset($_SESSION)) {
$session = $_SESSION;
}
//test with a valid module but invalid action. it should return false.
$view = new ViewClassic();
$view->module = 'Home';
$view->action = '';
$ret = $view->display();
$this->assertFalse($ret);
//test with a valid module and uncustomized action. it should return true
$view = new ViewClassic();
$view->module = 'Home';
$view->action = 'About';
// folowing code says: "Test code or tested code did not (only) close its own output buffers"
// ob_start();
// $ret = $view->display();
// $renderedContent = ob_get_contents();
// ob_end_clean();
// $this->assertEquals(0, strlen($renderedContent), 'Renderered Content was: ' . $renderedContent);
// $this->assertTrue($ret);
$this->markTestIncomplete("Warning was: Test code or tested code did not (only) close its own output buffers");
//test with a valid module and customized action. it should return true
$view = new ViewClassic();
$view->module = 'Home';
$view->action = 'index';
ob_start();
$ret = $view->display();
$renderedContent = ob_get_contents();
ob_end_clean();
$this->assertGreaterThan(0, strlen($renderedContent));
$this->assertTrue($ret);
if (isset($session)) {
$_SESSION = $session;
} else {
unset($_SESSION);
}
}
}