Fix editview metadata loading for Users module

- Properly load the legacy app and router
-- Fixes user module metadata loading
- Adjust unit tests
This commit is contained in:
Clemente Raposo 2021-01-04 23:26:05 +00:00 committed by Dillon-Brown
parent 544adba1b3
commit bfed5ae78e
23 changed files with 112 additions and 33 deletions

View file

@ -165,6 +165,7 @@ abstract class LegacyHandler
/** /**
* Start Legacy Suite app * Start Legacy Suite app
* @param string $currentModule
* @return void * @return void
* Based on @see SugarApplication::execute * Based on @see SugarApplication::execute
* Not calling: * Not calling:
@ -174,7 +175,7 @@ abstract class LegacyHandler
* - controller->execute(); * - controller->execute();
* - sugar_cleanup * - sugar_cleanup
*/ */
protected function startLegacyApp(): void protected function startLegacyApp(string $currentModule = ''): void
{ {
if ($this->state->isLegacyStarted()) { if ($this->state->isLegacyStarted()) {
return; return;
@ -194,8 +195,8 @@ abstract class LegacyHandler
} }
$module = $app->default_module; $module = $app->default_module;
if (!empty($_REQUEST['module'])) { if (!empty($currentModule)) {
$module = $_REQUEST['module']; $module = $currentModule;
} }
/** @var SugarController $controller */ /** @var SugarController $controller */

View file

@ -141,6 +141,8 @@ class ViewDefinitionsHandler extends LegacyHandler implements ViewDefinitionsPro
$legacyModuleName = $this->validateModuleName($moduleName); $legacyModuleName = $this->validateModuleName($moduleName);
$this->startLegacyApp($legacyModuleName);
$viewDef = new ViewDefinition(); $viewDef = new ViewDefinition();
$viewDef->setId($moduleName); $viewDef->setId($moduleName);

View file

@ -20,7 +20,10 @@ class AssignedUserOpportunitiesCountMock extends AssignedUserOpportunitiesCount
return $this->getMockQueryResults(); return $this->getMockQueryResults();
} }
protected function startLegacyApp(): void /**
* @inheritDoc
*/
protected function startLegacyApp(string $currentModule = ''): void
{ {
} }

View file

@ -2,10 +2,10 @@
namespace App\Tests\_mock\Mock\core\legacy\Statistics; namespace App\Tests\_mock\Mock\core\legacy\Statistics;
use App\Legacy\Statistics\CaseDaysOpen;
use Doctrine\ORM\EntityManagerInterface;
use aCase; use aCase;
use App\Legacy\Statistics\CaseDaysOpen;
use App\Tests\_mock\Helpers\core\legacy\Data\DBQueryResultsMocking; use App\Tests\_mock\Helpers\core\legacy\Data\DBQueryResultsMocking;
use Doctrine\ORM\EntityManagerInterface;
use SugarBean; use SugarBean;
/** /**
@ -38,7 +38,10 @@ class CaseDaysOpenMock extends CaseDaysOpen
return $this->case; return $this->case;
} }
protected function startLegacyApp(): void /**
* @inheritDoc
*/
protected function startLegacyApp(string $currentModule = ''): void
{ {
} }

View file

@ -2,11 +2,9 @@
namespace Mock\Core\Legacy\Statistics; namespace Mock\Core\Legacy\Statistics;
use AcceptanceTester; use aCase;
use App\Legacy\Statistics\CasesPerAccount; use App\Legacy\Statistics\CasesPerAccount;
use App\Tests\_mock\Helpers\core\legacy\Data\DBQueryResultsMocking; use App\Tests\_mock\Helpers\core\legacy\Data\DBQueryResultsMocking;
use SugarBean;
use aCase;
use BeanFactory; use BeanFactory;
class CasesPerAccountMock extends CasesPerAccount class CasesPerAccountMock extends CasesPerAccount
@ -34,7 +32,10 @@ class CasesPerAccountMock extends CasesPerAccount
return $this->getMockQueryResults(); return $this->getMockQueryResults();
} }
protected function startLegacyApp(): void /**
* @inheritDoc
*/
protected function startLegacyApp(string $currentModule = ''): void
{ {
} }

View file

@ -3,8 +3,8 @@
namespace App\Tests\_mock\Mock\core\legacy\Statistics; namespace App\Tests\_mock\Mock\core\legacy\Statistics;
use App\Legacy\Statistics\DaysUntilDueTask; use App\Legacy\Statistics\DaysUntilDueTask;
use Task;
use App\Tests\_mock\Helpers\core\legacy\Data\DBQueryResultsMocking; use App\Tests\_mock\Helpers\core\legacy\Data\DBQueryResultsMocking;
use Task;
/** /**
* Class DaysUntilDueTaskMock * Class DaysUntilDueTaskMock
@ -36,7 +36,10 @@ class DaysUntilDueTaskMock extends DaysUntilDueTask
return $this->task; return $this->task;
} }
protected function startLegacyApp(): void /**
* @inheritDoc
*/
protected function startLegacyApp(string $currentModule = ''): void
{ {
} }

View file

@ -3,9 +3,9 @@
namespace App\Tests\_mock\Mock\core\legacy\Statistics; namespace App\Tests\_mock\Mock\core\legacy\Statistics;
use App\Legacy\Statistics\LeadDaysOpen; use App\Legacy\Statistics\LeadDaysOpen;
use App\Tests\_mock\Helpers\core\legacy\Data\DBQueryResultsMocking;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Lead; use Lead;
use App\Tests\_mock\Helpers\core\legacy\Data\DBQueryResultsMocking;
use SugarBean; use SugarBean;
/** /**
@ -38,7 +38,10 @@ class LeadDaysOpenMock extends LeadDaysOpen
return $this->lead; return $this->lead;
} }
protected function startLegacyApp(): void /**
* @inheritDoc
*/
protected function startLegacyApp(string $currentModule = ''): void
{ {
} }

View file

@ -3,8 +3,8 @@
namespace App\Tests\_mock\Mock\core\legacy\Statistics; namespace App\Tests\_mock\Mock\core\legacy\Statistics;
use App\Legacy\Statistics\OpportunitySalesStageTimeSpan; use App\Legacy\Statistics\OpportunitySalesStageTimeSpan;
use Doctrine\ORM\EntityManagerInterface;
use App\Tests\_mock\Helpers\core\legacy\Data\DBQueryResultsMocking; use App\Tests\_mock\Helpers\core\legacy\Data\DBQueryResultsMocking;
use Doctrine\ORM\EntityManagerInterface;
use Opportunity; use Opportunity;
use SugarBean; use SugarBean;
@ -38,7 +38,10 @@ class OpportunitySalesStageTimeSpanMock extends OpportunitySalesStageTimeSpan
return $this->opp; return $this->opp;
} }
protected function startLegacyApp(): void /**
* @inheritDoc
*/
protected function startLegacyApp(string $currentModule = ''): void
{ {
} }

View file

@ -20,7 +20,10 @@ class OpportunitySizeAnalysisMock extends OpportunitySizeAnalysis
return $this->getMockQueryResults(); return $this->getMockQueryResults();
} }
protected function startLegacyApp(): void /**
* @inheritDoc
*/
protected function startLegacyApp(string $currentModule = ''): void
{ {
} }

View file

@ -35,7 +35,10 @@ class LeadsByStatusCountMock extends LeadsByStatusCount
$this->bean = $bean; $this->bean = $bean;
} }
protected function startLegacyApp(): void /**
* @inheritDoc
*/
protected function startLegacyApp(string $currentModule = ''): void
{ {
} }

View file

@ -35,7 +35,10 @@ class OpportunitiesBySalesStagePipelineMock extends OpportunitiesBySalesStagePip
$this->bean = $bean; $this->bean = $bean;
} }
protected function startLegacyApp(): void /**
* @inheritDoc
*/
protected function startLegacyApp(string $currentModule = ''): void
{ {
} }
@ -47,6 +50,9 @@ class OpportunitiesBySalesStagePipelineMock extends OpportunitiesBySalesStagePip
return $this->getAllMockQueryResults(); return $this->getAllMockQueryResults();
} }
/**
* @inheritDoc
*/
protected function generateQuery(array $query): array protected function generateQuery(array $query): array
{ {
return [ return [

View file

@ -35,7 +35,10 @@ class SubPanelActivitiesNextDateMock extends SubPanelActivitiesNextDate
return $this->getMockQueryResults(); return $this->getMockQueryResults();
} }
protected function startLegacyApp(): void /**
* @inheritDoc
*/
protected function startLegacyApp(string $currentModule = ''): void
{ {
} }
} }

View file

@ -35,7 +35,10 @@ class SubPanelCampaignLastReceivedMock extends SubPanelCampaignsLastReceived
return $this->getMockQueryResults(); return $this->getMockQueryResults();
} }
protected function startLegacyApp(): void /**
* @inheritDoc
*/
protected function startLegacyApp(string $currentModule = ''): void
{ {
} }
} }

View file

@ -34,7 +34,10 @@ class SubPanelCasesCountMock extends SubPanelCasesCount
return $this->getMockQueryResults(); return $this->getMockQueryResults();
} }
protected function startLegacyApp(): void /**
* @inheritDoc
*/
protected function startLegacyApp(string $currentModule = ''): void
{ {
} }
} }

View file

@ -36,7 +36,10 @@ class SubPanelContractsRenewalDateMock extends SubPanelContractsRenewalDate
return $this->getMockQueryResults(); return $this->getMockQueryResults();
} }
protected function startLegacyApp(): void /**
* @inheritDoc
*/
protected function startLegacyApp(string $currentModule = ''): void
{ {
} }
} }

