-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prepare Refactorings to be able to add tests
- Loading branch information
1 parent
138cf97
commit 51d569d
Showing
14 changed files
with
203 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
namespace GoalioForgotPassword\Form\Service; | ||
|
||
use GoalioForgotPassword\Form\Forgot; | ||
use GoalioForgotPassword\Form\ForgotFilter; | ||
use Zend\ServiceManager\ServiceLocatorInterface; | ||
use Zend\ServiceManager\FactoryInterface; | ||
|
||
class ForgotFactory implements FactoryInterface { | ||
|
||
public function createService(ServiceLocatorInterface $serviceLocator) { | ||
$options = $serviceLocator->get('goalioforgotpassword_module_options'); | ||
$form = new Forgot(null, $options); | ||
$validator = new \ZfcUser\Validator\RecordExists(array( | ||
'mapper' => $serviceLocator->get('zfcuser_user_mapper'), | ||
'key' => 'email' | ||
)); | ||
|
||
$translator = $serviceLocator->get('Translator'); | ||
|
||
$validator->setMessage($translator->translate('The email address you entered was not found.')); | ||
$form->setInputFilter(new ForgotFilter($validator,$options)); | ||
return $form; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
namespace GoalioForgotPassword\Form\Service; | ||
|
||
use GoalioForgotPassword\Form\Reset; | ||
use GoalioForgotPassword\Form\ResetFilter; | ||
use Zend\ServiceManager\ServiceLocatorInterface; | ||
use Zend\ServiceManager\FactoryInterface; | ||
|
||
class ForgotFactory implements FactoryInterface { | ||
|
||
public function createService(ServiceLocatorInterface $serviceLocator) { | ||
$options = $serviceLocator->get('goalioforgotpassword_module_options'); | ||
$form = new Reset(null, $options); | ||
$form->setInputFilter(new ResetFilter($options)); | ||
return $form; | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
src/GoalioForgotPassword/Mapper/Service/PasswordFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
namespace GoalioForgotPassword\Mapper\Service; | ||
|
||
use GoalioForgotPassword\Mapper\Password; | ||
use GoalioForgotPassword\Mapper\PasswordHydrator; | ||
use Zend\ServiceManager\ServiceLocatorInterface; | ||
use Zend\ServiceManager\FactoryInterface; | ||
|
||
class PasswordFactory implements FactoryInterface { | ||
|
||
public function createService(ServiceLocatorInterface $serviceLocator) { | ||
$options = $serviceLocator->get('goalioforgotpassword_module_options'); | ||
$mapper = new Password(); | ||
$mapper->setDbAdapter($serviceLocator->get('zfcuser_zend_db_adapter')); | ||
$entityClass = $options->getPasswordEntityClass(); | ||
$mapper->setEntityPrototype(new $entityClass); | ||
$mapper->setHydrator(new PasswordHydrator()); | ||
return $mapper; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/GoalioForgotPassword/Options/Service/ModuleOptionsFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
namespace GoalioForgotPassword\Options\Service; | ||
|
||
use GoalioForgotPassword\Options\ModuleOptions; | ||
use Zend\ServiceManager\ServiceLocatorInterface; | ||
use Zend\ServiceManager\FactoryInterface; | ||
|
||
class ModuleOptionsFactory implements FactoryInterface { | ||
|
||
public function createService(ServiceLocatorInterface $serviceLocator) { | ||
$config = $serviceLocator->get('Config'); | ||
return new ModuleOptions(isset($config['goalioforgotpassword']) ? $config['goalioforgotpassword'] : array()); | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
tests/GoalioForgotPasswordTest/Util/ServiceManagerFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace GoalioForgotPasswordTest\Util; | ||
|
||
use Zend\ServiceManager\ServiceManager; | ||
use Zend\Mvc\Service\ServiceManagerConfig; | ||
|
||
class ServiceManagerFactory | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
protected static $config; | ||
|
||
/** | ||
* @param array $config | ||
*/ | ||
public static function setConfig(array $config) | ||
{ | ||
static::$config = $config; | ||
} | ||
|
||
/** | ||
* Builds a new service manager | ||
*/ | ||
public static function getServiceManager() | ||
{ | ||
$serviceManager = new ServiceManager(new ServiceManagerConfig( | ||
isset(static::$config['service_manager']) ? static::$config['service_manager'] : array() | ||
)); | ||
$serviceManager->setService('ApplicationConfig', static::$config); | ||
$serviceManager->setFactory('ServiceListener', 'Zend\Mvc\Service\ServiceListenerFactory'); | ||
|
||
/** @var $moduleManager \Zend\ModuleManager\ModuleManager */ | ||
$moduleManager = $serviceManager->get('ModuleManager'); | ||
$moduleManager->loadModules(); | ||
//$serviceManager->setAllowOverride(true); | ||
return $serviceManager; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
chdir(__DIR__); | ||
|
||
$loader = null; | ||
if (file_exists('../vendor/autoload.php')) { | ||
$loader = include '../vendor/autoload.php'; | ||
} elseif (file_exists('../../../autoload.php')) { | ||
$loader = include '../../../autoload.php'; | ||
} else { | ||
throw new RuntimeException('vendor/autoload.php could not be found. Did you run `php composer.phar install`?'); | ||
} | ||
|
||
$loader->add('GoalioForgotPasswordTest', __DIR__); | ||
|
||
if (!$config = @include 'configuration.php') { | ||
$config = require 'configuration.php.dist'; | ||
} | ||
|
||
\GoalioForgotPasswordTest\Util\ServiceManagerFactory::setConfig($config); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
return array( | ||
'modules' => array( | ||
'GoalioMailService' | ||
), | ||
'module_listener_options' => array( | ||
'config_glob_paths' => array( | ||
__DIR__ . '/testing.config.php', | ||
), | ||
'module_paths' => array(), | ||
), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<phpunit bootstrap="./bootstrap.php" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
verbose="true" | ||
stopOnFailure="false" | ||
processIsolation="false" | ||
backupGlobals="false" | ||
syntaxCheck="true" | ||
> | ||
<testsuite name="GoalioForgotPassword Test Suite"> | ||
<directory>./GoalioForgotPasswordTest</directory> | ||
</testsuite> | ||
|
||
<filter> | ||
<whitelist> | ||
<directory suffix=".php">../src</directory> | ||
</whitelist> | ||
</filter> | ||
|
||
<logging> | ||
<log type="coverage-text" target="php://stdout"/> | ||
<log type="coverage-clover" target="../build/logs/clover.xml"/> | ||
</logging> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
return array( | ||
'service_manager' => array( | ||
'invokables' => array( | ||
'goalioforgotpassword_password_service' => 'GoalioForgotPassword\Service\Password', | ||
), | ||
'factories' => array( | ||
'goalioforgotpassword_module_options' => 'GoalioForgotPassword\Options\Service\ModuleOptionsFactory', | ||
'goalioforgotpassword_forgot_form' => 'GoalioForgotPassword\Form\Service\ForgotFactory', | ||
'goalioforgotpassword_reset_form' => 'GoalioForgotPassword\Form\Service\ResetFactory', | ||
'goalioforgotpassword_password_mapper' => 'GoalioForgotPassword\Mapper\Service\PasswordFactory', | ||
), | ||
), | ||
); |