0
0
mirror of https://github.com/salesagility/SuiteCRM.git synced 2024-11-22 16:02:36 +00:00
salesagility_SuiteCRM/tests/unit/phpunit/modules/Groups/GroupTest.php
Dillon-Brown 26aab7535d Move test namespaces into autoload-dev
Signed-off-by: Dillon-Brown <dillon.brown@salesagility.com>
2021-09-08 16:49:16 +01:00

59 lines
1.9 KiB
PHP

<?php
use SuiteCRM\Test\SuitePHPUnitFrameworkTestCase;
class GroupTest extends SuitePHPUnitFrameworkTestCase
{
protected function setUp(): void
{
parent::setUp();
global $current_user;
$current_user = BeanFactory::newBean('Users');
get_sugar_config_defaults();
}
public function testGroup(): void
{
//execute the constructor and check for the Object type and attributes
$group = BeanFactory::newBean('Groups');
self::assertInstanceOf('Group', $group);
self::assertInstanceOf('User', $group);
self::assertInstanceOf('SugarBean', $group);
self::assertEquals('Group', $group->status);
self::assertEquals('', $group->password);
self::assertEquals(false, $group->importable);
}
public function testmark_deleted(): void
{
self::markTestIncomplete('environment dependency (php7: Incorrect state hash: Hash doesn\'t match at key "database::users".)');
$group = BeanFactory::newBean('Groups');
// Execute the method and test that it works and doesn't throw an exception.
try {
$group->mark_deleted('');
self::assertTrue(true);
} catch (Exception $e) {
self::fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString());
}
}
public function testcreate_export_query(): void
{
$group = BeanFactory::newBean('Groups');
//test with empty string params
$expected = 'SELECT users.* FROM users WHERE users.deleted = 0 ORDER BY users.user_name';
$actual = $group->create_export_query('', '');
self::assertSame($expected, $actual);
//test with valid string params
$expected = 'SELECT users.* FROM users WHERE users.user_name="" AND users.deleted = 0 ORDER BY users.id';
$actual = $group->create_export_query('users.id', 'users.user_name=""');
self::assertSame($expected, $actual);
}
}