Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions src/Classes/ShopInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,31 @@ public static function getAdminPath()
*/
public static function getModifiedVersion(): string
{
$path = self::getAdminPath() .'/includes/version.php';
$path = self::getAdminPath() . '/includes/version.php';

if (!file_exists($path)) {
return '';
return 'unknown';
}

$fileStr = file_get_contents($path);
$pos = strpos($fileStr, 'MOD_');
$version = substr($fileStr, (int) $pos + 4, 7);

if ($pos) {
/**
* DB_VERSION exists in file
*/
$version = substr($fileStr, (int) $pos + 4, 7);
} else {
/**
* DB_VERSION does not exists in file
* use PROJECT_MAJOR_VERSION and PROJECT_MINOR_VERSION instead
*/
preg_match('/MAJOR_VERSION.+?\'([\d\.]+)\'/', $fileStr, $versionMajor);
preg_match('/MINOR_VERSION.+?\'([\d\.]+)\'/', $fileStr, $versionMinor);

$version = $versionMajor[1] . '.' . $versionMinor[1];
}

return $version;
}

Expand Down
8 changes: 4 additions & 4 deletions tests/unit/RemoteModuleLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function testCanLoadAllVersions()
{
$apiRequest = new ApiRequest();
$modules = $this->loader->loadAllVersions();

$this->assertContainsOnlyInstancesOf(Module::class, $modules);
$this->assertGreaterThan(150, count($modules));

Expand Down Expand Up @@ -72,15 +72,15 @@ public function testCanLoadLatestVersionByArchiveName()
$module = $this->loader->loadLatestVersionByArchiveName('composer/autoload');

$this->assertEquals('composer/autoload', $module->getArchiveName());
$this->assertEquals('1.1.0', $module->getVersion());
$this->assertEquals('1.2.0', $module->getVersion());
}

public function testCanLoadByArchiveNameAndVersion()
{
$apiRequest = new ApiRequest();
$module = $this->loader->loadLatestVersionByArchiveName('composer/autoload', '1.1.0');

$this->assertEquals('composer/autoload', $module->getArchiveName());
$this->assertEquals('1.1.0', $module->getVersion());
$this->assertEquals('1.2.0', $module->getVersion());
}
}