Added readme

This commit is contained in:
R. Eric Wheeler 2016-08-08 07:56:35 -07:00
parent cf3a9e28b8
commit d8557c6188
6 changed files with 75 additions and 240 deletions

View File

@ -16,7 +16,7 @@ matrix:
- php: nightly
before_script:
- composer install --dev
- composer install
script:
- mkdir -p build/logs

28
README.md Normal file
View File

@ -0,0 +1,28 @@
# Drupal Variable Mock
Mocks for drupal variable functions variable_(set,get,del) for testing outside of Drupal
## Versions
Drupal 7.x
## Usage
```composer require sikofitt/mocks-drupal-variables```
```require 'vendor/autoload.php'```
Then just use as if you were in drupal.
```php
variable_set('myvar', 'myvalue');
variable_get('myvar'); // myvalue
variable_del('myvar');
variable_get('myvar', 'default_if_not_found'); // default_if_not_found
```
Just like drupal, every function returns null, except variable_get.
But variable_get will return null if the value is not found and no default was given.
## Requirements
PHP >=5.3
## Tests
phpunit

View File

@ -4,11 +4,11 @@
"keywords": ["drupal", "mock", "config"],
"type": "library",
"require": {
"php": ">=5.4"
"php": ">=5.3"
},
"require-dev": {
"phpunit/phpunit": "^5.5",
"phpunit/php-code-coverage": "4.0.*"
"phpunit/phpunit": "~4",
"phpunit/php-code-coverage": "~2"
},
"license": "GPL-3.0",
"authors": [

275
composer.lock generated
View File

@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "34225ddc86ef42457ccd546bb137f3c3",
"content-hash": "be291abae27306620a5badf0f0af23c3",
"hash": "867f932029554c9fa1b78c2f7e43cb49",
"content-hash": "0ae53463400e780d5425171991cad9ce",
"packages": [],
"packages-dev": [
{
@ -62,48 +62,6 @@
],
"time": "2015-06-14 21:17:01"
},
{
"name": "myclabs/deep-copy",
"version": "1.5.1",
"source": {
"type": "git",
"url": "https://github.com/myclabs/DeepCopy.git",
"reference": "a8773992b362b58498eed24bf85005f363c34771"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/a8773992b362b58498eed24bf85005f363c34771",
"reference": "a8773992b362b58498eed24bf85005f363c34771",
"shasum": ""
},
"require": {
"php": ">=5.4.0"
},
"require-dev": {
"doctrine/collections": "1.*",
"phpunit/phpunit": "~4.1"
},
"type": "library",
"autoload": {
"psr-4": {
"DeepCopy\\": "src/DeepCopy/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Create deep copies (clones) of your objects",
"homepage": "https://github.com/myclabs/DeepCopy",
"keywords": [
"clone",
"copy",
"duplicate",
"object",
"object graph"
],
"time": "2015-11-20 12:04:31"
},
{
"name": "phpdocumentor/reflection-common",
"version": "1.0",
@ -314,40 +272,39 @@
},
{
"name": "phpunit/php-code-coverage",
"version": "4.0.1",
"version": "2.2.4",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "5f3f7e736d6319d5f1fc402aff8b026da26709a3"
"reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/5f3f7e736d6319d5f1fc402aff8b026da26709a3",
"reference": "5f3f7e736d6319d5f1fc402aff8b026da26709a3",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/eabf68b476ac7d0f73793aada060f1c1a9bf8979",
"reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979",
"shasum": ""
},
"require": {
"php": "^5.6 || ^7.0",
"php": ">=5.3.3",
"phpunit/php-file-iterator": "~1.3",
"phpunit/php-text-template": "~1.2",
"phpunit/php-token-stream": "^1.4.2",
"sebastian/code-unit-reverse-lookup": "~1.0",
"sebastian/environment": "^1.3.2 || ^2.0",
"sebastian/version": "~1.0|~2.0"
"phpunit/php-token-stream": "~1.3",
"sebastian/environment": "^1.3.2",
"sebastian/version": "~1.0"
},
"require-dev": {
"ext-xdebug": ">=2.1.4",
"phpunit/phpunit": "^5.4"
"phpunit/phpunit": "~4"
},
"suggest": {
"ext-dom": "*",
"ext-xdebug": ">=2.4.0",
"ext-xdebug": ">=2.2.1",
"ext-xmlwriter": "*"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.0.x-dev"
"dev-master": "2.2.x-dev"
}
},
"autoload": {
@ -373,7 +330,7 @@
"testing",
"xunit"
],
"time": "2016-07-26 14:39:29"
"time": "2015-10-06 15:47:00"
},
{
"name": "phpunit/php-file-iterator",
@ -558,16 +515,16 @@
},
{
"name": "phpunit/phpunit",
"version": "5.5.0",
"version": "4.8.27",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "c7b3e1dcc1d183f26d5ba282881fe65c2cbb5b2b"
"reference": "c062dddcb68e44b563f66ee319ddae2b5a322a90"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c7b3e1dcc1d183f26d5ba282881fe65c2cbb5b2b",
"reference": "c7b3e1dcc1d183f26d5ba282881fe65c2cbb5b2b",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c062dddcb68e44b563f66ee319ddae2b5a322a90",
"reference": "c062dddcb68e44b563f66ee319ddae2b5a322a90",
"shasum": ""
},
"require": {
@ -576,27 +533,21 @@
"ext-pcre": "*",
"ext-reflection": "*",
"ext-spl": "*",
"myclabs/deep-copy": "~1.3",
"php": "^5.6 || ^7.0",
"php": ">=5.3.3",
"phpspec/prophecy": "^1.3.1",
"phpunit/php-code-coverage": "^4.0.1",
"phpunit/php-code-coverage": "~2.1",
"phpunit/php-file-iterator": "~1.4",
"phpunit/php-text-template": "~1.2",
"phpunit/php-timer": "^1.0.6",
"phpunit/phpunit-mock-objects": "^3.2",
"phpunit/phpunit-mock-objects": "~2.3",
"sebastian/comparator": "~1.1",
"sebastian/diff": "~1.2",
"sebastian/environment": "^1.3 || ^2.0",
"sebastian/environment": "~1.3",
"sebastian/exporter": "~1.2",
"sebastian/global-state": "~1.0",
"sebastian/object-enumerator": "~1.0",
"sebastian/resource-operations": "~1.0",
"sebastian/version": "~1.0|~2.0",
"sebastian/version": "~1.0",
"symfony/yaml": "~2.1|~3.0"
},
"conflict": {
"phpdocumentor/reflection-docblock": "3.0.2"
},
"suggest": {
"phpunit/php-invoker": "~1.1"
},
@ -606,7 +557,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "5.5.x-dev"
"dev-master": "4.8.x-dev"
}
},
"autoload": {
@ -632,33 +583,30 @@
"testing",
"xunit"
],
"time": "2016-08-05 04:49:02"
"time": "2016-07-21 06:48:14"
},
{
"name": "phpunit/phpunit-mock-objects",
"version": "3.2.3",
"version": "2.3.8",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
"reference": "b13d0d9426ced06958bd32104653526a6c998a52"
"reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/b13d0d9426ced06958bd32104653526a6c998a52",
"reference": "b13d0d9426ced06958bd32104653526a6c998a52",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/ac8e7a3db35738d56ee9a76e78a4e03d97628983",
"reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983",
"shasum": ""
},
"require": {
"doctrine/instantiator": "^1.0.2",
"php": "^5.6 || ^7.0",
"phpunit/php-text-template": "^1.2",
"sebastian/exporter": "^1.2"
},
"conflict": {
"phpunit/phpunit": "<5.4.0"
"php": ">=5.3.3",
"phpunit/php-text-template": "~1.2",
"sebastian/exporter": "~1.2"
},
"require-dev": {
"phpunit/phpunit": "^5.4"
"phpunit/phpunit": "~4.4"
},
"suggest": {
"ext-soap": "*"
@ -666,7 +614,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.2.x-dev"
"dev-master": "2.3.x-dev"
}
},
"autoload": {
@ -691,52 +639,7 @@
"mock",
"xunit"
],
"time": "2016-06-12 07:37:26"
},
{
"name": "sebastian/code-unit-reverse-lookup",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git",
"reference": "c36f5e7cfce482fde5bf8d10d41a53591e0198fe"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/c36f5e7cfce482fde5bf8d10d41a53591e0198fe",
"reference": "c36f5e7cfce482fde5bf8d10d41a53591e0198fe",
"shasum": ""
},
"require": {
"php": ">=5.6"
},
"require-dev": {
"phpunit/phpunit": "~5"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
}
],
"description": "Looks up which function or method a line of code belongs to",
"homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/",
"time": "2016-02-13 06:45:14"
"time": "2015-10-02 06:51:40"
},
{
"name": "sebastian/comparator",
@ -1022,52 +925,6 @@
],
"time": "2015-10-12 03:26:01"
},
{
"name": "sebastian/object-enumerator",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/object-enumerator.git",
"reference": "d4ca2fb70344987502567bc50081c03e6192fb26"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/d4ca2fb70344987502567bc50081c03e6192fb26",
"reference": "d4ca2fb70344987502567bc50081c03e6192fb26",
"shasum": ""
},
"require": {
"php": ">=5.6",
"sebastian/recursion-context": "~1.0"
},
"require-dev": {
"phpunit/phpunit": "~5"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
}
],
"description": "Traverses array structures and object graphs to enumerate all referenced objects",
"homepage": "https://github.com/sebastianbergmann/object-enumerator/",
"time": "2016-01-28 13:25:10"
},
{
"name": "sebastian/recursion-context",
"version": "1.0.2",
@ -1121,71 +978,21 @@
"homepage": "http://www.github.com/sebastianbergmann/recursion-context",
"time": "2015-11-11 19:50:13"
},
{
"name": "sebastian/resource-operations",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/resource-operations.git",
"reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/ce990bb21759f94aeafd30209e8cfcdfa8bc3f52",
"reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52",
"shasum": ""
},
"require": {
"php": ">=5.6.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
}
],
"description": "Provides a list of PHP built-in functions that operate on resources",
"homepage": "https://www.github.com/sebastianbergmann/resource-operations",
"time": "2015-07-28 20:34:47"
},
{
"name": "sebastian/version",
"version": "2.0.0",
"version": "1.0.6",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/version.git",
"reference": "c829badbd8fdf16a0bad8aa7fa7971c029f1b9c5"
"reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c829badbd8fdf16a0bad8aa7fa7971c029f1b9c5",
"reference": "c829badbd8fdf16a0bad8aa7fa7971c029f1b9c5",
"url": "https://api.github.com/repos/sebastianbergmann/version/zipball/58b3a85e7999757d6ad81c787a1fbf5ff6c628c6",
"reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6",
"shasum": ""
},
"require": {
"php": ">=5.6"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"autoload": {
"classmap": [
"src/"
@ -1204,7 +1011,7 @@
],
"description": "Library that helps with managing the version number of Git-hosted PHP projects",
"homepage": "https://github.com/sebastianbergmann/version",
"time": "2016-02-04 12:56:52"
"time": "2015-06-21 13:59:46"
},
{
"name": "symfony/yaml",
@ -1311,7 +1118,7 @@
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
"php": ">=5.4"
"php": ">=5.3"
},
"platform-dev": []
}

View File

@ -149,7 +149,7 @@ class Variables extends \ArrayObject
file_get_contents(
sys_get_temp_dir().self::VARIABLE_NAMESPACE.self::VARIABLE_TEMP_FILE_NAME))
) {
$this->config = [];
$this->config = array();
}
}

View File

@ -50,7 +50,7 @@ class VariablesTest extends \PHPUnit_Framework_TestCase
$this->assertArrayHasKey('subVariableName1', variable_get('variableName4'));
$this->assertArraySubset($this->keyedArrayData, variable_get('variableName4'));
$this->assertEquals($this->object, variable_get('variableObjectName1'));
$this->assertNotSame('variableValue1', []);
$this->assertNotSame('variableValue1', array());
$this->assertSame(0, variable_get('thisVariableDoesntExist', 0));
$this->assertNull(variable_get('thisVariableDoesntExist'));
}