Skip to content
This repository has been archived by the owner on Jun 10, 2019. It is now read-only.

Commit

Permalink
More tests in inchoo_php7_test.
Browse files Browse the repository at this point in the history
  • Loading branch information
icurdinj committed Apr 5, 2017
1 parent 3598107 commit d0c503c
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/code/local/Mage/Connect/Packager.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
*/
class Mage_Connect_Packager
{
const INCHOO_PHP7 = true; // Test const to check if this file is properly overriden

/**
* Constructor
*/
Expand Down
2 changes: 2 additions & 0 deletions app/code/local/Mage/Core/Model/File/Uploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
*/
class Mage_Core_Model_File_Uploader extends Varien_File_Uploader
{
const INCHOO_PHP7 = true; // Test const to check if this file is properly overriden

/**
* Flag, that defines should DB processing be skipped
*
Expand Down
2 changes: 2 additions & 0 deletions app/code/local/Mage/Core/Model/Resource/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
*/
class Mage_Core_Model_Resource_Session implements Zend_Session_SaveHandler_Interface
{
const INCHOO_PHP7 = true; // Test const to check if this file is properly overriden

/**
* Session maximum cookie lifetime
*/
Expand Down
2 changes: 2 additions & 0 deletions app/code/local/Mage/Sales/Model/Config/Ordered.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
*/
abstract class Mage_Sales_Model_Config_Ordered extends Mage_Core_Model_Config_Base
{
const INCHOO_PHP7 = true; // Test const to check if this file is properly overriden

/**
* Cache key for collectors
*
Expand Down
42 changes: 41 additions & 1 deletion shell/inchoo_php7_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
* Test if Inchoo_PHP is installed and integrated into Magento correctly.
*
* TODO: check PHP version vs Mcrypt. Sugest Mcrypt polyfill on PHP 7.1
* IDEA: for testing core overwrites - implement a const in those classes, so we can check for its existence
*
* @author Ivan Čurdinjaković <[email protected]>
*/
Expand Down Expand Up @@ -45,6 +44,16 @@ private function checkRewrite($model, string $className): bool
return (get_class($model) === $className || get_parent_class($model) === $className);
}

/**
* Checks if a class has INCHOO_PHP7 const, proving it is correctly overriden
* @param string $class
* @return bool
*/
private function checkOverride(string $class): bool
{
return defined("$class::INCHOO_PHP7");
}

private function isCoreHelperRewritten(): bool
{
return $this->checkRewrite($this->coreHelper, 'Inchoo_PHP7_Helper_Data');
Expand Down Expand Up @@ -95,6 +104,21 @@ private function isExportEntityCustomerRewritten(): bool
);
}

private function isPackagerOverriden(): bool
{
return $this->checkOverride('Mage_Connect_Packager');
}

private function isUploaderOverriden(): bool
{
return $this->checkOverride('Mage_Core_Model_File_Uploader');
}

private function isSessionOverriden(): bool
{
return $this->checkOverride('Mage_Core_Model_Resource_Session');
}

/**
* Check if extension version is appropriate for M core
* @return int Extension major version: 1 or 2
Expand Down Expand Up @@ -212,6 +236,22 @@ public function run()
);
$extensionVersion = $this->checkExtensionAndCoreVersions();

$this->doTest(
[$this, 'isPackagerOverriden'],
'Magento Connect Packager is overriden.',
'Magento Connect Packager override PROBLEM!'
);
$this->doTest(
[$this, 'isUploaderOverriden'],
'Magento File Uploader is overriden.',
'Magento File Uploader override PROBLEM!'
);
$this->doTest(
[$this, 'isSessionOverriden'],
'Magento Session Resource is overriden.',
'Magento File Uploader override PROBLEM!'
);

// Inchoo_PHP7 1.* specific tests
if ($extensionVersion === 1) {
$this->doTest(
Expand Down

0 comments on commit d0c503c

Please sign in to comment.