Permalink
Browse files

Add independent 3.1 and 3.2 branch version enable checks

  • Loading branch information...
1 parent 9af03ba commit 317a7e9509898df0261dec4056defcafc1dbfbaf @VSEphpbb VSEphpbb committed Jul 20, 2016
Showing with 28 additions and 4 deletions.
  1. +25 −1 ext.php
  2. +3 −3 skeleton/tests/dbal/simple_test.php.twig
View
26 ext.php
@@ -28,7 +28,31 @@ class ext extends \phpbb\extension\base
*/
public function is_enableable()
{
- return phpbb_version_compare(PHPBB_VERSION, '3.1.4', '>=') && class_exists('ZipArchive');
+ return class_exists('ZipArchive') && ($this->phpbb_31_compatible() || $this->phpbb_32_compatible());
+ }
+
+ /**
+ * Check phpBB 3.1 compatibility
+ *
+ * Requires phpBB 3.1.4 or greater
+ *
+ * @return bool
+ */
+ protected function phpbb_31_compatible()
+ {
+ return phpbb_version_compare(PHPBB_VERSION, '3.1.4', '>=') && phpbb_version_compare(PHPBB_VERSION, '3.2.0-dev', '<');
+ }
+
+ /**
+ * Check phpBB 3.2 compatibility
+ *
+ * Requires phpBB 3.2.0-b3 or greater
+ *
+ * @return bool
+ */
+ protected function phpbb_32_compatible()
+ {
+ return phpbb_version_compare(PHPBB_VERSION, '3.2.0-b3', '>=');
}
}
View
6 skeleton/tests/dbal/simple_test.php.twig
@@ -14,7 +14,7 @@
namespace {{ EXTENSION.vendor_name }}\{{ EXTENSION.extension_name }}\tests\dbal;
// Need to include functions.php to use phpbb_version_compare in this test
-require_once dirname(__FILE__) . '/../../../../../includes/functions.php';
+require_once __DIR__ . '/../../../../../includes/functions.php';
class simple_test extends \phpbb_database_test_case
{
@@ -28,14 +28,14 @@ class simple_test extends \phpbb_database_test_case
public function getDataSet()
{
- return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml');
+ return $this->createXMLDataSet(__DIR__ . '/fixtures/config.xml');
}
public function test_column()
{
$this->db = $this->new_dbal();
- if (phpbb_version_compare(PHPBB_VERSION, '3.2.0-dev', '<')
+ if (phpbb_version_compare(PHPBB_VERSION, '3.2.0-dev', '<'))
{
// This is how to instantiate db_tools in phpBB 3.1
$db_tools = new \phpbb\db\tools($this->db);

0 comments on commit 317a7e9

Please sign in to comment.