mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-08 18:44:30 +00:00
Fix unit tests
This commit is contained in:
@@ -238,7 +238,7 @@ class Export implements ControllerProviderInterface
|
||||
$list = $download->prepare_export(
|
||||
$app['phraseanet.user'],
|
||||
$app['filesystem'],
|
||||
$request->request->get('obj'),
|
||||
(array) $request->request->get('obj'),
|
||||
$request->request->get("type") == "title" ? : false,
|
||||
$request->request->get('businessfields')
|
||||
);
|
||||
@@ -288,9 +288,9 @@ class Export implements ControllerProviderInterface
|
||||
$receiver = new Receiver(null, trim($mail));
|
||||
|
||||
$mail = MailRecordsExport::create($app, $receiver, $emitter, $request->request->get('textmail'));
|
||||
$mail->setUrl($url);
|
||||
$mail->setEnddate($endDateObject);
|
||||
|
||||
$mail->setButtonUrl($url);
|
||||
$mail->setExpiration($endDateObject);
|
||||
|
||||
try {
|
||||
$app['notification.deliverer']->deliver($mail);
|
||||
unset($remaingEmails[$key]);
|
||||
|
@@ -21,7 +21,6 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||
use Symfony\Component\HttpFoundation\File\MimeType\FileBinaryMimeTypeGuesser;
|
||||
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser;
|
||||
use Symfony\Component\Serializer\Serializer;
|
||||
|
||||
/**
|
||||
* Upload controller collection
|
||||
@@ -303,7 +302,7 @@ class Upload implements ControllerProviderInterface
|
||||
|
||||
foreach ($user->ACL()->get_granted_base(array('canaddrecord')) as $collection) {
|
||||
$databox = $collection->get_databox();
|
||||
|
||||
|
||||
if ( ! isset($collections[$databox->get_sbas_id()])) {
|
||||
$collections[$databox->get_sbas_id()] = array(
|
||||
'databox' => $databox,
|
||||
|
@@ -296,13 +296,13 @@ class Account implements ControllerProviderInterface
|
||||
}
|
||||
|
||||
try {
|
||||
$date = new DateTime('1 day');
|
||||
$token = random::getUrlToken($app, \random::TYPE_EMAIL, $app['phraseanet.user']->get_id(), $date, $app['phraseanet.user']->get_email());
|
||||
$date = new \DateTime('1 day');
|
||||
$token = \random::getUrlToken($app, \random::TYPE_EMAIL, $app['phraseanet.user']->get_id(), $date, $app['phraseanet.user']->get_email());
|
||||
$url = $app['phraseanet.registry']->get('GV_ServerName') . 'account/reset-email/?token=' . $token;
|
||||
|
||||
$receiver = Receiver::fromUser($app['phraseanet.user']);
|
||||
$mail = MailRequestEmailUpdate::create($app, $receiver, null);
|
||||
$mail->setUrl($url);
|
||||
$mail->setButtonUrl($url);
|
||||
$mail->setExpiration($date);
|
||||
|
||||
$app['notification.deliverer']->deliver($mail);
|
||||
|
@@ -287,17 +287,23 @@ class Login implements ControllerProviderInterface
|
||||
|
||||
\random::removeToken($app, $code);
|
||||
|
||||
if (\Swift_Validate::email($user->get_email())) {
|
||||
if (count($user->ACL()->get_granted_base()) > 0) {
|
||||
$mail = MailSuccessEmailConfirmationRegistered::create($app, Receiver::fromUser($user));
|
||||
$app['notification.deliverer']->deliver($mail);
|
||||
}
|
||||
if (!\Swift_Validate::email($user->get_email())) {
|
||||
return $app->redirect('/login/?redirect=prod¬ice=invalid-email');
|
||||
}
|
||||
|
||||
$user->set_mail_locked(false);
|
||||
\random::removeToken($app, $code);
|
||||
$user->set_mail_locked(false);
|
||||
\random::removeToken($app, $code);
|
||||
|
||||
if (count($user->ACL()->get_granted_base()) > 0) {
|
||||
$mail = MailSuccessEmailConfirmationRegistered::create($app, Receiver::fromUser($user));
|
||||
$app['notification.deliverer']->deliver($mail);
|
||||
|
||||
return $app->redirect('/login/?redirect=prod¬ice=confirm-ok');
|
||||
} else {
|
||||
$mail = MailSuccessEmailConfirmationUnregistered::create($app, Receiver::fromUser($user));
|
||||
$app['notification.deliverer']->deliver($mail);
|
||||
|
||||
return $app->redirect('/login/?redirect=prod¬ice=confirm-ok-wait');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -328,13 +334,9 @@ class Login implements ControllerProviderInterface
|
||||
|
||||
$mail = MailRequestEmailConfirmation::create($app, Receiver::fromUser($user));
|
||||
$mail->setButtonUrl($url);
|
||||
$app['notification.deliverer']->deliver($mail);
|
||||
|
||||
try {
|
||||
$app['notification.deliverer']->deliver($mail);
|
||||
return $app->redirect($app['url_generator']->generate('login_forgot_password', array('sent' => 'ok')));
|
||||
} catch (\Exception $e) {
|
||||
return $app->redirect($app['url_generator']->generate('login_forgot_password', array('sent' => 'ok')));
|
||||
}
|
||||
return $app->redirect($app['url_generator']->generate('login_forgot_password', array('sent' => 'ok')));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -632,82 +634,72 @@ class Login implements ControllerProviderInterface
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$user = \User_Adapter::create($app, $request->request->get('form_login'), $request->request->get("form_password"), $request->request->get("form_email"), false);
|
||||
$user = \User_Adapter::create($app, $request->request->get('form_login'), $request->request->get("form_password"), $request->request->get("form_email"), false);
|
||||
|
||||
$user->set_gender($request->request->get('form_gender'))
|
||||
->set_firstname($request->request->get('form_firstname'))
|
||||
->set_lastname($request->request->get('form_lastname'))
|
||||
->set_address($request->request->get('form_address'))
|
||||
->set_zip($request->request->get('form_zip'))
|
||||
->set_tel($request->request->get('form_phone'))
|
||||
->set_fax($request->request->get('form_fax'))
|
||||
->set_job($request->request->get('form_job'))
|
||||
->set_company($request->request->get('form_company'))
|
||||
->set_position($request->request->get('form_activity'))
|
||||
->set_geonameid($request->request->get('form_geonameid'));
|
||||
$user->set_gender($request->request->get('form_gender'))
|
||||
->set_firstname($request->request->get('form_firstname'))
|
||||
->set_lastname($request->request->get('form_lastname'))
|
||||
->set_address($request->request->get('form_address'))
|
||||
->set_zip($request->request->get('form_zip'))
|
||||
->set_tel($request->request->get('form_phone'))
|
||||
->set_fax($request->request->get('form_fax'))
|
||||
->set_job($request->request->get('form_job'))
|
||||
->set_company($request->request->get('form_company'))
|
||||
->set_position($request->request->get('form_activity'))
|
||||
->set_geonameid($request->request->get('form_geonameid'));
|
||||
|
||||
$demandOK = array();
|
||||
$demandOK = array();
|
||||
|
||||
if (!!$app['phraseanet.registry']->get('GV_autoregister')) {
|
||||
if (!!$app['phraseanet.registry']->get('GV_autoregister')) {
|
||||
|
||||
$template_user_id = \User_Adapter::get_usr_id_from_login($app, 'autoregister');
|
||||
$template_user_id = \User_Adapter::get_usr_id_from_login($app, 'autoregister');
|
||||
|
||||
$template_user = \User_Adapter::getInstance($template_user_id, $app);
|
||||
$template_user = \User_Adapter::getInstance($template_user_id, $app);
|
||||
|
||||
$base_ids = array();
|
||||
$base_ids = array();
|
||||
|
||||
foreach (array_keys($inscOK) as $base_id) {
|
||||
$base_ids[] = $base_id;
|
||||
}
|
||||
$user->ACL()->apply_model($template_user, $base_ids);
|
||||
foreach (array_keys($inscOK) as $base_id) {
|
||||
$base_ids[] = $base_id;
|
||||
}
|
||||
|
||||
$autoReg = $user->ACL()->get_granted_base();
|
||||
|
||||
$appbox_register = new \appbox_register($app['phraseanet.appbox']);
|
||||
|
||||
foreach ($demands as $base_id) {
|
||||
if (false === $inscOK[$base_id] || $user->ACL()->has_access_to_base($base_id)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$collection = \collection::get_from_base_id($app, $base_id);
|
||||
$appbox_register->add_request($user, $collection);
|
||||
unset($collection);
|
||||
$demandOK[$base_id] = true;
|
||||
}
|
||||
|
||||
$params = array(
|
||||
'demand' => $demandOK,
|
||||
'autoregister' => $autoReg,
|
||||
'usr_id' => $user->get_id()
|
||||
);
|
||||
|
||||
$app['events-manager']->trigger('__REGISTER_AUTOREGISTER__', $params);
|
||||
$app['events-manager']->trigger('__REGISTER_APPROVAL__', $params);
|
||||
|
||||
$user->set_mail_locked(true);
|
||||
|
||||
try {
|
||||
$expire = new \DateTime('+3 days');
|
||||
$token = \random::getUrlToken($app, \random::TYPE_PASSWORD, $user->get_id(), $expire, $user->get_email());
|
||||
|
||||
$mail = MailRequestEmailConfirmation::create($app, Receiver::fromUser($user));
|
||||
$mail->setButtonUrl($app['phraseanet.registry']->get('GV_ServerName') . "register-confirm/?code=" . $token);
|
||||
$mail->setExpiration($expire);
|
||||
|
||||
$app['notification.deliverer']->deliver($mail);
|
||||
|
||||
return $app->redirect('/login/?notice=mail-sent');
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
|
||||
return $app->redirect(sprintf('/login/?usr=%d', $user->get_id()));
|
||||
} catch (\Exception $e) {
|
||||
return $app->redirect('/login/?error=unexpected');
|
||||
$user->ACL()->apply_model($template_user, $base_ids);
|
||||
}
|
||||
|
||||
$autoReg = $user->ACL()->get_granted_base();
|
||||
|
||||
$appbox_register = new \appbox_register($app['phraseanet.appbox']);
|
||||
|
||||
foreach ($demands as $base_id) {
|
||||
if (false === $inscOK[$base_id] || $user->ACL()->has_access_to_base($base_id)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$collection = \collection::get_from_base_id($app, $base_id);
|
||||
$appbox_register->add_request($user, $collection);
|
||||
unset($collection);
|
||||
$demandOK[$base_id] = true;
|
||||
}
|
||||
|
||||
$params = array(
|
||||
'demand' => $demandOK,
|
||||
'autoregister' => $autoReg,
|
||||
'usr_id' => $user->get_id()
|
||||
);
|
||||
|
||||
$app['events-manager']->trigger('__REGISTER_AUTOREGISTER__', $params);
|
||||
$app['events-manager']->trigger('__REGISTER_APPROVAL__', $params);
|
||||
|
||||
$user->set_mail_locked(true);
|
||||
|
||||
$expire = new \DateTime('+3 days');
|
||||
$token = \random::getUrlToken($app, \random::TYPE_PASSWORD, $user->get_id(), $expire, $user->get_email());
|
||||
|
||||
$mail = MailRequestEmailConfirmation::create($app, Receiver::fromUser($user));
|
||||
$mail->setButtonUrl($app['phraseanet.registry']->get('GV_ServerName') . "register-confirm/?code=" . $token);
|
||||
$mail->setExpiration($expire);
|
||||
|
||||
$app['notification.deliverer']->deliver($mail);
|
||||
|
||||
return $app->redirect('/login/?notice=mail-sent');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -3,6 +3,7 @@
|
||||
namespace Alchemy\Phrasea\Core\Provider;
|
||||
|
||||
use Alchemy\Phrasea\Notification\Deliverer;
|
||||
use Alchemy\Phrasea\Notification\Emitter;
|
||||
use Silex\Application;
|
||||
use Silex\ServiceProviderInterface;
|
||||
|
||||
@@ -10,8 +11,24 @@ class NotificationDelivererServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
public function register(Application $app)
|
||||
{
|
||||
$app['notification.default.emitter'] = $app->share(function (Application $app) {
|
||||
return new Emitter(
|
||||
$app['phraseanet.registry']->get('GV_defaulmailsenderaddr', 'no-reply@phraseanet.com'),
|
||||
$app['phraseanet.registry']->get('GV_homeTitle', 'Phraseanet')
|
||||
);
|
||||
});
|
||||
|
||||
$app['notification.prefix'] = $app->share(function (Application $app) {
|
||||
return $app['phraseanet.registry']->get('GV_email_prefix');
|
||||
});
|
||||
|
||||
$app['notification.deliverer'] = $app->share(function($app) {
|
||||
return new Deliverer($app['mailer'], $app['phraseanet.registry'], $app['dispatcher']);
|
||||
return new Deliverer(
|
||||
$app['mailer'],
|
||||
$app['dispatcher'],
|
||||
$app['notification.default.emitter'],
|
||||
$app['notification.prefix']
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -546,12 +546,8 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
|
||||
$mailOldAddress = MailSuccessEmailUpdate::create($this->app, $oldReceiver, null, sprintf(_('You will now receive notifications at %s'), $new_email));
|
||||
$mailNewAddress = MailSuccessEmailUpdate::create($this->app, $newReceiver, null, sprintf(_('You will no longer receive notifications at %s'), $old_email));
|
||||
|
||||
try {
|
||||
$this->app['notification.deliverer']->deliver($mailOldAddress);
|
||||
$this->app['notification.deliverer']->deliver($mailNewAddress);
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
$this->app['notification.deliverer']->deliver($mailOldAddress);
|
||||
$this->app['notification.deliverer']->deliver($mailNewAddress);
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
@@ -14,6 +14,7 @@ namespace Alchemy\Phrasea\Helper\User;
|
||||
use Alchemy\Phrasea\Helper\Helper;
|
||||
use Alchemy\Phrasea\Notification\Receiver;
|
||||
use Alchemy\Phrasea\Notification\Mail\MailRequestPasswordSetup;
|
||||
use Alchemy\Phrasea\Notification\Mail\MailSuccessEmailConfirmationUnregistered;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -183,7 +184,7 @@ class Manage extends Helper
|
||||
|
||||
if (false !== $urlToken) {
|
||||
$mail = MailSuccessEmailConfirmationUnregistered::create($this->app, Receiver::fromUser($createdUser));
|
||||
$mail->setUrl($this->app['url_generator']->generate('login_forgot_password', array('token' => $urlToken), true));
|
||||
$mail->setButtonUrl($this->app['url_generator']->generate('login_forgot_password', array('token' => $urlToken), true));
|
||||
$this->app['notification.deliverer']->deliver($mail);
|
||||
}
|
||||
}
|
||||
|
@@ -50,7 +50,10 @@ class Emitter implements EmitterInterface
|
||||
public static function fromUser(\User_Adapter $user)
|
||||
{
|
||||
if (!\Swift_Validate::email($user->get_email())) {
|
||||
throw new InvalidArgumentException(sprintf('User provided does not have a valid e-mail address'));
|
||||
throw new InvalidArgumentException(sprintf(
|
||||
'User provided does not have a valid e-mail address (%s)',
|
||||
$user->get_email()
|
||||
));
|
||||
}
|
||||
|
||||
return new static($user->get_display_name(), $user->get_email());
|
||||
|
@@ -50,7 +50,10 @@ class Receiver implements ReceiverInterface
|
||||
public static function fromUser(\User_Adapter $user)
|
||||
{
|
||||
if (!\Swift_Validate::email($user->get_email())) {
|
||||
throw new InvalidArgumentException(sprintf('User provided does not have a valid e-mail address'));
|
||||
throw new InvalidArgumentException(sprintf(
|
||||
'User provided does not have a valid e-mail address (%s)',
|
||||
$user->get_email()
|
||||
));
|
||||
}
|
||||
|
||||
return new static($user->get_display_name(), $user->get_email());
|
||||
|
@@ -36,7 +36,7 @@ class PhraseanetServiceProvider implements ServiceProviderInterface
|
||||
$app['firewall'] = $app->share(function(SilexApplication $app) {
|
||||
return new Firewall($app);
|
||||
});
|
||||
|
||||
|
||||
$app['events-manager'] = $app->share(function(SilexApplication $app) {
|
||||
$events = new \eventsmanager_broker($app);
|
||||
$events->start();
|
||||
|
@@ -1463,10 +1463,15 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
|
||||
|
||||
if (!$session->hasModuleId($app_id)) {
|
||||
$module = new \Entities\SessionModule();
|
||||
|
||||
$module->setModuleId($app_id);
|
||||
$module->setSession($session);
|
||||
$session->addSessionModule($module);
|
||||
|
||||
$app['EM']->persist($module);
|
||||
$app['EM']->persist($session);
|
||||
|
||||
$app['EM']->flush();
|
||||
}
|
||||
|
||||
|
||||
|
@@ -110,6 +110,12 @@ class User_Query implements User_QueryInterface
|
||||
*/
|
||||
protected $only_templates = false;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $email_not_null = false;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var Array
|
||||
@@ -222,6 +228,10 @@ class User_Query implements User_QueryInterface
|
||||
$sql .= ' AND usr.invite=0 ';
|
||||
}
|
||||
|
||||
if ( ! $this->email_not_null) {
|
||||
$sql .= ' AND usr.usr_mail IS NOT NULL ';
|
||||
}
|
||||
|
||||
if ($this->only_templates === true) {
|
||||
$sql .= ' AND model_of = ' . $this->app['phraseanet.user']->get_id();
|
||||
} elseif ($this->include_templates === false) {
|
||||
@@ -439,6 +449,18 @@ class User_Query implements User_QueryInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param boolean $boolean
|
||||
* @return User_Query
|
||||
*/
|
||||
public function email_not_null($boolean)
|
||||
{
|
||||
$this->email_not_null = ! ! $boolean;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $rights
|
||||
|
@@ -197,17 +197,20 @@ class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract
|
||||
$body .= sprintf("%s : %s\n", _('admin::compte-utilisateur email'), $registeredUser->get_email());
|
||||
$body .= sprintf("%s/%s\n", $registeredUser->get_job(), $registeredUser->get_company());
|
||||
|
||||
$receiver = Receiver::fromUser($to);
|
||||
$mail = MailInfoSomebodyAutoregistered::create($this->app, $receiver, $body);
|
||||
|
||||
$readyToSend = false;
|
||||
try {
|
||||
$this->app['notification.deliverer']->deliver($mail);
|
||||
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
$receiver = Receiver::fromUser($to);
|
||||
$readyToSend = true;
|
||||
} catch (Exception $e) {
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
if ($readyToSend) {
|
||||
$mail = MailInfoSomebodyAutoregistered::create($this->app, $receiver, $body);
|
||||
$this->app['notification.deliverer']->deliver($mail);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -82,19 +82,24 @@ class eventsmanager_notify_bridgeuploadfail extends eventsmanager_notifyAbstract
|
||||
$mailed = false;
|
||||
|
||||
if ($this->shouldSendNotificationFor($params['usr_id'])) {
|
||||
$user = User_Adapter::getInstance($params['usr_id'], $this->app);
|
||||
|
||||
$readyToSend = false;
|
||||
try {
|
||||
$user = User_Adapter::getInstance($params['usr_id'], $this->app);
|
||||
$account = Bridge_Account::load_account($this->app, $params['account_id']);
|
||||
$readyToSend = true;
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
|
||||
if ($readyToSend) {
|
||||
$receiver = Receiver::fromUser($user);
|
||||
/** ADD MAIL TEST */
|
||||
$mail = MailInfoBridgeUploadFailed::create($this->app, $receiver);
|
||||
$mail->setAdapter($account->get_api()->get_connector()->get_name());
|
||||
$mail->setReason($params['reason']);
|
||||
$this->app['notification.deliverer']->deliver($mail);
|
||||
$mailed = true;
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -67,7 +67,10 @@ class eventsmanager_notify_feed extends eventsmanager_notifyAbstract
|
||||
|
||||
$Query = new \User_Query($this->app);
|
||||
|
||||
$Query->include_phantoms(true)->include_invite(false)->include_templates(false);
|
||||
$Query->include_phantoms(true)
|
||||
->include_invite(false)
|
||||
->include_templates(false)
|
||||
->email_not_null(true);
|
||||
|
||||
if ($entry->get_feed()->get_collection()) {
|
||||
$Query->on_base_ids(array($entry->get_feed()->get_collection()->get_base_id()));
|
||||
@@ -83,32 +86,38 @@ class eventsmanager_notify_feed extends eventsmanager_notifyAbstract
|
||||
|
||||
do {
|
||||
$results = $Query->limit($start, $perLoop)->execute()->get_results();
|
||||
|
||||
|
||||
foreach ($results as $user_to_notif) {
|
||||
/* @var $user_to_notif \User_Adapter */
|
||||
$mailed = false;
|
||||
|
||||
if ($this->shouldSendNotificationFor($user_to_notif->get_id())) {
|
||||
|
||||
$token = \random::getUrlToken(
|
||||
$this->app,
|
||||
\random::TYPE_FEED_ENTRY
|
||||
, $user_to_notif->get_id()
|
||||
, null
|
||||
, $entry->get_id()
|
||||
);
|
||||
|
||||
$url = $this->app['phraseanet.registry']->get('GV_ServerName') . 'lightbox/index.php?LOG=' . $token;
|
||||
|
||||
$readyToSend = false;
|
||||
try {
|
||||
$token = \random::getUrlToken(
|
||||
$this->app,
|
||||
\random::TYPE_FEED_ENTRY
|
||||
, $user_to_notif->get_id()
|
||||
, null
|
||||
, $entry->get_id()
|
||||
);
|
||||
|
||||
$url = $this->app['phraseanet.registry']->get('GV_ServerName') . 'lightbox/index.php?LOG=' . $token;
|
||||
|
||||
$receiver = Receiver::fromUser($user_to_notif);
|
||||
$readyToSend = true;
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
|
||||
if ($readyToSend) {
|
||||
$mail = MailInfoNewPublication::create($this->app, $receiver);
|
||||
$mail->setButtonUrl($url);
|
||||
$mail->setAuthor($entry->get_author_name());
|
||||
$mail->setTitle($entry->get_title());
|
||||
$mailed = true;
|
||||
} catch (\Exception $e) {
|
||||
|
||||
$this->app['notification.deliverer']->deliver($mail);
|
||||
$mailed = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -111,15 +111,20 @@ class eventsmanager_notify_order extends eventsmanager_notifyAbstract
|
||||
$mailed = false;
|
||||
|
||||
if ($this->shouldSendNotificationFor($user->get_id())) {
|
||||
$readyToSend = false;
|
||||
try {
|
||||
$receiver = Receiver::fromUser($user);
|
||||
$readyToSend = true;
|
||||
} catch (Exception $e) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($readyToSend) {
|
||||
$mail = MailInfoNewOrder::create($this->app, $receiver);
|
||||
$mail->setUser($orderInitiator);
|
||||
|
||||
$this->app['notification.deliverer']->deliver($mail);
|
||||
$mailed = true;
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -96,30 +96,29 @@ class eventsmanager_notify_orderdeliver extends eventsmanager_notifyAbstract
|
||||
$mailed = false;
|
||||
|
||||
if ($this->shouldSendNotificationFor($params['to'])) {
|
||||
$readyToSend = false;
|
||||
try {
|
||||
$user_from = User_Adapter::getInstance($params['from'], $this->app);
|
||||
$user_to = User_Adapter::getInstance($params['to'], $this->app);
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
$repository = $this->app['EM']->getRepository('\Entities\Basket');
|
||||
|
||||
$basket = $repository->find($params['ssel_id']);
|
||||
|
||||
$receiver = Receiver::fromUser($user_to);
|
||||
$emitter = Emitter::fromUser($user_from);
|
||||
|
||||
$repository = $this->app['EM']->getRepository('\Entities\Basket');
|
||||
$basket = $repository->find($params['ssel_id']);
|
||||
|
||||
$readyToSend = true;
|
||||
} catch (Exception $e) {
|
||||
|
||||
}
|
||||
|
||||
if ($readyToSend) {
|
||||
$mail = MailInfoOrderDelivered::create($this->app, $receiver, $emitter);
|
||||
$mail->setBasket($basket);
|
||||
$mail->setDeliverer($user_from);
|
||||
|
||||
$this->app['notification.deliverer']->deliver($mail);
|
||||
$mailed = true;
|
||||
|
||||
} catch (Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -76,17 +76,22 @@ class eventsmanager_notify_ordernotdelivered extends eventsmanager_notifyAbstrac
|
||||
$mailed = false;
|
||||
|
||||
if ($this->shouldSendNotificationFor($params['to'])) {
|
||||
|
||||
$readyToSend = false;
|
||||
|
||||
try {
|
||||
$user_from = User_Adapter::getInstance($params['from'], $this->app);
|
||||
$user_to = User_Adapter::getInstance($params['to'], $this->app);
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
$receiver = Receiver::fromUser($user_to);
|
||||
$emitter = Emitter::fromUser($user_from);
|
||||
|
||||
$readyToSend = true;
|
||||
} catch (Exception $e) {
|
||||
|
||||
}
|
||||
|
||||
if ($readyToSend) {
|
||||
$mail = MailInfoOrderCancelled::create($this->app, $receiver, $emitter);
|
||||
$mail->setQuantity($params['n']);
|
||||
$mail->setDeliverer($user_from);
|
||||
@@ -94,8 +99,6 @@ class eventsmanager_notify_ordernotdelivered extends eventsmanager_notifyAbstrac
|
||||
$this->app['notification.deliverer']->deliver($mail);
|
||||
|
||||
$mailed = true;
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -83,6 +83,8 @@ class eventsmanager_notify_push extends eventsmanager_notifyAbstract
|
||||
$mailed = false;
|
||||
|
||||
if ($this->shouldSendNotificationFor($params['to'])) {
|
||||
|
||||
$readyToSend = false;
|
||||
try {
|
||||
$repository = $this->app['EM']->getRepository('\Entities\Basket');
|
||||
$basket = $repository->find($params['ssel_id']);
|
||||
@@ -92,7 +94,12 @@ class eventsmanager_notify_push extends eventsmanager_notifyAbstract
|
||||
|
||||
$receiver = Receiver::fromUser($user_from);
|
||||
$emitter = Emitter::fromUser($user_to);
|
||||
$readyToSend = true;
|
||||
} catch (Exception $e) {
|
||||
|
||||
}
|
||||
|
||||
if ($readyToSend) {
|
||||
$mail = MailInfoPushReceived::create($this->app, $receiver, $emitter, $params['message']);
|
||||
$mail->setBasket($basket);
|
||||
$mail->setPusher($user_from);
|
||||
@@ -100,8 +107,6 @@ class eventsmanager_notify_push extends eventsmanager_notifyAbstract
|
||||
$this->app['notification.deliverer']->deliver($mail, $params['accuse']);
|
||||
|
||||
$mailed = true;
|
||||
} catch (Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -119,18 +119,22 @@ class eventsmanager_notify_register extends eventsmanager_notifyAbstract
|
||||
$mailed = false;
|
||||
|
||||
if ($this->shouldSendNotificationFor($usr_id)) {
|
||||
$readyToSend = false;
|
||||
try {
|
||||
$admin_user = User_Adapter::getInstance($usr_id, $this->app);
|
||||
|
||||
$receiver = Receiver::fromUser($admin_user);
|
||||
$readyToSend = true;
|
||||
} catch (Exception $e) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($readyToSend) {
|
||||
$mail = MailInfoUserRegistered::create($this->app, $receiver);
|
||||
$mail->setRegisteredUser($registeredUser);
|
||||
|
||||
$this->app['notification.deliverer']->deliver($mail);
|
||||
|
||||
$mailed = true;
|
||||
} catch (Exception $e) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -110,13 +110,18 @@ class eventsmanager_notify_uploadquarantine extends eventsmanager_notifyAbstract
|
||||
$mailed = false;
|
||||
|
||||
if ($this->shouldSendNotificationFor($user->get_id())) {
|
||||
$readyToSend = false;
|
||||
try {
|
||||
$receiver = Receiver::fromUser($user);
|
||||
$readyToSend = true;
|
||||
} catch (Exception $e) {
|
||||
|
||||
}
|
||||
|
||||
if ($readyToSend) {
|
||||
$mail = MailInfoRecordQuarantined::create($this->app, $receiver);
|
||||
$this->app['notification.deliverer']->deliver($mail);
|
||||
$mailed = true;
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -10,8 +10,9 @@
|
||||
*/
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
|
||||
use Alchemy\Phrasea\Notification\Mail\MailInfoValidationRequest;
|
||||
use Alchemy\Phrasea\Notification\Emitter;
|
||||
use Alchemy\Phrasea\Notification\Receiver;
|
||||
|
||||
class eventsmanager_notify_validate extends eventsmanager_notifyAbstract
|
||||
{
|
||||
@@ -89,34 +90,32 @@ class eventsmanager_notify_validate extends eventsmanager_notifyAbstract
|
||||
$mailed = false;
|
||||
|
||||
if ($this->shouldSendNotificationFor($params['to'])) {
|
||||
|
||||
$readyToSend = false;
|
||||
try {
|
||||
$user_from = User_Adapter::getInstance($params['from'], $this->app);
|
||||
$user_to = User_Adapter::getInstance($params['to'], $this->app);
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
$basket = $this->app['EM']
|
||||
->getRepository('\Entities\Basket')
|
||||
->find($params['ssel_id']);
|
||||
$title = $basket->getName();
|
||||
|
||||
$receiver = Receiver::fromUser($user_to);
|
||||
$emitter = Emitter::fromUser($user_from);
|
||||
|
||||
$readyToSend = true;
|
||||
} catch (\Exception $e) {
|
||||
$title = '';
|
||||
|
||||
}
|
||||
|
||||
$receiver = Receiver::fromUser($user_to);
|
||||
$emitter = Receiver::fromUser($user_from);
|
||||
|
||||
try {
|
||||
if ($readyToSend) {
|
||||
$mail = MailInfoValidationRequest::create($this->app, $receiver, $emitter, $params['message']);
|
||||
$mail->setButtonUrl($params['url']);
|
||||
$mail->setTitle($title);
|
||||
|
||||
$this->app['notification.deliverer']->deliver($mail, $params['accuse']);
|
||||
$mailed = true;
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -10,8 +10,9 @@
|
||||
*/
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
|
||||
use Alchemy\Phrasea\Notification\Mail\MailInfoValidationDone;
|
||||
use Alchemy\Phrasea\Notification\Emitter;
|
||||
use Alchemy\Phrasea\Notification\Receiver;
|
||||
|
||||
class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract
|
||||
{
|
||||
@@ -85,34 +86,31 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract
|
||||
$mailed = false;
|
||||
|
||||
if ($this->shouldSendNotificationFor($params['to'])) {
|
||||
$readyToSend = false;
|
||||
try {
|
||||
$user_from = User_Adapter::getInstance($params['from'], $this->app);
|
||||
$user_to = User_Adapter::getInstance($params['to'], $this->app);
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
$basket = $this->app['EM']
|
||||
->getRepository('\Entities\Basket')
|
||||
->find($params['ssel_id']);
|
||||
$title = $basket->getName();
|
||||
|
||||
$receiver = Receiver::fromUser($user_to);
|
||||
$emitter = Emitter::fromUser($user_from);
|
||||
|
||||
$readyToSend = true;
|
||||
} catch (\Exception $e) {
|
||||
$title = '';
|
||||
|
||||
}
|
||||
|
||||
$receiver = Receiver::fromUser($user_to);
|
||||
$emitter = Receiver::fromUser($user_from);
|
||||
|
||||
try {
|
||||
if ($readyToSend) {
|
||||
$mail = MailInfoValidationDone::create($this->app, $receiver, $emitter);
|
||||
$mail->setButtonUrl($params['url']);
|
||||
$mail->setTitle($title);
|
||||
|
||||
$this->app['notification.deliverer']->deliver($mail);
|
||||
$mailed = true;
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -26,8 +26,9 @@ abstract class eventsmanager_notifyAbstract extends eventsmanager_eventAbstract
|
||||
protected function get_prefs($class, $usr_id)
|
||||
{
|
||||
$user = User_Adapter::getInstance($usr_id, $this->app);
|
||||
$pref = $user->getPrefs('notification_' . $class);
|
||||
|
||||
return $user->getPrefs('notification_' . $class);
|
||||
return null !== $pref ? $pref : 1;
|
||||
}
|
||||
|
||||
protected function shouldSendNotificationFor($usr_id)
|
||||
|
@@ -471,7 +471,7 @@ class set_order extends set_abstract
|
||||
$stmt->closeCursor();
|
||||
$n ++;
|
||||
}
|
||||
|
||||
|
||||
if ($n > 0) {
|
||||
$params = array(
|
||||
'from' => $this->app['phraseanet.user']->get_id(),
|
||||
|
@@ -1651,6 +1651,13 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
|
||||
*/
|
||||
public function testFeedsContent()
|
||||
{
|
||||
self::$DI['app']['notification.deliverer'] = $this->getMockBuilder('Alchemy\Phrasea\Notification\Deliverer')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
self::$DI['app']['notification.deliverer']->expects($this->atLeastOnce())
|
||||
->method('deliver')
|
||||
->with($this->isInstanceOf('Alchemy\Phrasea\Notification\Mail\MailInfoNewPublication'), $this->equalTo(null));
|
||||
|
||||
$title = 'Yellow title';
|
||||
$subtitle = 'Trololololo !';
|
||||
@@ -1710,6 +1717,13 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
|
||||
*/
|
||||
public function testFeedEntry()
|
||||
{
|
||||
self::$DI['app']['notification.deliverer'] = $this->getMockBuilder('Alchemy\Phrasea\Notification\Deliverer')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
self::$DI['app']['notification.deliverer']->expects($this->atLeastOnce())
|
||||
->method('deliver')
|
||||
->with($this->isInstanceOf('Alchemy\Phrasea\Notification\Mail\MailInfoNewPublication'), $this->equalTo(null));
|
||||
|
||||
$title = 'Yellow title';
|
||||
$subtitle = 'Trololololo !';
|
||||
@@ -1749,6 +1763,13 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
|
||||
*/
|
||||
public function testFeedEntryNoAccess()
|
||||
{
|
||||
self::$DI['app']['notification.deliverer'] = $this->getMockBuilder('Alchemy\Phrasea\Notification\Deliverer')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
self::$DI['app']['notification.deliverer']->expects($this->atLeastOnce())
|
||||
->method('deliver')
|
||||
->with($this->isInstanceOf('Alchemy\Phrasea\Notification\Mail\MailInfoNewPublication'), $this->equalTo(null));
|
||||
|
||||
$title = 'Yellow title';
|
||||
$subtitle = 'Trololololo !';
|
||||
@@ -1786,6 +1807,14 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
|
||||
*/
|
||||
public function testFeedContent()
|
||||
{
|
||||
self::$DI['app']['notification.deliverer'] = $this->getMockBuilder('Alchemy\Phrasea\Notification\Deliverer')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
self::$DI['app']['notification.deliverer']->expects($this->atLeastOnce())
|
||||
->method('deliver')
|
||||
->with($this->isInstanceOf('Alchemy\Phrasea\Notification\Mail\MailInfoNewPublication'), $this->equalTo(null));
|
||||
|
||||
$title = 'Yellow title';
|
||||
$subtitle = 'Trololololo !';
|
||||
$entry_title = 'Superman';
|
||||
|
@@ -14,6 +14,15 @@ class ApplicationLightboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstrac
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
self::$DI['app']['notification.deliverer'] = $this->getMockBuilder('Alchemy\Phrasea\Notification\Deliverer')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
self::$DI['app']['notification.deliverer']->expects($this->atLeastOnce())
|
||||
->method('deliver')
|
||||
->with($this->isInstanceOf('Alchemy\Phrasea\Notification\Mail\MailInfoNewPublication'), $this->equalTo(null));
|
||||
|
||||
$this->feed = \Feed_Adapter::create(self::$DI['app'], self::$DI['user'], "salut", 'coucou');
|
||||
$publishers = $this->feed->get_publishers();
|
||||
$publisher = array_shift($publishers);
|
||||
@@ -316,6 +325,8 @@ class ApplicationLightboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstrac
|
||||
{
|
||||
$basket = $this->insertOneBasket();
|
||||
|
||||
$this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailInfoValidationDone');
|
||||
|
||||
$crawler = self::$DI['client']->request('POST', '/lightbox/ajax/SET_RELEASE/' . $basket->getId() . '/');
|
||||
$this->assertEquals(200, self::$DI['client']->getResponse()->getStatusCode());
|
||||
$this->assertEquals('application/json', self::$DI['client']->getResponse()->headers->get('Content-type'));
|
||||
|
@@ -54,6 +54,8 @@ class AdminDashboardTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
{
|
||||
$this->setAdmin(true);
|
||||
|
||||
$this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailTest');
|
||||
|
||||
self::$DI['client']->request('POST', '/admin/dashboard/send-mail-test/', array(
|
||||
'email' => self::$DI['user']->get_email()
|
||||
));
|
||||
|
@@ -48,6 +48,7 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
|
||||
public function testRouteRightsApply()
|
||||
{
|
||||
$this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailSuccessEmailUpdate', 2);
|
||||
|
||||
$username = uniqid('user_');
|
||||
$user = \User_Adapter::create(self::$DI['app'], $username, "test", $username . "@email.com", false);
|
||||
@@ -241,12 +242,43 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$this->assertTrue($datas->error);
|
||||
}
|
||||
|
||||
public function testRouteCreateUser()
|
||||
public function testRouteCreateUserAndValidateEmail()
|
||||
{
|
||||
$this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailRequestPasswordSetup');
|
||||
$username = uniqid('user_');
|
||||
$user = \User_Adapter::create(self::$DI['app'], $username, "test", $username . "@email.com", false);
|
||||
|
||||
self::$DI['client']->request('POST', '/admin/users/create/', array('value' => $username . "@email.com", 'template' => '0'));
|
||||
self::$DI['client']->request('POST', '/admin/users/create/', array(
|
||||
'value' => $username . "@email.com",
|
||||
'template' => '0',
|
||||
'validate_mail' => true,
|
||||
));
|
||||
|
||||
$response = self::$DI['client']->getResponse();
|
||||
|
||||
$this->assertTrue($response->isOK());
|
||||
$this->assertEquals("application/json", $response->headers->get("content-type"));
|
||||
$datas = json_decode($response->getContent());
|
||||
$this->assertTrue(is_object($datas));
|
||||
$this->assertFalse($datas->error);
|
||||
|
||||
try {
|
||||
$user = \User_Adapter::getInstance((int) $datas->data, self::$DI['app']);
|
||||
$user->delete();
|
||||
} catch (\Exception $e) {
|
||||
$this->fail("could not delete created user " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function testRouteCreateUserAndSendCredentials()
|
||||
{
|
||||
$this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailSuccessEmailConfirmationUnregistered');
|
||||
$username = uniqid('user_');
|
||||
|
||||
self::$DI['client']->request('POST', '/admin/users/create/', array(
|
||||
'value' => $username . "@email.com",
|
||||
'template' => '0',
|
||||
'send_credentials' => true,
|
||||
));
|
||||
|
||||
$response = self::$DI['client']->getResponse();
|
||||
|
||||
|
@@ -174,6 +174,23 @@ class ExportTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
unset($response, $datas);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Alchemy\Phrasea\Controller\Prod\Export::exportMail
|
||||
*/
|
||||
public function testExportMail()
|
||||
{
|
||||
$this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailRecordsExport');
|
||||
|
||||
self::$DI['client']->request('POST', '/prod/export/mail/', array(
|
||||
'lst' => self::$DI['record_1']->get_serialize_key(),
|
||||
'destmail' => 'user@example.com',
|
||||
'obj' => array('preview'),
|
||||
));
|
||||
|
||||
$response = self::$DI['client']->getResponse();
|
||||
$this->assertTrue($response->isOk());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Alchemy\Phrasea\Controller\Prod\Export::connect
|
||||
* @covers Alchemy\Phrasea\Controller\Prod\Export::call
|
||||
|
@@ -42,6 +42,13 @@ class ControllerFeedApp extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
self::$DI['app']['notification.deliverer'] = $this->getMockBuilder('Alchemy\Phrasea\Notification\Deliverer')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
self::$DI['app']['notification.deliverer']->expects($this->atLeastOnce())
|
||||
->method('deliver')
|
||||
->with($this->isInstanceOf('Alchemy\Phrasea\Notification\Mail\MailInfoNewPublication'), $this->equalTo(null));
|
||||
|
||||
$this->feed = \Feed_Adapter::create(
|
||||
self::$DI['app'], self::$DI['user'], $this->feed_title, $this->feed_subtitle
|
||||
|
@@ -72,11 +72,14 @@ class OrderTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
public function testSendOrder()
|
||||
{
|
||||
$order = $this->createOneOrder('I need this pictures');
|
||||
|
||||
$this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailInfoOrderDelivered');
|
||||
|
||||
$parameters = array();
|
||||
foreach ($order as $id => $element) {
|
||||
$parameters[] = $id;
|
||||
}
|
||||
self::$DI['client']->request('POST', '/prod/order/' . $order->get_order_id() . '/send/', $parameters);
|
||||
self::$DI['client']->request('POST', '/prod/order/' . $order->get_order_id() . '/send/', array('elements' => $parameters));
|
||||
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
|
||||
$url = parse_url(self::$DI['client']->getResponse()->headers->get('location'));
|
||||
parse_str($url['query']);
|
||||
@@ -89,11 +92,14 @@ class OrderTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
public function testSendOrderJson()
|
||||
{
|
||||
$order = $this->createOneOrder('I need this pictures');
|
||||
|
||||
$this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailInfoOrderDelivered');
|
||||
|
||||
$parameters = array();
|
||||
foreach ($order as $id => $element) {
|
||||
$parameters[] = $id;
|
||||
}
|
||||
$this->XMLHTTPRequest('POST', '/prod/order/' . $order->get_order_id() . '/send/', $parameters);
|
||||
$this->XMLHTTPRequest('POST', '/prod/order/' . $order->get_order_id() . '/send/', array('elements' => $parameters));
|
||||
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
|
||||
$response = self::$DI['client']->getResponse();
|
||||
$this->assertTrue($response->isOk());
|
||||
@@ -112,11 +118,14 @@ class OrderTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
public function testDenyOrder()
|
||||
{
|
||||
$order = $this->createOneOrder('I need this pictures');
|
||||
|
||||
$this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailInfoOrderCancelled');
|
||||
|
||||
$parameters = array();
|
||||
foreach ($order as $id => $element) {
|
||||
$parameters[] = $id;
|
||||
}
|
||||
self::$DI['client']->request('POST', '/prod/order/' . $order->get_order_id() . '/deny/', $parameters);
|
||||
self::$DI['client']->request('POST', '/prod/order/' . $order->get_order_id() . '/deny/', array('elements' => $parameters));
|
||||
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
|
||||
$url = parse_url(self::$DI['client']->getResponse()->headers->get('location'));
|
||||
parse_str($url['query']);
|
||||
@@ -129,11 +138,14 @@ class OrderTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
public function testDenyOrderJson()
|
||||
{
|
||||
$order = $this->createOneOrder('I need this pictures');
|
||||
|
||||
$this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailInfoOrderCancelled');
|
||||
|
||||
$parameters = array();
|
||||
foreach ($order as $id => $element) {
|
||||
$parameters[] = $id;
|
||||
}
|
||||
$this->XMLHTTPRequest('POST', '/prod/order/' . $order->get_order_id() . '/deny/', $parameters);
|
||||
$this->XMLHTTPRequest('POST', '/prod/order/' . $order->get_order_id() . '/deny/', array('elements' => $parameters));
|
||||
$response = self::$DI['client']->getResponse();
|
||||
$this->assertTrue($response->isOk());
|
||||
$this->assertEquals('application/json', $response->headers->get('Content-Type'));
|
||||
@@ -147,6 +159,14 @@ class OrderTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
|
||||
private function createOneOrder($usage)
|
||||
{
|
||||
self::$DI['app']['notification.deliverer'] = $this->getMockBuilder('Alchemy\Phrasea\Notification\Deliverer')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
self::$DI['app']['notification.deliverer']->expects($this->atLeastOnce())
|
||||
->method('deliver')
|
||||
->with($this->isInstanceOf('Alchemy\Phrasea\Notification\Mail\MailInfoNewOrder'), $this->equalTo(null));
|
||||
|
||||
$receveid = array(self::$DI['record_1']->get_serialize_key() => self::$DI['record_1']);
|
||||
|
||||
return \set_order::create(
|
||||
|
@@ -35,6 +35,8 @@ class ControllerPushTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
|
||||
public function testRoutePOSTsend()
|
||||
{
|
||||
$this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailInfoPushReceived', 2);
|
||||
|
||||
$route = '/prod/push/send/';
|
||||
|
||||
$records = array(
|
||||
@@ -69,6 +71,8 @@ class ControllerPushTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
|
||||
public function testRoutePOSTvalidate()
|
||||
{
|
||||
$this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailInfoValidationRequest', 3);
|
||||
|
||||
$route = '/prod/push/validate/';
|
||||
|
||||
$records = array(
|
||||
|
@@ -204,6 +204,14 @@ class RecordsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
'toto'
|
||||
);
|
||||
|
||||
self::$DI['app']['notification.deliverer'] = $this->getMockBuilder('Alchemy\Phrasea\Notification\Deliverer')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
self::$DI['app']['notification.deliverer']->expects($this->atLeastOnce())
|
||||
->method('deliver')
|
||||
->with($this->isInstanceOf('Alchemy\Phrasea\Notification\Mail\MailInfoNewPublication'), $this->equalTo(null));
|
||||
|
||||
$feedEntry = \Feed_Entry_Adapter::create(
|
||||
self::$DI['app'],
|
||||
self::$feed,
|
||||
|
@@ -72,7 +72,14 @@ class UploadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
*/
|
||||
public function testUpload()
|
||||
{
|
||||
$params = array('base_id' => self::$DI['collection']->get_base_id());
|
||||
self::$DI['app']['notification.deliverer'] = $this->getMockBuilder('Alchemy\Phrasea\Notification\Deliverer')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$params = array(
|
||||
'base_id' => self::$DI['collection']->get_base_id()
|
||||
);
|
||||
|
||||
$files = array(
|
||||
'files' => array(
|
||||
new UploadedFile(
|
||||
@@ -97,6 +104,36 @@ class UploadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Alchemy\Phrasea\Controller\Prod\Upload::upload
|
||||
* @covers Alchemy\Phrasea\Controller\Prod\Upload::getJsonResponse
|
||||
*/
|
||||
public function testUploadingTwiceTheSameRecordShouldSendToQuantantine()
|
||||
{
|
||||
$this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailInfoRecordQuarantined');
|
||||
|
||||
$params = array(
|
||||
'base_id' => self::$DI['collection']->get_base_id()
|
||||
);
|
||||
|
||||
$files = array(
|
||||
'files' => array(
|
||||
new UploadedFile(
|
||||
$this->tmpFile, 'KIKOO.JPG'
|
||||
)
|
||||
)
|
||||
);
|
||||
self::$DI['client']->request('POST', '/prod/upload/', $params, $files, array('HTTP_Accept' => 'application/json'));
|
||||
|
||||
$response = self::$DI['client']->getResponse();
|
||||
|
||||
$this->checkJsonResponse($response);
|
||||
|
||||
$datas = json_decode($response->getContent(), true);
|
||||
|
||||
$this->assertTrue($datas['success']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Alchemy\Phrasea\Controller\Prod\Upload::upload
|
||||
*/
|
||||
|
@@ -185,6 +185,8 @@ class AccountTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
*/
|
||||
public function testPostResetMailEmail()
|
||||
{
|
||||
$this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailRequestEmailUpdate');
|
||||
|
||||
$password = \random::generatePassword();
|
||||
self::$DI['app']['phraseanet.user']->set_password($password);
|
||||
self::$DI['client']->request('POST', '/account/reset-email/', array(
|
||||
@@ -311,7 +313,6 @@ class AccountTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
*/
|
||||
public function testUpdateAccount()
|
||||
{
|
||||
$register = new \appbox_register(self::$DI['app']['phraseanet.appbox']);
|
||||
$bases = $notifs = array();
|
||||
|
||||
foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) {
|
||||
@@ -360,9 +361,9 @@ class AccountTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$this->assertEquals('minet', self::$DI['app']['phraseanet.user']->get_lastname());
|
||||
|
||||
$sql = 'SELECT base_id FROM demand WHERE usr_id = :usr_id AND en_cours="1" ';
|
||||
$stmt = $this->appbox->get_connection()->prepare($sql);
|
||||
$stmt->execute(array(':usr_id' => $user->get_id()));
|
||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
$stmt = self::$DI['app']['phraseanet.appbox']->get_connection()->prepare($sql);
|
||||
$stmt->execute(array(':usr_id' => self::$DI['app']['phraseanet.user']->get_id()));
|
||||
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
|
||||
$this->assertCount(count($bases), $rs);
|
||||
|
@@ -127,6 +127,8 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
*/
|
||||
public function testRegisterConfirmMail()
|
||||
{
|
||||
$this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailSuccessEmailConfirmationRegistered');
|
||||
|
||||
self::$DI['app']->closeAccount();
|
||||
$email = $this->generateEmail();
|
||||
$appboxRegister = new \appbox_register(self::$DI['app']['phraseanet.appbox']);
|
||||
@@ -139,7 +141,7 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$response = self::$DI['client']->getResponse();
|
||||
|
||||
$this->assertTrue($response->isRedirect());
|
||||
$this->assertEquals('/login/?redirect=prod¬ice=confirm-ok-wait', $response->headers->get('location'));
|
||||
$this->assertEquals('/login/?redirect=prod¬ice=confirm-ok', $response->headers->get('location'));
|
||||
$this->assertFalse(self::$DI['user']->get_mail_locked());
|
||||
}
|
||||
|
||||
@@ -148,11 +150,15 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
*/
|
||||
public function testRegisterConfirmMailNoCollAwait()
|
||||
{
|
||||
$this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailSuccessEmailConfirmationUnregistered');
|
||||
|
||||
$user = \User_Adapter::create(self::$DI['app'], 'test'.mt_rand(), \random::generatePassword(), 'email-random'.mt_rand().'@phraseanet.com', false);
|
||||
|
||||
self::$DI['app']->closeAccount();
|
||||
$email = $this->generateEmail();
|
||||
$token = \random::getUrlToken(self::$DI['app'], \random::TYPE_EMAIL, self::$DI['user']->get_id(), null, $email);
|
||||
$token = \random::getUrlToken(self::$DI['app'], \random::TYPE_EMAIL, $user->get_id(), null, $email);
|
||||
|
||||
self::$DI['user']->set_mail_locked(true);
|
||||
$user->set_mail_locked(true);
|
||||
|
||||
$this->deleteRequest();
|
||||
|
||||
@@ -161,7 +167,8 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
|
||||
$this->assertTrue($response->isRedirect());
|
||||
|
||||
$this->assertEquals('/login/?redirect=prod¬ice=confirm-ok', $response->headers->get('location'));
|
||||
$this->assertEquals('/login/?redirect=prod¬ice=confirm-ok-wait', $response->headers->get('location'));
|
||||
$user->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -195,6 +202,8 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
*/
|
||||
public function testRenewPasswordMail()
|
||||
{
|
||||
$this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailRequestEmailConfirmation');
|
||||
|
||||
self::$DI['app']->closeAccount();
|
||||
self::$DI['client']->request('POST', '/login/forgot-password/', array('mail' => self::$DI['user']->get_email()));
|
||||
$response = self::$DI['client']->getResponse();
|
||||
@@ -562,6 +571,8 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
*/
|
||||
public function testPostRegister()
|
||||
{
|
||||
$this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailRequestEmailConfirmation');
|
||||
|
||||
self::$DI['app']->closeAccount();
|
||||
$bases = array();
|
||||
|
||||
@@ -633,6 +644,8 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
*/
|
||||
public function testSendConfirmMail()
|
||||
{
|
||||
$this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailRequestEmailConfirmation');
|
||||
|
||||
self::$DI['app']->closeAccount();
|
||||
self::$DI['client']->request('GET', '/login/send-mail-confirm/', array('usr_id' => self::$DI['user']->get_id()));
|
||||
|
||||
|
@@ -71,9 +71,93 @@ class RssFeedTest extends \PhraseanetWebTestCaseAbstract
|
||||
protected static $feed_4_public_subtitle = 'Feed 4 subtitle';
|
||||
protected $client;
|
||||
|
||||
private static $initialized = false;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
if (!self::$initialized) {
|
||||
|
||||
@unlink('/tmp/db.sqlite');
|
||||
copy(__DIR__ . '/../../../../../db-ref.sqlite', '/tmp/db.sqlite');
|
||||
|
||||
self::$DI['app']['session']->clear();
|
||||
self::$DI['app']['session']->set('usr_id', self::$DI['user']->get_id());
|
||||
|
||||
self::$feed_1_private = \Feed_Adapter::create(self::$DI['app'], self::$DI['user'], self::$feed_1_private_title, self::$feed_1_private_subtitle);
|
||||
self::$feed_1_private->set_public(false);
|
||||
self::$feed_1_private->set_icon(__DIR__ . '/../../../../../files/logocoll.gif');
|
||||
|
||||
self::$feed_2_private = \Feed_Adapter::create(self::$DI['app'], self::$DI['user'], self::$feed_2_private_title, self::$feed_2_private_subtitle);
|
||||
self::$feed_2_private->set_public(false);
|
||||
|
||||
self::$feed_3_public = \Feed_Adapter::create(self::$DI['app'], self::$DI['user'], self::$feed_3_public_title, self::$feed_3_public_subtitle);
|
||||
self::$feed_3_public->set_public(true);
|
||||
self::$feed_3_public->set_icon(__DIR__ . '/../../../../../files/logocoll.gif');
|
||||
|
||||
self::$feed_4_public = \Feed_Adapter::create(self::$DI['app'], self::$DI['user'], self::$feed_4_public_title, self::$feed_4_public_subtitle);
|
||||
self::$feed_4_public->set_public(true);
|
||||
|
||||
$publishers = self::$feed_4_public->get_publishers();
|
||||
$publisher = array_shift($publishers);
|
||||
|
||||
self::$DI['app']['notification.deliverer'] = $this->getMockBuilder('Alchemy\Phrasea\Notification\Deliverer')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
self::$DI['app']['notification.deliverer']->expects($this->atLeastOnce())
|
||||
->method('deliver')
|
||||
->with($this->isInstanceOf('Alchemy\Phrasea\Notification\Mail\MailInfoNewPublication'), $this->equalTo(null));
|
||||
|
||||
for ($i = 1; $i != 15; $i++) {
|
||||
$entry = \Feed_Entry_Adapter::create(self::$DI['app'], self::$feed_4_public, $publisher, 'titre entry', 'soustitre entry', 'Jean-Marie Biggaro', 'author@example.com');
|
||||
|
||||
$item = \Feed_Entry_Item::create(self::$DI['app']['phraseanet.appbox'], $entry, self::$DI['record_1']);
|
||||
$item = \Feed_Entry_Item::create(self::$DI['app']['phraseanet.appbox'], $entry, self::$DI['record_6']);
|
||||
$item = \Feed_Entry_Item::create(self::$DI['app']['phraseanet.appbox'], $entry, self::$DI['record_7']);
|
||||
$item = \Feed_Entry_Item::create(self::$DI['app']['phraseanet.appbox'], $entry, self::$DI['record_8']);
|
||||
$item = \Feed_Entry_Item::create(self::$DI['app']['phraseanet.appbox'], $entry, self::$DI['record_9']);
|
||||
$item = \Feed_Entry_Item::create(self::$DI['app']['phraseanet.appbox'], $entry, self::$DI['record_10']);
|
||||
$item = \Feed_Entry_Item::create(self::$DI['app']['phraseanet.appbox'], $entry, self::$DI['record_1']);
|
||||
$item = \Feed_Entry_Item::create(self::$DI['app']['phraseanet.appbox'], $entry, self::$DI['record_13']);
|
||||
$item = \Feed_Entry_Item::create(self::$DI['app']['phraseanet.appbox'], $entry, self::$DI['record_15']);
|
||||
$item = \Feed_Entry_Item::create(self::$DI['app']['phraseanet.appbox'], $entry, self::$DI['record_16']);
|
||||
$item = \Feed_Entry_Item::create(self::$DI['app']['phraseanet.appbox'], $entry, self::$DI['record_19']);
|
||||
|
||||
$entry = \Feed_Entry_Adapter::create(self::$DI['app'], self::$feed_1_private, $publisher, 'titre entry', 'soustitre entry', 'Jean-Marie Biggaro', 'author@example.com');
|
||||
|
||||
$item = \Feed_Entry_Item::create(self::$DI['app']['phraseanet.appbox'], $entry, self::$DI['record_1']);
|
||||
$item = \Feed_Entry_Item::create(self::$DI['app']['phraseanet.appbox'], $entry, self::$DI['record_6']);
|
||||
$item = \Feed_Entry_Item::create(self::$DI['app']['phraseanet.appbox'], $entry, self::$DI['record_7']);
|
||||
$item = \Feed_Entry_Item::create(self::$DI['app']['phraseanet.appbox'], $entry, self::$DI['record_8']);
|
||||
$item = \Feed_Entry_Item::create(self::$DI['app']['phraseanet.appbox'], $entry, self::$DI['record_9']);
|
||||
$item = \Feed_Entry_Item::create(self::$DI['app']['phraseanet.appbox'], $entry, self::$DI['record_10']);
|
||||
$item = \Feed_Entry_Item::create(self::$DI['app']['phraseanet.appbox'], $entry, self::$DI['record_1']);
|
||||
$item = \Feed_Entry_Item::create(self::$DI['app']['phraseanet.appbox'], $entry, self::$DI['record_13']);
|
||||
$item = \Feed_Entry_Item::create(self::$DI['app']['phraseanet.appbox'], $entry, self::$DI['record_15']);
|
||||
$item = \Feed_Entry_Item::create(self::$DI['app']['phraseanet.appbox'], $entry, self::$DI['record_16']);
|
||||
$item = \Feed_Entry_Item::create(self::$DI['app']['phraseanet.appbox'], $entry, self::$DI['record_19']);
|
||||
|
||||
self::$feed_4_entries[] = $entry;
|
||||
}
|
||||
|
||||
|
||||
self::$public_feeds = \Feed_Collection::load_public_feeds(self::$DI['app']);
|
||||
self::$private_feeds = \Feed_Collection::load_all(self::$DI['app'], self::$DI['user']);
|
||||
self::$DI['app']['session']->clear();
|
||||
|
||||
self::$initialized = true;
|
||||
}
|
||||
|
||||
self::$DI['app']['notification.deliverer'] = $this->getMockBuilder('Alchemy\Phrasea\Notification\Deliverer')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
self::$DI['app']['notification.deliverer']->expects($this->atLeastOnce())
|
||||
->method('deliver')
|
||||
->with($this->isInstanceOf('Alchemy\Phrasea\Notification\Mail\MailInfoNewPublication'), $this->equalTo(null));
|
||||
|
||||
self::$feed = \Feed_Adapter::create(self::$DI['app'], self::$DI['user'], 'title', 'subtitle');
|
||||
self::$publisher = \Feed_Publisher_Adapter::getPublisher(self::$DI['app']['phraseanet.appbox'], self::$feed, self::$DI['user']);
|
||||
self::$entry = \Feed_Entry_Adapter::create(self::$DI['app'], self::$feed, self::$publisher, 'title_entry', 'subtitle', 'hello', "test@mail.com");
|
||||
@@ -102,65 +186,6 @@ class RssFeedTest extends \PhraseanetWebTestCaseAbstract
|
||||
|
||||
$application = new Application('test');
|
||||
|
||||
@unlink('/tmp/db.sqlite');
|
||||
copy(__DIR__ . '/../../../../../db-ref.sqlite', '/tmp/db.sqlite');
|
||||
|
||||
$application['session']->clear();
|
||||
$application['session']->set('usr_id', self::$DI['user']->get_id());
|
||||
|
||||
self::$feed_1_private = \Feed_Adapter::create($application, self::$DI['user'], self::$feed_1_private_title, self::$feed_1_private_subtitle);
|
||||
self::$feed_1_private->set_public(false);
|
||||
self::$feed_1_private->set_icon(__DIR__ . '/../../../../../files/logocoll.gif');
|
||||
|
||||
self::$feed_2_private = \Feed_Adapter::create($application, self::$DI['user'], self::$feed_2_private_title, self::$feed_2_private_subtitle);
|
||||
self::$feed_2_private->set_public(false);
|
||||
|
||||
self::$feed_3_public = \Feed_Adapter::create($application, self::$DI['user'], self::$feed_3_public_title, self::$feed_3_public_subtitle);
|
||||
self::$feed_3_public->set_public(true);
|
||||
self::$feed_3_public->set_icon(__DIR__ . '/../../../../../files/logocoll.gif');
|
||||
|
||||
self::$feed_4_public = \Feed_Adapter::create($application, self::$DI['user'], self::$feed_4_public_title, self::$feed_4_public_subtitle);
|
||||
self::$feed_4_public->set_public(true);
|
||||
|
||||
$publishers = self::$feed_4_public->get_publishers();
|
||||
$publisher = array_shift($publishers);
|
||||
|
||||
for ($i = 1; $i != 15; $i++) {
|
||||
$entry = \Feed_Entry_Adapter::create($application, self::$feed_4_public, $publisher, 'titre entry', 'soustitre entry', 'Jean-Marie Biggaro', 'author@example.com');
|
||||
|
||||
$item = \Feed_Entry_Item::create($application['phraseanet.appbox'], $entry, self::$DI['record_1']);
|
||||
$item = \Feed_Entry_Item::create($application['phraseanet.appbox'], $entry, self::$DI['record_6']);
|
||||
$item = \Feed_Entry_Item::create($application['phraseanet.appbox'], $entry, self::$DI['record_7']);
|
||||
$item = \Feed_Entry_Item::create($application['phraseanet.appbox'], $entry, self::$DI['record_8']);
|
||||
$item = \Feed_Entry_Item::create($application['phraseanet.appbox'], $entry, self::$DI['record_9']);
|
||||
$item = \Feed_Entry_Item::create($application['phraseanet.appbox'], $entry, self::$DI['record_10']);
|
||||
$item = \Feed_Entry_Item::create($application['phraseanet.appbox'], $entry, self::$DI['record_1']);
|
||||
$item = \Feed_Entry_Item::create($application['phraseanet.appbox'], $entry, self::$DI['record_13']);
|
||||
$item = \Feed_Entry_Item::create($application['phraseanet.appbox'], $entry, self::$DI['record_15']);
|
||||
$item = \Feed_Entry_Item::create($application['phraseanet.appbox'], $entry, self::$DI['record_16']);
|
||||
$item = \Feed_Entry_Item::create($application['phraseanet.appbox'], $entry, self::$DI['record_19']);
|
||||
|
||||
$entry = \Feed_Entry_Adapter::create($application, self::$feed_1_private, $publisher, 'titre entry', 'soustitre entry', 'Jean-Marie Biggaro', 'author@example.com');
|
||||
|
||||
$item = \Feed_Entry_Item::create($application['phraseanet.appbox'], $entry, self::$DI['record_1']);
|
||||
$item = \Feed_Entry_Item::create($application['phraseanet.appbox'], $entry, self::$DI['record_6']);
|
||||
$item = \Feed_Entry_Item::create($application['phraseanet.appbox'], $entry, self::$DI['record_7']);
|
||||
$item = \Feed_Entry_Item::create($application['phraseanet.appbox'], $entry, self::$DI['record_8']);
|
||||
$item = \Feed_Entry_Item::create($application['phraseanet.appbox'], $entry, self::$DI['record_9']);
|
||||
$item = \Feed_Entry_Item::create($application['phraseanet.appbox'], $entry, self::$DI['record_10']);
|
||||
$item = \Feed_Entry_Item::create($application['phraseanet.appbox'], $entry, self::$DI['record_1']);
|
||||
$item = \Feed_Entry_Item::create($application['phraseanet.appbox'], $entry, self::$DI['record_13']);
|
||||
$item = \Feed_Entry_Item::create($application['phraseanet.appbox'], $entry, self::$DI['record_15']);
|
||||
$item = \Feed_Entry_Item::create($application['phraseanet.appbox'], $entry, self::$DI['record_16']);
|
||||
$item = \Feed_Entry_Item::create($application['phraseanet.appbox'], $entry, self::$DI['record_19']);
|
||||
|
||||
self::$feed_4_entries[] = $entry;
|
||||
}
|
||||
|
||||
|
||||
self::$public_feeds = \Feed_Collection::load_public_feeds($application);
|
||||
self::$private_feeds = \Feed_Collection::load_all($application, self::$DI['user']);
|
||||
$application['session']->clear();
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
|
@@ -5,12 +5,12 @@ namespace Alchemy\Tests\Phrasea\Core\Provider;
|
||||
/**
|
||||
* @covers Alchemy\Phrasea\Core\Provider\ConfigurationTesterServiceProvider
|
||||
*/
|
||||
class ConfigurationTesterServiceProvidertest extends ServiceProviderTestCase
|
||||
class NotificationDelivererServiceProvidertest extends ServiceProviderTestCase
|
||||
{
|
||||
public function provideServiceDescription()
|
||||
{
|
||||
return array(
|
||||
array('Alchemy\Phrasea\Core\Provider\ConfigurationTesterServiceProvider', 'phraseanet.configuration-tester', 'Alchemy\\Phrasea\\Setup\\ConfigurationTester'),
|
||||
array('Alchemy\Phrasea\Core\Provider\NotificationDelivererServiceProvider', 'notification.deliverer', 'Alchemy\\Phrasea\\Notification\\Deliverer'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -95,6 +95,14 @@ class Feed_Entry_AdapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
||||
|
||||
public function testSetFeed()
|
||||
{
|
||||
self::$DI['app']['notification.deliverer'] = $this->getMockBuilder('Alchemy\Phrasea\Notification\Deliverer')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
self::$DI['app']['notification.deliverer']->expects($this->atLeastOnce())
|
||||
->method('deliver')
|
||||
->with($this->isInstanceOf('Alchemy\Phrasea\Notification\Mail\MailInfoNewPublication'), $this->equalTo(null));
|
||||
|
||||
$new_feed = Feed_Adapter::create(self::$DI['app'], self::$DI['user'], self::$feed_title, self::$feed_subtitle);
|
||||
|
||||
$publisher = Feed_Publisher_Adapter::getPublisher(self::$DI['app']['phraseanet.appbox'], $new_feed, self::$DI['user']);
|
||||
|
@@ -73,6 +73,8 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
||||
|
||||
self::generateRecords($application);
|
||||
|
||||
self::$DI['user']->set_email('valid@phraseanet.com');
|
||||
|
||||
self::$updated = true;
|
||||
}
|
||||
}
|
||||
@@ -103,8 +105,9 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
||||
\PHPUnit_Framework_Error_Warning::$enabled = true;
|
||||
\PHPUnit_Framework_Error_Notice::$enabled = true;
|
||||
|
||||
$phpunit = $this;
|
||||
|
||||
self::$DI['app'] = self::$DI->share(function($DI) {
|
||||
self::$DI['app'] = self::$DI->share(function($DI) use ($phpunit) {
|
||||
$environment = 'test';
|
||||
$app = require __DIR__ . '/../../lib/Alchemy/Phrasea/Application/Root.php';
|
||||
|
||||
@@ -124,6 +127,15 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
||||
return $browser;
|
||||
}));
|
||||
|
||||
$app['notification.deliverer'] = $this->getMockBuilder('Alchemy\Phrasea\Notification\Deliverer')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$app['notification.deliverer']->expects($this->any())
|
||||
->method('deliver')
|
||||
->will($this->returnCallback(function() use ($phpunit){
|
||||
$phpunit->fail('Notification deliverer must be mocked');
|
||||
}));
|
||||
|
||||
return $app;
|
||||
});
|
||||
|
||||
@@ -873,4 +885,15 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
||||
$this->assertTrue(is_array($data));
|
||||
$this->assertFalse($data['success']);
|
||||
}
|
||||
|
||||
protected function mockNotificationDeliverer($expectedMail, $qty = 1, $receipt = null)
|
||||
{
|
||||
self::$DI['app']['notification.deliverer'] = $this->getMockBuilder('Alchemy\Phrasea\Notification\Deliverer')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
self::$DI['app']['notification.deliverer']->expects($this->exactly($qty))
|
||||
->method('deliver')
|
||||
->with($this->isInstanceOf($expectedMail), $this->equalTo($receipt));
|
||||
}
|
||||
}
|
||||
|
@@ -618,6 +618,13 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
||||
|
||||
public function testGet_publication()
|
||||
{
|
||||
self::$DI['app']['notification.deliverer'] = $this->getMockBuilder('Alchemy\Phrasea\Notification\Deliverer')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
self::$DI['app']['notification.deliverer']->expects($this->atLeastOnce())
|
||||
->method('deliver')
|
||||
->with($this->isInstanceOf('Alchemy\Phrasea\Notification\Mail\MailInfoNewPublication'), $this->equalTo(null));
|
||||
|
||||
$date = new DateTime();
|
||||
$request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
|
||||
|
@@ -63,6 +63,14 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
||||
|
||||
self::$DI['app']['phraseanet.user']->ACL()->update_rights_to_base(self::$DI['record_1']->get_base_id(), array('order_master' => true));
|
||||
|
||||
self::$DI['app']['notification.deliverer'] = $this->getMockBuilder('Alchemy\Phrasea\Notification\Deliverer')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
self::$DI['app']['notification.deliverer']->expects($this->atLeastOnce())
|
||||
->method('deliver')
|
||||
->with($this->isInstanceOf('Alchemy\Phrasea\Notification\Mail\MailInfoNewOrder'), $this->equalTo(null));
|
||||
|
||||
return \set_order::create(
|
||||
self::$DI['app'], new RecordsRequest($receveid, new ArrayCollection($receveid), $basket), self::$DI['user_alt2'], 'I need this photos', new \DateTime('+10 minutes')
|
||||
);
|
||||
|
Reference in New Issue
Block a user