-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
113,371 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"version":1,"defects":{"Gantry\\Tests\\PHP83\\Component\\TwigTest::testTwigFilters":4,"Gantry\\Tests\\PHP83\\Component\\TwigTest::testTwigFunctions":4,"Gantry\\Tests\\PHP83\\Framework\\GantryTest::testGantryContainer":4,"Gantry\\Tests\\PHP83\\Platform\\PlatformTest::testJoomlaPlatform":1,"Gantry\\Tests\\PHP83\\Platform\\PlatformTest::testWordPressPlatform":1,"Gantry\\Tests\\PHP83\\Framework\\GantryTest::testGantryInstance":4,"Gantry\\Tests\\PHP83\\Framework\\GantryTest::testGantryDebug":4},"times":{"Gantry\\Tests\\PHP83\\Component\\Layout\\LayoutTest::testLayoutInitialization":0,"Gantry\\Tests\\PHP83\\Component\\Layout\\LayoutTest::testLayoutPresets":0,"Gantry\\Tests\\PHP83\\Component\\Layout\\LayoutTest::testLayoutRendering":0,"Gantry\\Tests\\PHP83\\PHP83TypesTest::testNullableAndUnionTypes":0,"Gantry\\Tests\\PHP83\\PHP83TypesTest::testTraitCompatibility":0,"Gantry\\Tests\\PHP83\\Component\\TwigTest::testTwigExtensionInstantiation":0,"Gantry\\Tests\\PHP83\\Component\\TwigTest::testTwigFilters":0,"Gantry\\Tests\\PHP83\\Component\\TwigTest::testTwigFunctions":0,"Gantry\\Tests\\PHP83\\Framework\\GantryTest::testGantryInstance":0,"Gantry\\Tests\\PHP83\\Framework\\GantryTest::testGantryContainer":0,"Gantry\\Tests\\PHP83\\Framework\\GantryTest::testGantryDebug":0,"Gantry\\Tests\\PHP83\\Platform\\PlatformTest::testPlatformDetection":0,"Gantry\\Tests\\PHP83\\Platform\\PlatformTest::testJoomlaPlatform":0,"Gantry\\Tests\\PHP83\\Platform\\PlatformTest::testWordPressPlatform":0}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit | ||
backupGlobals="false" | ||
backupStaticAttributes="false" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
bootstrap="tests/php83/bootstrap.php"> | ||
|
||
<testsuites> | ||
<testsuite name="PHP 8.3 Compatibility Tests"> | ||
<directory>tests/php83</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<filter> | ||
<whitelist> | ||
<directory suffix=".php">src/classes</directory> | ||
<directory suffix=".php">platforms/*/classes</directory> | ||
<exclude> | ||
<directory>vendor</directory> | ||
<directory>platforms/*/vendor</directory> | ||
</exclude> | ||
</whitelist> | ||
</filter> | ||
|
||
<php> | ||
<ini name="error_reporting" value="E_ALL" /> | ||
<ini name="display_errors" value="On" /> | ||
<ini name="display_startup_errors" value="On" /> | ||
</php> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
|
||
namespace Gantry\Tests\PHP83\Component\Layout; | ||
|
||
use Gantry\Tests\PHP83\MockableTest; | ||
use Gantry\Component\Layout\Layout; | ||
|
||
/** | ||
* Test layout component with PHP 8.3 | ||
*/ | ||
class LayoutTest extends MockableTest | ||
{ | ||
/** | ||
* Test layout initialization | ||
*/ | ||
public function testLayoutInitialization() | ||
{ | ||
// Test creating a layout instance with minimal parameters | ||
$layout = new Layout('test'); | ||
$this->assertInstanceOf(Layout::class, $layout); | ||
|
||
// Test getting layout name | ||
$this->assertEquals('test', $layout->name); | ||
} | ||
|
||
/** | ||
* Test layout preset loading | ||
*/ | ||
public function testLayoutPresets() | ||
{ | ||
$layout = new Layout('test'); | ||
|
||
// Test preset functionality | ||
$preset = [ | ||
'name' => 'Test Preset', | ||
'sections' => [ | ||
'main' => [ | ||
'type' => 'section', | ||
'attributes' => ['id' => 'main'] | ||
] | ||
] | ||
]; | ||
|
||
$layout->initPreset($preset); | ||
|
||
// Test that preset was applied | ||
$this->assertNotEmpty($layout->preset); | ||
} | ||
|
||
/** | ||
* Test layout rendering with PHP 8.3 compatibility | ||
*/ | ||
public function testLayoutRendering() | ||
{ | ||
$layout = new Layout('test'); | ||
|
||
// Simple preset for testing | ||
$preset = [ | ||
'name' => 'Test Preset', | ||
'sections' => [ | ||
'main' => [ | ||
'type' => 'section', | ||
'attributes' => ['id' => 'main'], | ||
'children' => [] | ||
] | ||
] | ||
]; | ||
|
||
$layout->initPreset($preset); | ||
|
||
// Test that the layout can be converted to array | ||
$array = $layout->toArray(); | ||
$this->assertIsArray($array); | ||
$this->assertArrayHasKey('name', $array); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
namespace Gantry\Tests\PHP83; | ||
|
||
use Gantry\Tests\PHP83\MockableTest; | ||
|
||
/** | ||
* Test PHP 8.3 specific type handling and compatibility | ||
*/ | ||
class PHP83TypesTest extends MockableTest | ||
{ | ||
/** | ||
* Test that nullable types and union types work correctly | ||
* | ||
* @covers \Gantry\Component\Stylesheet\CssCompiler | ||
*/ | ||
public function testNullableAndUnionTypes() | ||
{ | ||
// Test with null values for nullable parameters | ||
$instance = new \Gantry\Component\Stylesheet\CssCompiler(); | ||
|
||
// Set null target path and verify it handles correctly | ||
$instance->setTargetPath(null); | ||
$this->assertNull($instance->getTargetPath()); | ||
|
||
// Test with string target | ||
$testPath = 'test/path/to/css'; | ||
$instance->setTargetPath($testPath); | ||
$this->assertEquals($testPath, $instance->getTargetPath()); | ||
} | ||
|
||
/** | ||
* Test compatibility with PHP 8.3 trait handling | ||
* | ||
* @covers \Gantry\Component\Theme\ThemeTrait | ||
*/ | ||
public function testTraitCompatibility() | ||
{ | ||
// Create a mock class using the trait | ||
$mock = new class { | ||
use \Gantry\Component\Theme\ThemeTrait; | ||
|
||
public function getUrl() | ||
{ | ||
return $this->url; | ||
} | ||
|
||
public function setUrl($url) | ||
{ | ||
$this->url = $url; | ||
return $this; | ||
} | ||
}; | ||
|
||
// Test the trait functionality | ||
$testUrl = 'https://test.com/theme'; | ||
$mock->setUrl($testUrl); | ||
$this->assertEquals($testUrl, $mock->getUrl()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
namespace Gantry\Tests\PHP83\Component; | ||
|
||
use Gantry\Tests\PHP83\MockableTest; | ||
use Gantry\Component\Twig\TwigExtension; | ||
|
||
/** | ||
* Test Twig integration with PHP 8.3 | ||
*/ | ||
class TwigTest extends MockableTest | ||
{ | ||
/** | ||
* Test Twig extension class instantiation | ||
*/ | ||
public function testTwigExtensionInstantiation() | ||
{ | ||
$extension = new TwigExtension(); | ||
$this->assertInstanceOf(TwigExtension::class, $extension); | ||
} | ||
|
||
/** | ||
* Test Twig filters availability | ||
*/ | ||
public function testTwigFilters() | ||
{ | ||
$extension = new TwigExtension(); | ||
$filters = $extension->getFilters(); | ||
|
||
$this->assertIsArray($filters); | ||
$this->assertNotEmpty($filters); | ||
|
||
// Check for core filters | ||
$filterNames = array_map(function ($filter) { | ||
return $filter->getName(); | ||
}, $filters); | ||
|
||
$this->assertContains('transFilter', $filterNames); | ||
$this->assertContains('truncateHtml', $filterNames); | ||
} | ||
|
||
/** | ||
* Test Twig functions availability | ||
*/ | ||
public function testTwigFunctions() | ||
{ | ||
$extension = new TwigExtension(); | ||
$functions = $extension->getFunctions(); | ||
|
||
$this->assertIsArray($functions); | ||
$this->assertNotEmpty($functions); | ||
|
||
// Check for core functions | ||
$functionNames = array_map(function ($function) { | ||
return $function->getName(); | ||
}, $functions); | ||
|
||
$this->assertContains('trans', $functionNames); | ||
$this->assertContains('url', $functionNames); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
namespace Gantry\Framework\Base; | ||
|
||
/** | ||
* Mock Gantry class for testing | ||
*/ | ||
class Gantry | ||
{ | ||
private static $instance; | ||
|
||
/** | ||
* @var \stdClass | ||
*/ | ||
public $container; | ||
|
||
private $debugMode = false; | ||
|
||
/** | ||
* Constructor. | ||
*/ | ||
protected function __construct() | ||
{ | ||
// Create container as a class to allow method calls | ||
$this->container = new class { | ||
public $services = ['platform' => 'mock']; | ||
|
||
public function has($service) { | ||
return isset($this->services[$service]); | ||
} | ||
|
||
public function get($service) { | ||
return $this->services[$service] ?? null; | ||
} | ||
}; | ||
} | ||
|
||
/** | ||
* Get instance of the Gantry Framework | ||
* | ||
* @return Gantry | ||
*/ | ||
public static function instance() | ||
{ | ||
if (!self::$instance) { | ||
self::$instance = new static(); | ||
} | ||
|
||
return self::$instance; | ||
} | ||
|
||
/** | ||
* Set/Get debug mode. | ||
* | ||
* @param bool|null $enabled True to enable debugging, null to ignore. | ||
* @return bool | ||
*/ | ||
public function debug($enabled = null) | ||
{ | ||
if (isset($enabled)) { | ||
$this->debugMode = (bool) $enabled; | ||
} | ||
|
||
return $this->debugMode; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
namespace Gantry\Tests\PHP83\Framework; | ||
|
||
use Gantry\Tests\PHP83\MockableTest; | ||
use Gantry\Framework\Base\Gantry; | ||
|
||
/** | ||
* Test core Gantry framework functionality with PHP 8.3 | ||
*/ | ||
class GantryTest extends MockableTest | ||
{ | ||
/** | ||
* Test instance creation and basic functionality | ||
*/ | ||
public function testGantryInstance() | ||
{ | ||
// Get the Gantry instance | ||
$gantry = Gantry::instance(); | ||
|
||
// Test that we got a valid instance | ||
$this->assertInstanceOf(Gantry::class, $gantry); | ||
|
||
// Test that we can access the container | ||
$container = $gantry->container; | ||
$this->assertNotNull($container); | ||
} | ||
|
||
/** | ||
* Test Gantry container services | ||
*/ | ||
public function testGantryContainer() | ||
{ | ||
$gantry = Gantry::instance(); | ||
|
||
// Test platform service | ||
$this->assertTrue($gantry->container->has('platform')); | ||
|
||
// Test theme service | ||
if ($gantry->container->has('theme')) { | ||
$theme = $gantry->container->get('theme'); | ||
$this->assertNotNull($theme); | ||
} | ||
} | ||
|
||
/** | ||
* Test debugging functionality | ||
*/ | ||
public function testGantryDebug() | ||
{ | ||
$gantry = Gantry::instance(); | ||
|
||
// Test debug mode can be set | ||
$gantry->debug(true); | ||
$this->assertTrue($gantry->debug()); | ||
|
||
$gantry->debug(false); | ||
$this->assertFalse($gantry->debug()); | ||
} | ||
} |
Oops, something went wrong.