-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename module from Yireo_HyvaCheckoutUtils to Yireo_HyvaThemeAutoRegi…
…stration
- Loading branch information
1 parent
26ea38e
commit b15194e
Showing
17 changed files
with
157 additions
and
54 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
EXTENSION_VENDOR="Yireo" | ||
EXTENSION_NAME="Yireo_HyvaCheckoutUtils" | ||
COMPOSER_NAME="yireo/magento2-hyva-checkout-utils" | ||
PHP_VERSIONS=("8.1", "8.2") | ||
EXTENSION_NAME="Yireo_HyvaThemeAutoRegistration" | ||
COMPOSER_NAME="yireo/magento2-hyva-theme-auto-registration" | ||
PHP_VERSIONS=("8.1", "8.2", "8.3") |
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
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,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yireo\HyvaThemeAutoRegistration\Test\Integration; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Yireo\IntegrationTestHelper\Test\Integration\Traits\AssertModuleIsEnabled; | ||
use Yireo\IntegrationTestHelper\Test\Integration\Traits\AssertModuleIsRegistered; | ||
use Yireo\IntegrationTestHelper\Test\Integration\Traits\AssertModuleIsRegisteredForReal; | ||
|
||
class ModuleTest extends TestCase | ||
{ | ||
use AssertModuleIsEnabled; | ||
use AssertModuleIsRegistered; | ||
use AssertModuleIsRegisteredForReal; | ||
|
||
public function testModuleIsEnabled() | ||
{ | ||
$moduleName = 'Yireo_HyvaThemeAutoRegistration'; | ||
|
||
$this->assertModuleIsRegistered($moduleName); | ||
$this->assertModuleIsRegisteredForReal($moduleName); | ||
$this->assertModuleIsEnabled($moduleName); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
Test/Integration/Observer/RegisterModuleForHyvaConfigTest.php
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,64 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yireo\HyvaThemeAutoRegistration\Test\Integration\Observer; | ||
|
||
use Magento\Framework\App\ObjectManager; | ||
use Magento\Framework\DataObject; | ||
use Magento\Framework\Event\ConfigInterface as EventManagerConfig; | ||
use Magento\Framework\Event\Observer; | ||
use Magento\TestFramework\Fixture\AppArea; | ||
use Magento\TestFramework\Fixture\ComponentsDir; | ||
use PHPUnit\Framework\TestCase; | ||
use Yireo\HyvaThemeAutoRegistration\Observer\RegisterModuleForHyvaConfig; | ||
|
||
class RegisterModuleForHyvaConfigTest extends TestCase | ||
{ | ||
#[AppArea('frontend')] | ||
public function testIfObserverIsRegistered() | ||
{ | ||
// @todo: Copy this to integration test helper | ||
$eventManagerConfig = ObjectManager::getInstance()->get(EventManagerConfig::class); | ||
$observers = $eventManagerConfig->getObservers('hyva_config_generate_before'); | ||
|
||
$foundObserver = false; | ||
$debugInfo = []; | ||
foreach($observers as $observer) { | ||
$debugInfo[] = $observer; | ||
if ($observer['instance'] === RegisterModuleForHyvaConfig::class) { | ||
$foundObserver = true; | ||
} | ||
} | ||
|
||
$this->assertTrue($foundObserver, var_export($debugInfo, true)); | ||
} | ||
|
||
#[ComponentsDir('./_files')] | ||
public function testIfObserverExecutionIncludesConstructorBasedModules() | ||
{ | ||
// @todo: Enable the relevant module | ||
|
||
$observer = $this->getObserver(); | ||
$target = ObjectManager::getInstance()->get(RegisterModuleForHyvaConfig::class); | ||
$target->execute($observer); | ||
|
||
$this->assertNotEmpty($observer->getEvent()->getConfig()['extensions']); | ||
$this->assertObserverEventContainsModule($observer, 'Yireo_Foobar1'); | ||
} | ||
|
||
private function getObserver(): Observer | ||
{ | ||
$config = new DataObject(['extensions' => []]); | ||
$event = new DataObject(['config' => $config]); | ||
$observer = ObjectManager::getInstance()->create(Observer::class); | ||
$observer->setEvent($event); | ||
return $observer; | ||
} | ||
|
||
private function assertObserverEventContainsModule(Observer $observer, string $moduleName) | ||
{ | ||
$extensions = $observer->getEvent()->getConfig()['extensions']; | ||
$this->assertContains($moduleName, $extensions); | ||
} | ||
} |
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,5 @@ | ||
<?xml version="1.0"?> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> | ||
<module name="Foo_Bar1"/> | ||
</config> |
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,6 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
use Magento\Framework\Component\ComponentRegistrar; | ||
|
||
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Foo_Bar1', __DIR__); |
1 change: 1 addition & 0 deletions
1
Test/Integration/_files/Foo_Bar1/view/frontend/tailwind/tailwind.config.js
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 @@ | ||
console.log('dummy'); |
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,5 @@ | ||
<?xml version="1.0"?> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> | ||
<module name="Yireo_Foobar1"/> | ||
</config> |
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,6 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
use Magento\Framework\Component\ComponentRegistrar; | ||
|
||
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Yireo_Foobar1', __DIR__); |
1 change: 1 addition & 0 deletions
1
Test/Integration/_files/Yireo_Foobar1/view/frontend/tailwind/tailwind.config.js
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 @@ | ||
console.log('dummy'); |
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 |
---|---|---|
@@ -1,17 +1,41 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Yireo\HyvaCheckoutUtils\Utils; | ||
namespace Yireo\HyvaThemeAutoRegistration\Utils; | ||
|
||
use Magento\Framework\Component\ComponentRegistrar; | ||
use Magento\Framework\Exception\FileSystemException; | ||
use Magento\Framework\Filesystem\Driver\File as FileDriver; | ||
|
||
class HyvaFiles | ||
{ | ||
public function __construct( | ||
private ComponentRegistrar $componentRegistrar, | ||
private FileDriver $fileDriver, | ||
) { | ||
} | ||
public function getFiles(): array | ||
{ | ||
return [ | ||
'view/frontend/tailwind/tailwind.config.js', | ||
'view/frontend/tailwind/tailwind-source.css' | ||
]; | ||
} | ||
|
||
/** | ||
* @param string $moduleName | ||
* @return bool | ||
* @throws FileSystemException | ||
*/ | ||
public function hasHyvaFiles(string $moduleName): bool | ||
{ | ||
$path = $this->componentRegistrar->getPath(ComponentRegistrar::MODULE, $moduleName); | ||
foreach ($this->getFiles() as $file) { | ||
if ($this->fileDriver->isExists($path . '/' . $file)) { | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<?xml version="1.0"?> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> | ||
<module name="Yireo_HyvaCheckoutUtils"/> | ||
<module name="Yireo_HyvaThemeAutoRegistration"/> | ||
</config> |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
use Magento\Framework\Component\ComponentRegistrar; | ||
|
||
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Yireo_HyvaCheckoutUtils', __DIR__); | ||
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Yireo_HyvaThemeAutoRegistration', __DIR__); |