tests
CI / php (push) Successful in 2m56s

This commit is contained in:
2026-03-21 03:49:54 -05:00
parent d543c3bb0e
commit bbd83659a7
29 changed files with 1090 additions and 38 deletions
@@ -0,0 +1,69 @@
<?php
declare(strict_types=1);
namespace MageSail\Magesail\Test\Unit\Model;
use MageSail\Magesail\Model\AdminPathDetector;
use Magento\Framework\App\DeploymentConfig;
use Magento\Framework\App\Request\Http;
use PHPUnit\Framework\TestCase;
class AdminPathDetectorTest extends TestCase
{
public function testGetConfiguredAdminFrontNameUsesDeploymentConfig(): void
{
$config = new DeploymentConfig();
$config->setTestValue('backend/frontName', 'custom');
$detector = new AdminPathDetector($config);
self::assertSame('custom', $detector->getConfiguredAdminFrontName());
}
public function testGetConfiguredAdminFrontNameDefaultsToAdmin(): void
{
$config = new DeploymentConfig();
$detector = new AdminPathDetector($config);
self::assertSame('admin', $detector->getConfiguredAdminFrontName());
}
public function testIsAdminPathTrueWhenPathInfoContainsFrontName(): void
{
$config = new DeploymentConfig();
$config->setTestValue('backend/frontName', 'admin');
$detector = new AdminPathDetector($config);
$request = new Http();
$request->setPathInfo('/admin/sales/order');
self::assertTrue($detector->isAdminPath($request));
}
public function testIsAdminPathSkipsIndexPhpAndPubSegments(): void
{
$config = new DeploymentConfig();
$config->setTestValue('backend/frontName', 'admin');
$detector = new AdminPathDetector($config);
$request = new Http();
$request->setPathInfo('/pub/index.php/admin/dashboard');
self::assertTrue($detector->isAdminPath($request));
}
public function testIsAdminPathFalseForFrontendPath(): void
{
$config = new DeploymentConfig();
$config->setTestValue('backend/frontName', 'admin');
$detector = new AdminPathDetector($config);
$request = new Http();
$request->setPathInfo('/catalog/product/view');
self::assertFalse($detector->isAdminPath($request));
}
public function testGetAdminFrontNameIfPresentInPathUsesRequestUriWhenPathInfoEmpty(): void
{
$config = new DeploymentConfig();
$config->setTestValue('backend/frontName', 'backend');
$detector = new AdminPathDetector($config);
$request = new Http();
$request->setPathInfo('');
$request->setRequestUri('/backend/index/index');
self::assertSame('backend', $detector->getAdminFrontNameIfPresentInPath($request));
}
}