View file

@ -35,7 +35,10 @@ class SubPanelEventsLastDateMock extends SubPanelEventsLastDate
return $this->getMockQueryResults(); return $this->getMockQueryResults();
} }
protected function startLegacyApp(): void /**
* @inheritDoc
*/
protected function startLegacyApp(string $currentModule = ''): void
{ {
} }
} }

View file

@ -40,7 +40,10 @@ class SubPanelHistoryLastDateMock extends SubPanelHistoryLastDate
return $this->getMockQueryResults(); return $this->getMockQueryResults();
} }
protected function startLegacyApp(): void /**
* @inheritDoc
*/
protected function startLegacyApp(string $currentModule = ''): void
{ {
} }
} }

View file

@ -34,7 +34,10 @@ class SubPanelInvoicesTotalMock extends SubPanelInvoicesTotal
return $this->getMockQueryResults(); return $this->getMockQueryResults();
} }
protected function startLegacyApp(): void /**
* @inheritDoc
*/
protected function startLegacyApp(string $currentModule = ''): void
{ {
} }
} }

View file

@ -36,7 +36,10 @@ class SubPanelQuotesTotalMock extends SubPanelQuotesTotal
return $this->getMockQueryResults(); return $this->getMockQueryResults();
} }
protected function startLegacyApp(): void /**
* @inheritDoc
*/
protected function startLegacyApp(string $currentModule = ''): void
{ {
} }
} }

View file

@ -34,7 +34,10 @@ class SubpanelOpportunitiesTotalMock extends SubpanelOpportunitiesTotal
return $this->getMockQueryResults(); return $this->getMockQueryResults();
} }
protected function startLegacyApp(): void /**
* @inheritDoc
*/
protected function startLegacyApp(string $currentModule = ''): void
{ {
} }
} }

View file

@ -34,7 +34,10 @@ class WonOpportunityAmountByYearMock extends WonOpportunityAmountByYear
return $this->getMockQueryResults(); return $this->getMockQueryResults();
} }
protected function startLegacyApp(): void /**
* @inheritDoc
*/
protected function startLegacyApp(string $currentModule = ''): void
{ {
} }
} }

View file

@ -0,0 +1,18 @@
<?php
namespace App\Tests\_mock\Mock\core\legacy;
use App\Legacy\ViewDefinitionsHandler;
class ViewDefinitionsHandlerMock extends ViewDefinitionsHandler
{
/**
* @inheritDoc
*/
protected function startLegacyApp(string $currentModule = ''): void
{
}
}

View file

@ -9,7 +9,6 @@ use App\Legacy\ModuleNameMapperHandler;
use App\Legacy\ViewDefinitions\ListViewDefinitionHandler; use App\Legacy\ViewDefinitions\ListViewDefinitionHandler;
use App\Legacy\ViewDefinitions\RecordViewDefinitionHandler; use App\Legacy\ViewDefinitions\RecordViewDefinitionHandler;
use App\Legacy\ViewDefinitions\SubPanelDefinitionHandler; use App\Legacy\ViewDefinitions\SubPanelDefinitionHandler;
use App\Legacy\ViewDefinitionsHandler;
use App\Service\AclManagerInterface; use App\Service\AclManagerInterface;
use App\Service\BulkActionDefinitionProvider; use App\Service\BulkActionDefinitionProvider;
use App\Service\FilterDefinitionProvider; use App\Service\FilterDefinitionProvider;
@ -17,6 +16,7 @@ use App\Service\FilterDefinitionProviderInterface;
use App\Service\LineActionDefinitionProvider; use App\Service\LineActionDefinitionProvider;
use App\Service\ListViewSidebarWidgetDefinitionProvider; use App\Service\ListViewSidebarWidgetDefinitionProvider;
use App\Service\RecordActionDefinitionProvider; use App\Service\RecordActionDefinitionProvider;
use App\Tests\_mock\Mock\core\legacy\ViewDefinitionsHandlerMock;
use App\Tests\UnitTester; use App\Tests\UnitTester;
use Codeception\Test\Unit; use Codeception\Test\Unit;
use Exception; use Exception;
@ -35,7 +35,7 @@ final class ViewDefinitionsHandlerTest extends Unit
protected $tester; protected $tester;
/** /**
* @var ViewDefinitionsHandler * @var ViewDefinitionsHandlerMock
*/ */
private $viewDefinitionHandler; private $viewDefinitionHandler;
@ -270,7 +270,7 @@ final class ViewDefinitionsHandlerTest extends Unit
$filterDefinitionHandler $filterDefinitionHandler
); );
$this->viewDefinitionHandler = new ViewDefinitionsHandler( $this->viewDefinitionHandler = new ViewDefinitionsHandlerMock(
$projectDir, $projectDir,
$legacyDir, $legacyDir,
$legacySessionName, $legacySessionName,