mirror of
https://github.com/SuiteCRM/SuiteCRM-Core.git
synced 2025-09-04 10:14:13 +08:00
Add searchdefs to metadata api
- Retrieve searchdefs in legacy handler - Change ViewDefinitions Api to retrieve all viewdefs instead of just the listview defs - Add varchar info to searchdefs - Update codeception unit tests
This commit is contained in:
parent
b4d234cb43
commit
b62d1907aa
6 changed files with 416 additions and 33 deletions
|
@ -6,6 +6,7 @@ use App\Entity\FieldDefinition;
|
|||
use Codeception\Test\Unit;
|
||||
use Exception;
|
||||
use SuiteCRM\Core\Legacy\FieldDefinitionsHandler;
|
||||
use SuiteCRM\Core\Legacy\ModuleNameMapperHandler;
|
||||
|
||||
final class FieldDefinitionHandlerTest extends Unit
|
||||
{
|
||||
|
@ -26,13 +27,22 @@ final class FieldDefinitionHandlerTest extends Unit
|
|||
|
||||
protected function _before(): void
|
||||
{
|
||||
$this->fieldDefinitionsHandler = new FieldDefinitionsHandler(
|
||||
$moduleNameMapper = new ModuleNameMapperHandler(
|
||||
$this->tester->getProjectDir(),
|
||||
$this->tester->getLegacyDir(),
|
||||
$this->tester->getLegacySessionName(),
|
||||
$this->tester->getDefaultSessionName(),
|
||||
$this->tester->getLegacyScope()
|
||||
);
|
||||
|
||||
$this->fieldDefinitionsHandler = new FieldDefinitionsHandler(
|
||||
$this->tester->getProjectDir(),
|
||||
$this->tester->getLegacyDir(),
|
||||
$this->tester->getLegacySessionName(),
|
||||
$this->tester->getDefaultSessionName(),
|
||||
$this->tester->getLegacyScope(),
|
||||
$moduleNameMapper
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -40,11 +50,23 @@ final class FieldDefinitionHandlerTest extends Unit
|
|||
*/
|
||||
public function testGetUserVardef(): void
|
||||
{
|
||||
$this->fieldDefinition = $this->fieldDefinitionsHandler->getVardef('Accounts');
|
||||
$output = $this->fieldDefinition->vardef;
|
||||
$this->fieldDefinition = $this->fieldDefinitionsHandler->getVardef('accounts');
|
||||
|
||||
static::assertCount(
|
||||
1, $output
|
||||
);
|
||||
static::assertNotNull($this->fieldDefinition);
|
||||
|
||||
$vardefs = $this->fieldDefinition->vardef;
|
||||
static::assertNotNull($vardefs);
|
||||
static::assertIsArray($vardefs);
|
||||
static::assertNotEmpty($vardefs);
|
||||
|
||||
$first = $vardefs['name'];
|
||||
static::assertIsArray($first);
|
||||
static::assertNotEmpty($first);
|
||||
|
||||
static::assertArrayHasKey('name', $first);
|
||||
static::assertArrayHasKey('type', $first);
|
||||
static::assertArrayHasKey('dbType', $first);
|
||||
static::assertArrayHasKey('vname', $first);
|
||||
static::assertArrayHasKey('len', $first);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,15 +2,11 @@
|
|||
|
||||
namespace App\Tests;
|
||||
|
||||
use App\Entity\ViewDefinition;
|
||||
use AspectMock\Test;
|
||||
use Codeception\Test\Unit;
|
||||
use Exception;
|
||||
use SuiteCRM\Core\Legacy\ActionNameMapperHandler;
|
||||
use SuiteCRM\Core\Legacy\FieldDefinitionsHandler;
|
||||
use SuiteCRM\Core\Legacy\ModuleNameMapperHandler;
|
||||
use SuiteCRM\Core\Legacy\ModuleRegistryHandler;
|
||||
use SuiteCRM\Core\Legacy\ViewDefinitionsHandler;
|
||||
use SuiteCRM\Core\Legacy\RouteConverterHandler;
|
||||
|
||||
final class ViewDefinitionsHandlerTest extends Unit
|
||||
{
|
||||
|
@ -19,11 +15,6 @@ final class ViewDefinitionsHandlerTest extends Unit
|
|||
*/
|
||||
protected $tester;
|
||||
|
||||
/**
|
||||
* @var ViewDefinition
|
||||
*/
|
||||
protected $viewDefinition;
|
||||
|
||||
/**
|
||||
* @var ViewDefinitionsHandler
|
||||
*/
|
||||
|
@ -31,7 +22,6 @@ final class ViewDefinitionsHandlerTest extends Unit
|
|||
|
||||
/**
|
||||
* @throws Exception
|
||||
* @noinspection StaticClosureCanBeUsedInspection
|
||||
*/
|
||||
protected function _before(): void
|
||||
{
|
||||
|
@ -50,7 +40,7 @@ final class ViewDefinitionsHandlerTest extends Unit
|
|||
$legacyScope
|
||||
);
|
||||
|
||||
$this->viewDefinitionHandler = new ViewDefinitionsHandler(
|
||||
$fieldDefinitionsHandler = new FieldDefinitionsHandler(
|
||||
$projectDir,
|
||||
$legacyDir,
|
||||
$legacySessionName,
|
||||
|
@ -59,6 +49,87 @@ final class ViewDefinitionsHandlerTest extends Unit
|
|||
$moduleNameMapper
|
||||
);
|
||||
|
||||
$this->viewDefinition = $this->viewDefinitionHandler->getListViewDef('Accounts');
|
||||
$this->viewDefinitionHandler = new ViewDefinitionsHandler(
|
||||
$projectDir,
|
||||
$legacyDir,
|
||||
$legacySessionName,
|
||||
$defaultSessionName,
|
||||
$legacyScope,
|
||||
$moduleNameMapper,
|
||||
$fieldDefinitionsHandler
|
||||
);
|
||||
|
||||
// Needed for aspect mock
|
||||
/* @noinspection PhpIncludeInspection */
|
||||
require_once 'include/ListView/ListViewDisplay.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Test List view defs retrieval
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testListViewDefs(): void
|
||||
{
|
||||
|
||||
$listViewDefs = $this->viewDefinitionHandler->getListViewDef('accounts');
|
||||
static::assertNotNull($listViewDefs);
|
||||
static::assertNotNull($listViewDefs->getListView());
|
||||
static::assertIsArray($listViewDefs->getListView());
|
||||
static::assertNotEmpty($listViewDefs->getListView());
|
||||
|
||||
$first = $listViewDefs->getListView()[0];
|
||||
static::assertIsArray($first);
|
||||
static::assertNotEmpty($first);
|
||||
|
||||
static::assertArrayHasKey('fieldName', $first);
|
||||
static::assertArrayHasKey('label', $first);
|
||||
static::assertArrayHasKey('link', $first);
|
||||
static::assertIsBool($first['link']);
|
||||
static::assertArrayHasKey('default', $first);
|
||||
static::assertIsBool($first['default']);
|
||||
static::assertArrayHasKey('sortable', $first);
|
||||
static::assertIsBool($first['sortable']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test search defs retrieval
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testSearchDefs(): void
|
||||
{
|
||||
|
||||
$searchDefs = $this->viewDefinitionHandler->getSearchDefs('accounts');
|
||||
static::assertNotNull($searchDefs);
|
||||
static::assertNotNull($searchDefs->getSearch());
|
||||
static::assertIsArray($searchDefs->getSearch());
|
||||
static::assertNotEmpty($searchDefs->getSearch());
|
||||
static::assertArrayHasKey('layout', $searchDefs->getSearch());
|
||||
|
||||
static::assertNotNull($searchDefs->getSearch()['layout']);
|
||||
static::assertIsArray($searchDefs->getSearch()['layout']);
|
||||
static::assertNotEmpty($searchDefs->getSearch()['layout']);
|
||||
|
||||
static::assertArrayHasKey('basic', $searchDefs->getSearch()['layout']);
|
||||
static::assertNotNull($searchDefs->getSearch()['layout']['basic']);
|
||||
static::assertIsArray($searchDefs->getSearch()['layout']['basic']);
|
||||
static::assertNotEmpty($searchDefs->getSearch()['layout']['basic']);
|
||||
|
||||
$first = array_pop($searchDefs->getSearch()['layout']['basic']);
|
||||
static::assertIsArray($first);
|
||||
static::assertNotEmpty($first);
|
||||
|
||||
static::assertArrayHasKey('name', $first);
|
||||
|
||||
static::assertArrayHasKey('advanced', $searchDefs->getSearch()['layout']);
|
||||
static::assertNotNull($searchDefs->getSearch()['layout']['advanced']);
|
||||
static::assertIsArray($searchDefs->getSearch()['layout']['advanced']);
|
||||
static::assertNotEmpty($searchDefs->getSearch()['layout']['advanced']);
|
||||
|
||||
$first = array_pop($searchDefs->getSearch()['layout']['advanced']);
|
||||
static::assertIsArray($first);
|
||||
static::assertNotEmpty($first);
|
||||
|
||||
static::assertArrayHasKey('name', $first);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue