commit 27da5247596fa2490c3be16bc84ba55b19fe6752
parent 18d638ca85c90a894a0c3221264aa84daf0acb53
Author: Felicitus <felicitus@felicitus.org>
Date: Sun, 3 May 2015 19:08:36 +0200
Created unit tests for login
Diffstat:
12 files changed, 385 insertions(+), 174 deletions(-)
diff --git a/app/AppKernel.php b/app/AppKernel.php
@@ -56,7 +56,7 @@ class AppKernel extends Kernel
new JMS\SerializerBundle\JMSSerializerBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new Nelmio\ApiDocBundle\NelmioApiDocBundle(),
- new PartKeepr\AuthBundle\PartKeeprAuthBundle(),
+ new \Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),
);
// Developer bundles
@@ -64,11 +64,13 @@ class AppKernel extends Kernel
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
+ $bundles[] = new Liip\FunctionalTestBundle\LiipFunctionalTestBundle();
}
// PartKeepr bundles
$bundles[] = new PartKeepr\FrontendBundle\PartKeeprFrontendBundle();
$bundles[] = new PartKeepr\SiPrefixBundle\PartKeeprSiPrefixBundle();
+ $bundles[] = new PartKeepr\AuthBundle\PartKeeprAuthBundle();
return $bundles;
}
diff --git a/app/SymfonyRequirements.php b/app/SymfonyRequirements.php
@@ -77,7 +77,7 @@ class Requirement
}
/**
- * Returns the help text for resolving the problem
+ * Returns the help text for resolving the problem.
*
* @return string The help text
*/
@@ -119,14 +119,14 @@ class PhpIniRequirement extends Requirement
*
* @param string $cfgName The configuration name used for ini_get()
* @param Boolean|callback $evaluation Either a Boolean indicating whether the configuration should evaluate to true or false,
- or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement
- * @param Boolean $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false.
- This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin.
- Example: You require a config to be true but PHP later removes this config and defaults it to true internally.
- * @param string|null $testMessage The message for testing the requirement (when null and $evaluation is a Boolean a default message is derived)
- * @param string|null $helpHtml The help text formatted in HTML for resolving the problem (when null and $evaluation is a Boolean a default help is derived)
- * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags)
- * @param Boolean $optional Whether this is only an optional recommendation not a mandatory requirement
+ * or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement
+ * @param Boolean $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false.
+ * This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin.
+ * Example: You require a config to be true but PHP later removes this config and defaults it to true internally.
+ * @param string|null $testMessage The message for testing the requirement (when null and $evaluation is a Boolean a default message is derived)
+ * @param string|null $helpHtml The help text formatted in HTML for resolving the problem (when null and $evaluation is a Boolean a default help is derived)
+ * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags)
+ * @param Boolean $optional Whether this is only an optional recommendation not a mandatory requirement
*/
public function __construct($cfgName, $evaluation, $approveCfgAbsence = false, $testMessage = null, $helpHtml = null, $helpText = null, $optional = false)
{
@@ -221,13 +221,13 @@ class RequirementCollection implements IteratorAggregate
*
* @param string $cfgName The configuration name used for ini_get()
* @param Boolean|callback $evaluation Either a Boolean indicating whether the configuration should evaluate to true or false,
- or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement
- * @param Boolean $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false.
- This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin.
- Example: You require a config to be true but PHP later removes this config and defaults it to true internally.
- * @param string $testMessage The message for testing the requirement (when null and $evaluation is a Boolean a default message is derived)
- * @param string $helpHtml The help text formatted in HTML for resolving the problem (when null and $evaluation is a Boolean a default help is derived)
- * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags)
+ * or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement
+ * @param Boolean $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false.
+ * This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin.
+ * Example: You require a config to be true but PHP later removes this config and defaults it to true internally.
+ * @param string $testMessage The message for testing the requirement (when null and $evaluation is a Boolean a default message is derived)
+ * @param string $helpHtml The help text formatted in HTML for resolving the problem (when null and $evaluation is a Boolean a default help is derived)
+ * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags)
*/
public function addPhpIniRequirement($cfgName, $evaluation, $approveCfgAbsence = false, $testMessage = null, $helpHtml = null, $helpText = null)
{
@@ -239,13 +239,13 @@ class RequirementCollection implements IteratorAggregate
*
* @param string $cfgName The configuration name used for ini_get()
* @param Boolean|callback $evaluation Either a Boolean indicating whether the configuration should evaluate to true or false,
- or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement
- * @param Boolean $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false.
- This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin.
- Example: You require a config to be true but PHP later removes this config and defaults it to true internally.
- * @param string $testMessage The message for testing the requirement (when null and $evaluation is a Boolean a default message is derived)
- * @param string $helpHtml The help text formatted in HTML for resolving the problem (when null and $evaluation is a Boolean a default help is derived)
- * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags)
+ * or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement
+ * @param Boolean $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false.
+ * This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin.
+ * Example: You require a config to be true but PHP later removes this config and defaults it to true internally.
+ * @param string $testMessage The message for testing the requirement (when null and $evaluation is a Boolean a default message is derived)
+ * @param string $helpHtml The help text formatted in HTML for resolving the problem (when null and $evaluation is a Boolean a default help is derived)
+ * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags)
*/
public function addPhpIniRecommendation($cfgName, $evaluation, $approveCfgAbsence = false, $testMessage = null, $helpHtml = null, $helpText = null)
{
diff --git a/app/config/config_test.yml b/app/config/config_test.yml
@@ -15,6 +15,10 @@ web_profiler:
doctrine:
dbal:
- driver: pdo_sqlite
- charset: UTF8
- memory: true-
\ No newline at end of file
+ default_connection: default
+ connections:
+ default:
+ driver: pdo_sqlite
+ path: %kernel.cache_dir%/test.db
+
+liip_functional_test: ~+
\ No newline at end of file
diff --git a/composer.json b/composer.json
@@ -42,7 +42,9 @@
"jms/serializer-bundle": "0.13.0",
"cbsi/doctrine2-nestedset": "dev-master",
"zendmaniacs/extjs5": "dev-master",
- "fortawesome/font-awesome": "4.1.0"
+ "fortawesome/font-awesome": "4.1.0",
+ "doctrine/doctrine-fixtures-bundle": "2.2.*",
+ "symfony/doctrine-bridge": "2.7.x-dev"
},
"autoload": {
"psr-0": { "": "src/",
@@ -73,5 +75,8 @@
"installer-paths": {
"web/js/packages/{$name}": ["zendmaniacs/extjs5"]
}
+ },
+ "require-dev": {
+ "liip/functional-test-bundle": "~1.1"
}
}
diff --git a/composer.lock b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
- "hash": "51531e7d2e001a0f394195667f791526",
+ "hash": "73df1c8000eb59280fdd3b9719de71bf",
"packages": [
{
"name": "cbsi/doctrine2-nestedset",
@@ -436,6 +436,63 @@
"time": "2014-05-21 19:28:51"
},
{
+ "name": "doctrine/data-fixtures",
+ "version": "v1.1.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/doctrine/data-fixtures.git",
+ "reference": "70020ae434da2e87fb62b40aba1211ef4fb04182"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/doctrine/data-fixtures/zipball/70020ae434da2e87fb62b40aba1211ef4fb04182",
+ "reference": "70020ae434da2e87fb62b40aba1211ef4fb04182",
+ "shasum": ""
+ },
+ "require": {
+ "doctrine/common": "~2.2",
+ "php": ">=5.3.2"
+ },
+ "conflict": {
+ "doctrine/orm": "< 2.4"
+ },
+ "require-dev": {
+ "doctrine/orm": "~2.4"
+ },
+ "suggest": {
+ "doctrine/mongodb-odm": "For loading MongoDB ODM fixtures",
+ "doctrine/orm": "For loading ORM fixtures",
+ "doctrine/phpcr-odm": "For loading PHPCR ODM fixtures"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.1.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-0": {
+ "Doctrine\\Common\\DataFixtures": "lib/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Jonathan Wage",
+ "email": "jonwage@gmail.com"
+ }
+ ],
+ "description": "Data Fixtures for all Doctrine Object Managers",
+ "homepage": "http://www.doctrine-project.org",
+ "keywords": [
+ "database"
+ ],
+ "time": "2015-03-28 22:24:17"
+ },
+ {
"name": "doctrine/dbal",
"version": "v2.5.1",
"source": {
@@ -668,6 +725,66 @@
"time": "2014-11-28 09:43:36"
},
{
+ "name": "doctrine/doctrine-fixtures-bundle",
+ "version": "v2.2.0",
+ "target-dir": "Doctrine/Bundle/FixturesBundle",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/doctrine/DoctrineFixturesBundle.git",
+ "reference": "c811f96f0cf83b997e3a3ed037cac729bbe3e803"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/doctrine/DoctrineFixturesBundle/zipball/c811f96f0cf83b997e3a3ed037cac729bbe3e803",
+ "reference": "c811f96f0cf83b997e3a3ed037cac729bbe3e803",
+ "shasum": ""
+ },
+ "require": {
+ "doctrine/data-fixtures": "~1.0",
+ "doctrine/doctrine-bundle": "~1.0",
+ "php": ">=5.3.2",
+ "symfony/doctrine-bridge": "~2.1"
+ },
+ "type": "symfony-bundle",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.1.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-0": {
+ "Doctrine\\Bundle\\FixturesBundle": ""
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com",
+ "homepage": "http://fabien.potencier.org",
+ "role": "Lead Developer"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "http://symfony.com/contributors"
+ },
+ {
+ "name": "Doctrine Project",
+ "homepage": "http://www.doctrine-project.org"
+ }
+ ],
+ "description": "Symfony DoctrineFixturesBundle",
+ "homepage": "http://www.doctrine-project.org",
+ "keywords": [
+ "Fixture",
+ "persistence"
+ ],
+ "time": "2013-09-05 11:23:37"
+ },
+ {
"name": "doctrine/inflector",
"version": "v1.0.1",
"source": {
@@ -1516,17 +1633,17 @@
},
{
"name": "nelmio/api-doc-bundle",
- "version": "2.7.0",
+ "version": "2.8.0",
"target-dir": "Nelmio/ApiDocBundle",
"source": {
"type": "git",
"url": "https://github.com/nelmio/NelmioApiDocBundle.git",
- "reference": "3fdb2d4a819d1f71bff0c45880af705a8b124955"
+ "reference": "f23351b1321942c4264efb604653d475cff7201f"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/nelmio/NelmioApiDocBundle/zipball/3fdb2d4a819d1f71bff0c45880af705a8b124955",
- "reference": "3fdb2d4a819d1f71bff0c45880af705a8b124955",
+ "url": "https://api.github.com/repos/nelmio/NelmioApiDocBundle/zipball/f23351b1321942c4264efb604653d475cff7201f",
+ "reference": "f23351b1321942c4264efb604653d475cff7201f",
"shasum": ""
},
"require": {
@@ -1542,7 +1659,7 @@
"require-dev": {
"friendsofsymfony/rest-bundle": "~1.0",
"jms/serializer-bundle": ">=0.11",
- "sensio/framework-extra-bundle": "~2.1",
+ "sensio/framework-extra-bundle": "~3.0",
"symfony/browser-kit": "~2.1",
"symfony/css-selector": "~2.1",
"symfony/form": "~2.1",
@@ -1558,7 +1675,7 @@
"type": "symfony-bundle",
"extra": {
"branch-alias": {
- "dev-master": "2.7.x-dev"
+ "dev-master": "2.8.x-dev"
}
},
"autoload": {
@@ -1587,7 +1704,7 @@
"documentation",
"rest"
],
- "time": "2014-07-30 09:11:08"
+ "time": "2015-03-06 10:47:58"
},
{
"name": "phpcollection/phpcollection",
@@ -1728,17 +1845,17 @@
},
{
"name": "sensio/distribution-bundle",
- "version": "v2.3.11",
+ "version": "v2.3.13",
"target-dir": "Sensio/Bundle/DistributionBundle",
"source": {
"type": "git",
"url": "https://github.com/sensiolabs/SensioDistributionBundle.git",
- "reference": "374bbea795fa69a85b1623048798a89aebffe62b"
+ "reference": "c344892aa9f09f0005b395d79ad2531a7deaedc9"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sensiolabs/SensioDistributionBundle/zipball/374bbea795fa69a85b1623048798a89aebffe62b",
- "reference": "374bbea795fa69a85b1623048798a89aebffe62b",
+ "url": "https://api.github.com/repos/sensiolabs/SensioDistributionBundle/zipball/c344892aa9f09f0005b395d79ad2531a7deaedc9",
+ "reference": "c344892aa9f09f0005b395d79ad2531a7deaedc9",
"shasum": ""
},
"require": {
@@ -1770,7 +1887,7 @@
"configuration",
"distribution"
],
- "time": "2015-02-27 12:58:18"
+ "time": "2015-03-26 11:09:17"
},
{
"name": "sensio/framework-extra-bundle",
@@ -1823,17 +1940,17 @@
},
{
"name": "sensio/generator-bundle",
- "version": "v2.5.2",
+ "version": "v2.5.3",
"target-dir": "Sensio/Bundle/GeneratorBundle",
"source": {
"type": "git",
"url": "https://github.com/sensiolabs/SensioGeneratorBundle.git",
- "reference": "4b09746520a826a7bf34a466ba31c7d8740fef7e"
+ "reference": "e50108c2133ee5c9c484555faed50c17a61221d3"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sensiolabs/SensioGeneratorBundle/zipball/4b09746520a826a7bf34a466ba31c7d8740fef7e",
- "reference": "4b09746520a826a7bf34a466ba31c7d8740fef7e",
+ "url": "https://api.github.com/repos/sensiolabs/SensioGeneratorBundle/zipball/e50108c2133ee5c9c484555faed50c17a61221d3",
+ "reference": "e50108c2133ee5c9c484555faed50c17a61221d3",
"shasum": ""
},
"require": {
@@ -1867,7 +1984,7 @@
}
],
"description": "This bundle generates code for you",
- "time": "2015-02-11 07:21:23"
+ "time": "2015-03-17 06:36:52"
},
{
"name": "swiftmailer/swiftmailer",
@@ -1987,6 +2104,76 @@
"time": "2015-01-27 12:45:16"
},
{
+ "name": "symfony/doctrine-bridge",
+ "version": "2.7.x-dev",
+ "target-dir": "Symfony/Bridge/Doctrine",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/DoctrineBridge.git",
+ "reference": "cabea45a299993dc0d934db614ebc58d2822b52b"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/DoctrineBridge/zipball/cabea45a299993dc0d934db614ebc58d2822b52b",
+ "reference": "cabea45a299993dc0d934db614ebc58d2822b52b",
+ "shasum": ""
+ },
+ "require": {
+ "doctrine/common": "~2.3",
+ "php": ">=5.3.9"
+ },
+ "require-dev": {
+ "doctrine/data-fixtures": "1.0.*",
+ "doctrine/dbal": "~2.2",
+ "doctrine/orm": "~2.2,>=2.2.3",
+ "symfony/dependency-injection": "~2.2|~3.0.0",
+ "symfony/expression-language": "~2.2|~3.0.0",
+ "symfony/form": "~2.7|~3.0.0",
+ "symfony/http-kernel": "~2.2|~3.0.0",
+ "symfony/phpunit-bridge": "~2.7|~3.0.0",
+ "symfony/property-access": "~2.3|~3.0.0",
+ "symfony/security": "~2.2|~3.0.0",
+ "symfony/stopwatch": "~2.2|~3.0.0",
+ "symfony/translation": "~2.0,>=2.0.5|~3.0.0",
+ "symfony/validator": "~2.5,>=2.5.5|~3.0.0"
+ },
+ "suggest": {
+ "doctrine/data-fixtures": "",
+ "doctrine/dbal": "",
+ "doctrine/orm": "",
+ "symfony/form": "",
+ "symfony/validator": ""
+ },
+ "type": "symfony-bridge",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.7-dev"
+ }
+ },
+ "autoload": {
+ "psr-0": {
+ "Symfony\\Bridge\\Doctrine\\": ""
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Symfony Community",
+ "homepage": "http://symfony.com/contributors"
+ },
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ }
+ ],
+ "description": "Symfony Doctrine Bridge",
+ "homepage": "http://symfony.com",
+ "time": "2015-03-22 16:57:18"
+ },
+ {
"name": "symfony/monolog-bundle",
"version": "v2.7.1",
"source": {
@@ -2104,16 +2291,16 @@
},
{
"name": "symfony/symfony",
- "version": "v2.6.4",
+ "version": "v2.6.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/symfony.git",
- "reference": "23b647f1e4eeb24a457d3c47f5f5046377d5a3bf"
+ "reference": "80833da9d04b004fa59fd23102e6dfad80c98106"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/symfony/zipball/23b647f1e4eeb24a457d3c47f5f5046377d5a3bf",
- "reference": "23b647f1e4eeb24a457d3c47f5f5046377d5a3bf",
+ "url": "https://api.github.com/repos/symfony/symfony/zipball/80833da9d04b004fa59fd23102e6dfad80c98106",
+ "reference": "80833da9d04b004fa59fd23102e6dfad80c98106",
"shasum": ""
},
"require": {
@@ -2177,7 +2364,8 @@
"ircmaxell/password-compat": "~1.0",
"monolog/monolog": "~1.11",
"ocramius/proxy-manager": "~0.4|~1.0",
- "propel/propel1": "~1.6"
+ "propel/propel1": "~1.6",
+ "symfony/phpunit-bridge": "~2.7"
},
"type": "library",
"extra": {
@@ -2216,7 +2404,7 @@
"keywords": [
"framework"
],
- "time": "2015-02-02 18:02:30"
+ "time": "2015-03-17 14:58:46"
},
{
"name": "twig/extensions",
@@ -2422,12 +2610,12 @@
"source": {
"type": "git",
"url": "https://github.com/zendmaniacs/extjs5.git",
- "reference": "77a9e5002be20038337a4c621c512f09bf064bd6"
+ "reference": "e2540f3225a208894dfe178d6d68764bd1c3dbd9"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/zendmaniacs/extjs5/zipball/77a9e5002be20038337a4c621c512f09bf064bd6",
- "reference": "77a9e5002be20038337a4c621c512f09bf064bd6",
+ "url": "https://api.github.com/repos/zendmaniacs/extjs5/zipball/e2540f3225a208894dfe178d6d68764bd1c3dbd9",
+ "reference": "e2540f3225a208894dfe178d6d68764bd1c3dbd9",
"shasum": ""
},
"require": {
@@ -2443,15 +2631,73 @@
"extjs5",
"zendmaniacs"
],
- "time": "2015-02-09 15:57:01"
+ "time": "2015-03-19 13:17:50"
+ }
+ ],
+ "packages-dev": [
+ {
+ "name": "liip/functional-test-bundle",
+ "version": "1.1.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/liip/LiipFunctionalTestBundle.git",
+ "reference": "0f7b983a22b59cbee27ff6e26c7a9a8d805eb5e2"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/liip/LiipFunctionalTestBundle/zipball/0f7b983a22b59cbee27ff6e26c7a9a8d805eb5e2",
+ "reference": "0f7b983a22b59cbee27ff6e26c7a9a8d805eb5e2",
+ "shasum": ""
+ },
+ "require": {
+ "doctrine/common": "2.*",
+ "php": ">=5.3.2",
+ "symfony/browser-kit": "~2.0",
+ "symfony/framework-bundle": "~2.0"
+ },
+ "suggest": {
+ "doctrine/dbal": "Required when using the fixture loading functionality with an ORM and SQLite",
+ "doctrine/doctrine-fixtures-bundle": "Required when using the fixture loading functionality",
+ "doctrine/orm": "Required when using the fixture loading functionality with an ORM and SQLite"
+ },
+ "type": "symfony-bundle",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.1.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Liip\\FunctionalTestBundle\\": ""
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Liip AG",
+ "homepage": "http://www.liip.ch/"
+ },
+ {
+ "name": "Community contributions",
+ "homepage": "https://github.com/liip/LiipFunctionalTestBundle/contributors"
+ }
+ ],
+ "description": "This bundles provides additional functional test-cases for Symfony2 applications",
+ "keywords": [
+ "Symfony2"
+ ],
+ "time": "2015-03-20 15:18:13"
}
],
- "packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": {
"cbsi/doctrine2-nestedset": 20,
- "zendmaniacs/extjs5": 20
+ "zendmaniacs/extjs5": 20,
+ "symfony/doctrine-bridge": 20
},
"prefer-stable": false,
"prefer-lowest": false,
diff --git a/documentation/developer/REST-API.md b/documentation/developer/REST-API.md
@@ -0,0 +1,7 @@
+# The PartKeepr REST API
+The PartKeepr frontend communicates with the backend using an
+[REST API](http://en.wikipedia.org/wiki/Representational_state_transfer).
+
+# Headers
+
+PartKeepr sets a few headers which are not included in the REST API Specification:
diff --git a/src/PartKeepr/AuthBundle/DataFixtures/LoadUserData.php b/src/PartKeepr/AuthBundle/DataFixtures/LoadUserData.php
@@ -0,0 +1,17 @@
+<?php
+namespace PartKeepr\AuthBundle\DataFixtures;
+
+use Doctrine\Common\DataFixtures\FixtureInterface;
+use Doctrine\Common\Persistence\ObjectManager;
+use PartKeepr\AuthBundle\Entity\User\User;
+
+class LoadUserData implements FixtureInterface {
+ public function load (ObjectManager $manager) {
+ $admin = new User();
+ $admin->setUsername("admin");
+ $admin->setPassword("admin");
+
+ $manager->persist($admin);
+ $manager->flush();
+ }
+}+
\ No newline at end of file
diff --git a/src/PartKeepr/AuthBundle/Entity/User/User.php b/src/PartKeepr/AuthBundle/Entity/User/User.php
@@ -93,7 +93,7 @@ class User extends BaseEntity implements Serializable, Deserializable {
* Sets the user's password. Automatically
* applies md5 hashing.
*
- * @param string $password
+ * @param string $password The unencrypted password
*/
public function setPassword ($password) {
$this->setHashedPassword(md5($password));
diff --git a/src/PartKeepr/AuthBundle/Tests/Controller/DefaultControllerTest.php b/src/PartKeepr/AuthBundle/Tests/Controller/DefaultControllerTest.php
@@ -2,16 +2,38 @@
namespace PartKeepr\AuthBundle\Tests\Controller;
-use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
+use Liip\FunctionalTestBundle\Test\WebTestCase;
class DefaultControllerTest extends WebTestCase
{
- public function testIndex()
+
+ private $repo;
+
+ public function testLogin()
{
+ $this->loadFixtures(
+ array(
+ 'PartKeepr\AuthBundle\DataFixtures\LoadUserData'
+ )
+ );
+
$client = static::createClient();
- $crawler = $client->request('GET', '/hello/Fabien');
+ $request = array("username" => "admin", "password" => md5("admin"));
+
+ $client->request(
+ 'POST',
+ '/auth/login',
+ array(),
+ array(),
+ array('CONTENT_TYPE' => 'application/json'),
+ json_encode($request)
+ );
+
+ $response = json_decode($client->getResponse()->getContent());
+
+ $this->assertObjectHasAttribute("sessionId", $response);
+ $this->assertObjectHasAttribute("username", $response);
- $this->assertTrue($crawler->filter('html:contains("Hello Fabien")')->count() > 0);
}
}
diff --git a/src/backend/PartKeepr/Auth/AuthService.php b/src/backend/PartKeepr/Auth/AuthService.php
@@ -1,95 +0,0 @@
-<?php
-namespace PartKeepr\Auth;
-
-use PartKeepr\AuthBundle\Entity\User\Exceptions\InvalidLoginDataException;
-use PartKeepr\AuthBundle\Entity\User\User;
-use PartKeepr\AuthBundle\Entity\User\UserManager;
-use PartKeepr\Service\AnonService;
-use PartKeepr\Session\SessionManager;
-
-
-/**
- * Implements the AuthService
- * @ServiceDescription(description="Manages authentication against PartKeepr")
- */
-class AuthService extends AnonService {
- /**
- * Logs in the given user. If the login was successful, a session is automatically started.
- *
- * @return array The data
- * @throws InvalidLoginDataException
- *
- * @ServiceCall(description="Authenticates a user against the system",
- * documentation="Authenticates a user and starts a new session upon success.",
- * returnValues={
- * @ServiceReturnValue(
- * name="username",
- * type="string:50",
- * description="The logged in username"
- * ),
- * @ServiceReturnValue(
- * name="sessionid",
- * type="string:50",
- * description="The session ID"
- * ),
- * @ServiceReturnValue(
- * name="admin",
- * type="boolean",
- * description="True if the logged in user has admin rights"
- * ),
- * @ServiceReturnValue(
- * name="userPreferences",
- * type="UserPreference[]",
- * description="An array of UserPreferences"
- * )
- * },
- * parameters={
- * @ServiceParameter( name="username",
- * type="string:50",
- * required=true,
- * description="The username to authenticate"
- * ),
- * @ServiceParameter( name="password",
- * type="string:32",
- * required=true,
- * description="The password, hashed in MD5"
- * )
- * })
- *
- */
- public function login () {
- $this->requireParameter("username");
- $this->requireParameter("password");
-
- /* Build a temporary user */
- $user = new User;
- $user->setRawUsername($this->getParameter("username"));
- $user->setHashedPassword($this->getParameter("password"));
-
- $authenticatedUser = UserManager::getInstance()->authenticate($user);
-
- if ($authenticatedUser !== false) {
- /* Start Session */
- $session = SessionManager::getInstance()->startSession($authenticatedUser);
-
- $session->getUser()->updateSeen();
-
- $aPreferences = array();
-
- foreach ($session->getUser()->getPreferences() as $result) {
- $aPreferences[] = $result->serialize();
- }
-
- return array(
- "sessionid" => $session->getSessionID(),
- "username" => $this->getParameter("username"),
- "admin" => $session->getUser()->isAdmin(),
- "userPreferences" => array(
- "response" => array(
- "data" => $aPreferences
- )));
- } else {
- throw new InvalidLoginDataException();
- }
- }
-}
diff --git a/src/backend/PartKeepr/Session/Session.php b/src/backend/PartKeepr/Session/Session.php
@@ -3,8 +3,9 @@ namespace PartKeepr\Session;
use Doctrine\ORM\Mapping as ORM;
use PartKeepr\AuthBundle\Entity\User\User;
+use Symfony\Component\HttpFoundation\Session\Session as SymfonySession;
use PartKeepr\PartKeepr;
-
+use Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage;
/** @ORM\Entity */
class Session {
@@ -21,23 +22,24 @@ class Session {
* @ORM\ManyToOne(targetEntity="PartKeepr\AuthBundle\Entity\User\User")
*/
private $user;
+
+ private $session;
public function __construct () {
-
}
public function start () {
- session_start();
- session_regenerate_id();
- session_destroy();
- unset($_SESSION);
- session_start();
+ $this->session = new SymfonySession(new MockFileSessionStorage());
+ $this->session->start();
+ $this->session->migrate();
+ $this->session->invalidate();
+ $this->session->start();
$query = PartKeepr::getEM()->createQuery("DELETE FROM PartKeepr\\Session\\Session s WHERE s.sessionid = :session");
- $query->setParameter("session", session_id());
+ $query->setParameter("session", $this->session->getId());
$query->execute();
- $this->sessionid = session_id();
+ $this->sessionid = $this->session->getId();
}
public function getId(){
@@ -49,8 +51,9 @@ class Session {
}
public function resume () {
- session_id($this->sessionid);
- session_start();
+ $this->session = new SymfonySession(new MockFileSessionStorage());
+ $this->session->setId($this->sessionid);
+ $this->session->start();
}
/**
@@ -65,5 +68,4 @@ class Session {
$this->user = $user;
}
-}
-?>-
\ No newline at end of file
+}+
\ No newline at end of file
diff --git a/src/backend/PartKeepr/Session/SessionManager.php b/src/backend/PartKeepr/Session/SessionManager.php
@@ -37,7 +37,7 @@ class SessionManager extends Singleton {
PartKeepr::getEM()->persist($session);
}
} else {
- $session = new Session;
+ $session = new Session();
$session->setUser(null);
$session->start();
PartKeepr::getEM()->persist($session);