mirror of
https://github.com/SuiteCRM/SuiteCRM-Core.git
synced 2025-09-04 10:14:13 +08:00
Add session swapping to LegacyHandlers
- Autowire LegacyHandlers as Symfony Services -- Configure legacy handlers folder in service.yml -- Replace handler instantiation with service injection - Add init and close to legacy handlers -- Swap sessions -- Swap current dir -- Add config to allow moving values between sessions -- replace hard coded values with injected configuration - Remove unused services and corresponding unit test -- NavbarService.php -- AuthenticationService.php - Refactor Authentication Handler to -- call init and close methods - Refactor navbar handler to be used as a service -- Adjust navbar unit tests
This commit is contained in:
parent
93d49d2514
commit
bd2e3d6e0c
14 changed files with 343 additions and 320 deletions
|
@ -1,39 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Codeception\Test\Unit;
|
||||
use SuiteCRM\Core\Legacy\Authentication;
|
||||
use SuiteCRM\Core\Legacy\AuthenticationService;
|
||||
|
||||
final class AuthenticationServiceTest extends Unit
|
||||
{
|
||||
/**
|
||||
* @var AuthenticationService
|
||||
*/
|
||||
private $authenticationService;
|
||||
|
||||
|
||||
protected function _before()
|
||||
{
|
||||
$this->authenticationService = new AuthenticationService();
|
||||
}
|
||||
|
||||
public function testGetName(): void
|
||||
{
|
||||
$this->assertSame('users.authentication', $this->authenticationService->getName());
|
||||
}
|
||||
|
||||
public function testGetDescription(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
'This service will deal with legacy authentication',
|
||||
$this->authenticationService->getDescription()
|
||||
);
|
||||
}
|
||||
|
||||
public function testCreateService(): void
|
||||
{
|
||||
$this->assertInstanceOf(Authentication::class, $this->authenticationService->createService());
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Codeception\Test\Unit;
|
||||
use SuiteCRM\Core\Legacy\Navbar;
|
||||
use SuiteCRM\Core\Legacy\NavbarService;
|
||||
|
||||
final class NavbarServiceTest extends Unit
|
||||
{
|
||||
/**
|
||||
* @var NavbarService
|
||||
*/
|
||||
private $navbarService;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->navbarService = new NavbarService();
|
||||
}
|
||||
|
||||
public function testGetName(): void
|
||||
{
|
||||
$this->assertSame('template.navbar', $this->navbarService->getName());
|
||||
}
|
||||
|
||||
public function testGetDescription(): void
|
||||
{
|
||||
$this->assertSame('This service will deal with retrieval of the navbar structure',
|
||||
$this->navbarService->getDescription());
|
||||
}
|
||||
|
||||
public function testCreateService(): void
|
||||
{
|
||||
$this->assertInstanceOf(Navbar::class, $this->navbarService->createService());
|
||||
}
|
||||
}
|
|
@ -2,19 +2,30 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
use App\Entity\Navbar;
|
||||
use Codeception\Test\Unit;
|
||||
use SuiteCRM\Core\Legacy\Navbar;
|
||||
use SuiteCRM\Core\Legacy\NavbarHandler;
|
||||
|
||||
final class NavbarTest extends Unit
|
||||
{
|
||||
/**
|
||||
* @var NavbarHandler
|
||||
*/
|
||||
private $navbarHandler;
|
||||
|
||||
/**
|
||||
* @var Navbar
|
||||
*/
|
||||
private $navbar;
|
||||
protected $navbar;
|
||||
|
||||
protected function _before()
|
||||
{
|
||||
$this->navbar = new Navbar();
|
||||
$projectDir = codecept_root_dir();
|
||||
$legacyDir = $projectDir . '/legacy';
|
||||
$legacySessionName = 'LEGACYSESSID';
|
||||
$defaultSessionName = 'PHPSESSID';
|
||||
$this->navbarHandler = new NavbarHandler($projectDir, $legacyDir, $legacySessionName, $defaultSessionName);
|
||||
$this->navbar = $this->navbarHandler->getNavbar();
|
||||
}
|
||||
|
||||
public function testGetUserActionMenu(): void
|
||||
|
@ -55,7 +66,7 @@ final class NavbarTest extends Unit
|
|||
|
||||
$this->assertSame(
|
||||
$expected,
|
||||
$this->navbar->getUserActionMenu()
|
||||
$this->navbar->userActionMenu
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -103,7 +114,7 @@ final class NavbarTest extends Unit
|
|||
|
||||
$this->assertSame(
|
||||
$expected,
|
||||
$this->navbar->getNonGroupedNavTabs()
|
||||
$this->navbar->NonGroupedTabs
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -177,7 +188,7 @@ final class NavbarTest extends Unit
|
|||
|
||||
$this->assertSame(
|
||||
$expected,
|
||||
$this->navbar->getGroupedNavTabs()
|
||||
$this->navbar->groupedTabs
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -371,7 +382,7 @@ final class NavbarTest extends Unit
|
|||
|
||||
$this->assertSame(
|
||||
$expected,
|
||||
$this->navbar->getModuleSubMenus()
|
||||
$this->navbar->moduleSubmenus
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue