-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1548 from tripal/tv4g0-issue214-tripal-version
Port tripal_version() api function and drush trp-version to Tripal 4
- Loading branch information
Showing
7 changed files
with
149 additions
and
4 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
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,69 @@ | ||
<?php | ||
|
||
namespace Drupal\Tests\tripal\Kernel\TripalConfig; | ||
|
||
use Drupal\KernelTests\KernelTestBase; | ||
|
||
/** | ||
* Tests for configuration in Yaml files. | ||
* These tests do not currently cover any code. | ||
* | ||
* @group Tripal | ||
* @group Tripal Config | ||
*/ | ||
class configTest extends KernelTestBase { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected static $modules = ['tripal', 'tripal_biodb', 'tripal_chado']; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function setUp(): void { | ||
parent::setUp(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static function tearDownAfterClass() :void { | ||
} | ||
|
||
/** | ||
* When we update the version of Tripal, we need to remember to | ||
* do it in all three yaml files. This function confirms that | ||
* version and also core_version_requirements are consistent in | ||
* each of the sub-modules' *.info.yml files. | ||
* | ||
*/ | ||
public function testConfigYaml() { | ||
$previous_module = NULL; | ||
$previous_version = NULL; | ||
$previous_core_version_requirement = NULL; | ||
foreach (self::$modules as $module) { | ||
$moduleObj = \Drupal::service('module_handler')->getModule($module); | ||
$moduleInfo = \Drupal::service('info_parser')->parse($moduleObj->getPathname()); | ||
$version = $moduleInfo['version'] ?? NULL; | ||
$core_version_requirement = $moduleInfo['core_version_requirement'] ?? NULL; | ||
// Verify that values are present. | ||
$this->assertNotNull($version, 'No "version" was specified in ' . $module . '.info.yml'); | ||
$this->assertNotNull($core_version_requirement, 'No "core_version_requirement" was specified in ' . $module . '.info.yml'); | ||
// On second and later modules, verify that returned values match those | ||
// from the previous module (the consistency check). | ||
if ($previous_module) { | ||
$this->assertEquals($version, $previous_version, | ||
'version for module "' | ||
. $previous_module . '" is different than for module "' . $module . '"'); | ||
$this->assertEquals($core_version_requirement, $previous_core_version_requirement, | ||
'core_version_requirement for module "' | ||
. $previous_module . '" is different than for module "' . $module . '"'); | ||
} | ||
$previous_module = $module; | ||
$previous_version = $version; | ||
$previous_core_version_requirement = $core_version_requirement; | ||
} | ||
} | ||
|
||
} |
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,50 @@ | ||
<?php | ||
|
||
namespace Drupal\Tests\tripal\Kernel\Api\TripalApi; | ||
|
||
use Drupal\KernelTests\KernelTestBase; | ||
|
||
/** | ||
* Tests for procedural API functions. | ||
* | ||
* @group Tripal | ||
* @group Tripal Api | ||
*/ | ||
class apiTest extends KernelTestBase { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected static $modules = ['tripal']; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function setUp(): void { | ||
parent::setUp(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static function tearDownAfterClass() :void { | ||
} | ||
|
||
/** | ||
* Tests the API function tripal_version(). | ||
* | ||
* @cover ::tripal_version | ||
*/ | ||
public function testTripalVersion() { | ||
// Get the version of the Tripal module as stored in tripal.info.yml | ||
$moduleObj = \Drupal::service('module_handler')->getModule(self::$modules[0]); | ||
$info = \Drupal::service('info_parser')->parse($moduleObj->getPathname()); | ||
$check_version = $info['version'] ?? NULL; | ||
|
||
// Get the version using the API function to be tested. | ||
$tripal_version = tripal_version(); | ||
|
||
$this->assertEquals($check_version, $tripal_version, 'tripal_version() returned the wrong value'); | ||
} | ||
|
||
} |
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,7 +1,8 @@ | ||
name: 'Tripal BioDB Task API' | ||
type: module | ||
description: 'Provides a database focused TASK API for Tripal.' | ||
core_version_requirement: ^9.2 || ^10 | ||
core_version_requirement: ^9.4 || ^10 | ||
package: 'Tripal' | ||
version: 4.0.alpha2 | ||
dependencies: | ||
- tripal:tripal |
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,8 +1,9 @@ | ||
name: 'Tripal Chado' | ||
type: module | ||
description: 'Chado integration for Tripal.' | ||
core_version_requirement: ^9.2 || ^10 | ||
core_version_requirement: ^9.4 || ^10 | ||
package: 'Tripal' | ||
version: 4.0.alpha2 | ||
dependencies: | ||
- tripal:tripal | ||
- tripal:tripal_biodb |