Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
solarium
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
solarium
Commits
0a08acb8
Commit
0a08acb8
authored
Feb 23, 2011
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- improved phpdoc
- added check methods to Solarium_Version - added new tests for Solarium_Version
parent
f2bba9c6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
142 additions
and
4 deletions
+142
-4
library/Solarium/Configurable.php
library/Solarium/Configurable.php
+2
-2
library/Solarium/Exception.php
library/Solarium/Exception.php
+1
-1
library/Solarium/Version.php
library/Solarium/Version.php
+81
-1
tests/Solarium/VersionTest.php
tests/Solarium/VersionTest.php
+58
-0
No files found.
library/Solarium/Configurable.php
View file @
0a08acb8
...
...
@@ -126,9 +126,9 @@ class Solarium_Configurable
}
/**
* Get an option value
* Get an option value
by name
*
* If the option
s
is empty or not set a NULL value will be returned.
* If the option is empty or not set a NULL value will be returned.
*
* @param string $name
* @return mixed
...
...
library/Solarium/Exception.php
View file @
0a08acb8
...
...
@@ -38,7 +38,7 @@
* Solarium specific exception
*
* All exceptions thrown by Solarium are of this type. This way you can easily
* catch Solarium exception and keep them separate from you own exceptions.
* catch Solarium exception and keep them separate from you
r
own exceptions.
*
* @package Solarium
*/
...
...
library/Solarium/Version.php
View file @
0a08acb8
...
...
@@ -47,9 +47,89 @@ class Solarium_Version
/**
* Version number of the Solarium library
*
* The version is built up in this format: major.minor.mini
*
* A major release is used for significant release with architectural
* changes and changes that might break backwards compatibility
*
* A minor release adds and enhances features, and might also contain
* bugfixes. It should be backwards compatible, or the incompatibilities
* should be clearly documented with the release.
*
* A mini release only contains bugfixes to existing features and is always
* backwards compatible.
*
* If you develop your application to a specific Solarium version it is best
* to check for that exact major and minor version, leaving the mini version
* open to allow for upgrades in case of bugfixes.
*
* @see checkExact()
* @see checkMinimal()
*
* @var string
*/
const
VERSION
=
'0.1-dev'
;
const
VERSION
=
'1.2.3'
;
/**
* Check for an exact version
*
* This method can check for all three versioning levels, but they are
* optional. If you only care for major and minor versions you can use
* something like '1.0' as input. Or '1' if you only want to check a major
* version.
*
* For each level that is checked the input has to be exactly the same as
* the actual version. Some examples:
*
* The if the version is 1.2.3 the following checks would return true:
* - 1 (only major version is checked)
* - 1.2 (only major and minor version are checked)
* - 1.2.3 (full version is checked)
*
* These values will return false:
* - 1.0 (lower)
* - 1.2.4 (higher)
*
*
* @internal a string compare is used instead of version_compare because
* version_compare returns false for a compare of 1.0.0 with 1.0
*
* @param string $version
* @return boolean
*/
static
public
function
checkExact
(
$version
)
{
return
(
substr
(
self
::
VERSION
,
0
,
strlen
(
$version
))
==
$version
);
}
/**
* Check for a minimal version
*
* This method can check for all three versioning levels, but they are
* optional. If you only care for major and minor versions you can use
* something like '1.0' as input. Or '1' if you only want to check a major
* version.
*
* For each level that is checked the actual value needs to be the same or
* higher. Some examples:
*
* The if the version is 1.2.3 the following checks would return true:
* - 1.2.3 (the same)
* - 1 (the actual version is higher)
*
* These values will return false:
* - 2 (the actual version is lower)
* - 1.3 (the actual version is lower)
*
* @param string $version
* @return boolean
*/
static
public
function
checkMinimal
(
$version
)
{
return
version_compare
(
self
::
VERSION
,
$version
,
'>='
);
}
}
\ No newline at end of file
tests/Solarium/VersionTest.php
View file @
0a08acb8
...
...
@@ -38,4 +38,62 @@ class Solarium_VersionTest extends PHPUnit_Framework_TestCase
$this
->
assertNotNull
(
$version
);
}
public
function
testCheckExact
()
{
$this
->
assertTrue
(
Solarium_Version
::
checkExact
(
Solarium_Version
::
VERSION
)
);
}
public
function
testCheckExactPartial
()
{
$this
->
assertTrue
(
Solarium_Version
::
checkExact
(
substr
(
Solarium_Version
::
VERSION
,
0
,
1
))
);
}
public
function
testCheckExactLower
()
{
$this
->
assertFalse
(
Solarium_Version
::
checkExact
(
'0.1'
)
);
}
public
function
testCheckExactHigher
()
{
$this
->
assertFalse
(
Solarium_Version
::
checkExact
(
'99.0'
)
);
}
public
function
testCheckMinimal
()
{
$this
->
assertTrue
(
Solarium_Version
::
checkMinimal
(
Solarium_Version
::
VERSION
)
);
}
public
function
testCheckMinimalPartial
()
{
$version
=
substr
(
Solarium_Version
::
VERSION
,
0
,
1
);
$this
->
assertTrue
(
Solarium_Version
::
checkMinimal
(
$version
)
);
}
public
function
testCheckMinimalLower
()
{
$this
->
assertTrue
(
Solarium_Version
::
checkMinimal
(
'0.1.0'
)
);
}
public
function
testCheckMinimalHigher
()
{
$this
->
assertFalse
(
Solarium_Version
::
checkMinimal
(
'99.0'
)
);
}
}
\ No newline at end of file
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