Skip to content

Commit

Permalink
Merge branch 'feature/professional-edition' into release/1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
steverobbins committed May 19, 2015
2 parents 48777f8 + 5d414a1 commit 79fa184
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 28 deletions.
19 changes: 12 additions & 7 deletions src/MageScan/Check/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
*/
class Version
{
const EDITION_ENTERPRISE = 'Enterprise';
const EDITION_COMMUNITY = 'Community';
const EDITION_ENTERPRISE = 'Enterprise';
const EDITION_PROFESSIONAL = 'Professional';
const EDITION_COMMUNITY = 'Community';

/**
* Guess Magento edition from license in public file
Expand All @@ -30,8 +31,12 @@ public function getMagentoEdition(\stdClass $response)
if ($response->code == 200) {
preg_match('/@license.*/', $response->body, $match);
if (isset($match[0])) {
return strpos($match[0], 'enterprise') !== false
? self::EDITION_ENTERPRISE : self::EDITION_COMMUNITY;
if (strpos($match[0], 'enterprise') !== false) {
return self::EDITION_ENTERPRISE;
} elseif (strpos($match[0], 'commercial') !== false) {
return self::EDITION_PROFESSIONAL;
}
return self::EDITION_COMMUNITY;
}
}
return 'Unknown';
Expand Down Expand Up @@ -77,13 +82,13 @@ protected function getMagentoVersionByYear($year, $edition)
return $edition == self::EDITION_ENTERPRISE ?
'1.13' : '1.8';
case 2012:
return $edition == self::EDITION_ENTERPRISE ?
return ($edition == self::EDITION_ENTERPRISE || $edition == self::EDITION_PROFESSIONAL) ?
'1.12' : '1.7';
case 2011:
return $edition == self::EDITION_ENTERPRISE ?
return ($edition == self::EDITION_ENTERPRISE || $edition == self::EDITION_PROFESSIONAL) ?
'1.11' : '1.6';
case 2010:
return $edition == self::EDITION_ENTERPRISE ?
return ($edition == self::EDITION_ENTERPRISE || $edition == self::EDITION_PROFESSIONAL) ?
'1.9 - 1.10' : '1.4 - 1.5';
}
return 'Unknown';
Expand Down
44 changes: 23 additions & 21 deletions test/MGA/Check/VersionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ public function testFileEmpty()
$this->assertSame('Unknown', $version);
}

/**
* Test for a missing product.js
*/
public function testFileMissing()
{
$response = new \stdClass;
Expand All @@ -51,9 +48,6 @@ public function testFileMissing()
$this->assertSame('Unknown', $version);
}

/**
* Test for a missing product.js
*/
public function testEnterprise114()
{
$response = new \stdClass;
Expand All @@ -77,9 +71,6 @@ public function testEnterprise114()
$this->assertSame('1.14', $version);
}

/**
* Test for a missing product.js
*/
public function testEnterprise113()
{
$response = new \stdClass;
Expand All @@ -103,9 +94,6 @@ public function testEnterprise113()
$this->assertSame('1.13', $version);
}

/**
* Test for a missing product.js
*/
public function testEnterprise112()
{
$response = new \stdClass;
Expand All @@ -129,9 +117,29 @@ public function testEnterprise112()
$this->assertSame('1.12', $version);
}

/**
* Test for a missing product.js
*/
public function testProfessional112()
{
$response = new \stdClass;
$response->code = 200;
$response->body = <<<FILE
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Varien
* @package js
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
* @license http://www.magentocommerce.com/license/commercial-edition
*/
if(typeof Product=='undefined') {
var Product = {};
FILE;
$version = new Version;
$edition = $version->getMagentoEdition($response);
$this->assertSame('Professional', $edition);
$version = $version->getMagentoVersion($response, $edition);
$this->assertSame('1.12', $version);
}

public function testCommunity19()
{
$response = new \stdClass;
Expand All @@ -155,9 +163,6 @@ public function testCommunity19()
$this->assertSame('1.9', $version);
}

/**
* Test for a missing product.js
*/
public function testCommunity18()
{
$response = new \stdClass;
Expand All @@ -181,9 +186,6 @@ public function testCommunity18()
$this->assertSame('1.8', $version);
}

/**
* Test for a missing product.js
*/
public function testCommunity17()
{
$response = new \stdClass;
Expand Down

0 comments on commit 79fa184

Please sign in to comment.