Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
question2answer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
outils
question2answer
Commits
25d48a83
Commit
25d48a83
authored
Dec 18, 2018
by
Scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Q2A/PHP version checks
Corrects 1.8.0-beta and 1.8.0 being treated as the same version.
parent
80e735df
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
10 deletions
+21
-10
qa-base.php
qa-include/qa-base.php
+5
-10
BaseTest.php
qa-tests/BaseTest.php
+16
-0
No files found.
qa-include/qa-base.php
View file @
25d48a83
...
...
@@ -80,6 +80,7 @@ if (!isset($qa_autoconnect) || $qa_autoconnect !== false) {
/**
* Converts the $version string (e.g. 1.6.2.2) to a floating point that can be used for greater/lesser comparisons
* (PHP's version_compare() function is not quite suitable for our needs)
* @deprecated 1.8.2 no longer used
* @param $version
* @return float
*/
...
...
@@ -102,30 +103,24 @@ function qa_version_to_float($version)
/**
* Returns true if the current Q2A version is lower than $version
, if both are valid version strings for qa_version_to_float()
* Returns true if the current Q2A version is lower than $version
* @param $version
* @return bool
*/
function
qa_qa_version_below
(
$version
)
{
$minqa
=
qa_version_to_float
(
$version
);
$thisqa
=
qa_version_to_float
(
QA_VERSION
);
return
$minqa
&&
$thisqa
&&
$thisqa
<
$minqa
;
return
version_compare
(
QA_VERSION
,
$version
)
<
0
;
}
/**
* Returns true if the current PHP version is lower than $version
, if both are valid version strings for qa_version_to_float()
* Returns true if the current PHP version is lower than $version
* @param $version
* @return bool
*/
function
qa_php_version_below
(
$version
)
{
$minphp
=
qa_version_to_float
(
$version
);
$thisphp
=
qa_version_to_float
(
phpversion
());
return
$minphp
&&
$thisphp
&&
$thisphp
<
$minphp
;
return
version_compare
(
phpversion
(),
$version
)
<
0
;
}
...
...
qa-tests/BaseTest.php
View file @
25d48a83
...
...
@@ -9,6 +9,22 @@ class BaseTest extends PHPUnit_Framework_TestCase
$this
->
assertSame
(
1.008
,
qa_version_to_float
(
'1.8.0-beta1'
));
}
public
function
test__qa_qa_version_below
()
{
// as we cannot change the QA_VERSION constant, we test an appended version against the set constant
$buildVersion
=
QA_VERSION
.
'.1234'
;
$betaVersion
=
QA_VERSION
.
'-beta1'
;
$this
->
assertSame
(
true
,
qa_qa_version_below
(
$buildVersion
));
$this
->
assertSame
(
false
,
qa_qa_version_below
(
$betaVersion
));
}
public
function
test__qa_php_version_below
()
{
// as we cannot change the PHP version, we test against an unsupported PHP version and a far-future version
$this
->
assertSame
(
false
,
qa_php_version_below
(
'5.1.4'
));
$this
->
assertSame
(
true
,
qa_php_version_below
(
'11.1.0'
));
}
public
function
test__qa_js
()
{
$this
->
assertSame
(
"'test'"
,
qa_js
(
'test'
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment