Fix tests and templates

This commit is contained in:
Romain Neutron
2012-07-19 13:27:39 +02:00
parent e9623eaaee
commit 3169171952
15 changed files with 84 additions and 99 deletions

View File

@@ -169,7 +169,6 @@ class Description implements ControllerProviderInterface
$field->set_name($request->get('name_' . $id)) $field->set_name($request->get('name_' . $id))
->set_thumbtitle($request->get('thumbtitle_' . $id)) ->set_thumbtitle($request->get('thumbtitle_' . $id))
->set_tag(\databox_field::loadClassFromTagName($request->get('src_' . $id))) ->set_tag(\databox_field::loadClassFromTagName($request->get('src_' . $id)))
->set_multi($request->get('multi_' . $id))
->set_business($request->get('business_' . $id)) ->set_business($request->get('business_' . $id))
->set_indexable($request->get('indexable_' . $id)) ->set_indexable($request->get('indexable_' . $id))
->set_required($request->get('required_' . $id)) ->set_required($request->get('required_' . $id))

View File

@@ -13,7 +13,6 @@ namespace Alchemy\Phrasea\Controller\Admin;
use Alchemy\Phrasea\Application as PhraseaApplication; use Alchemy\Phrasea\Application as PhraseaApplication;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Silex\Application; use Silex\Application;
use Silex\ControllerProviderInterface; use Silex\ControllerProviderInterface;
@@ -94,7 +93,7 @@ class Publications implements ControllerProviderInterface
'message' => '', 'message' => '',
); );
$feed = new \Feed_Adapter($appbox, $id); $feed = new \Feed_Adapter($app['phraseanet.appbox'], $id);
$user = $app['phraseanet.core']->getAuthenticatedUser(); $user = $app['phraseanet.core']->getAuthenticatedUser();
@@ -154,19 +153,15 @@ class Publications implements ControllerProviderInterface
$datas['message'] = _('Unable to add file to Phraseanet'); $datas['message'] = _('Unable to add file to Phraseanet');
} }
return new Response( return $app->json($datas);
$app['phraseanet.core']['Serializer']->serialize($datas, 'json'),
200,
array('Content-type' => 'application/json')
);
})->assert('id', '\d+'); })->assert('id', '\d+');
$controllers->post('/feed/{id}/addpublisher/', function($id) use ($app, $appbox) { $controllers->post('/feed/{id}/addpublisher/', function(PhraseaApplication $app, $id) {
$error = ''; $error = '';
try { try {
$request = $app['request']; $request = $app['request'];
$user = \User_Adapter::getInstance($request->get('usr_id'), $appbox); $user = \User_Adapter::getInstance($request->get('usr_id'), $app['phraseanet.appbox']);
$feed = new \Feed_Adapter($appbox, $id); $feed = new \Feed_Adapter($app['phraseanet.appbox'], $id);
$feed->add_publisher($user); $feed->add_publisher($user);
} catch (\Exception $e) { } catch (\Exception $e) {
$error = $e->getMessage(); $error = $e->getMessage();
@@ -175,12 +170,12 @@ class Publications implements ControllerProviderInterface
return $app->redirect('/admin/publications/feed/' . $id . '/?err=' . $error); return $app->redirect('/admin/publications/feed/' . $id . '/?err=' . $error);
})->assert('id', '\d+'); })->assert('id', '\d+');
$controllers->post('/feed/{id}/removepublisher/', function($id) use ($app, $appbox) { $controllers->post('/feed/{id}/removepublisher/', function(PhraseaApplication $app, $id) {
try { try {
$request = $app['request']; $request = $app['request'];
$feed = new \Feed_Adapter($appbox, $id); $feed = new \Feed_Adapter($app['phraseanet.appbox'], $id);
$publisher = new \Feed_Publisher_Adapter($appbox, $request->get('publisher_id')); $publisher = new \Feed_Publisher_Adapter($app['phraseanet.appbox'], $request->get('publisher_id'));
$user = $publisher->get_user(); $user = $publisher->get_user();
if ($feed->is_publisher($user) === true && $feed->is_owner($user) === false) if ($feed->is_publisher($user) === true && $feed->is_owner($user) === false)
$publisher->delete(); $publisher->delete();
@@ -191,8 +186,8 @@ class Publications implements ControllerProviderInterface
return $app->redirect('/admin/publications/feed/' . $id . '/?err=' . $error); return $app->redirect('/admin/publications/feed/' . $id . '/?err=' . $error);
})->assert('id', '\d+'); })->assert('id', '\d+');
$controllers->post('/feed/{id}/delete/', function($id) use ($app, $appbox) { $controllers->post('/feed/{id}/delete/', function(PhraseaApplication $app, $id) {
$feed = new \Feed_Adapter($appbox, $id); $feed = new \Feed_Adapter($app['phraseanet.appbox'], $id);
$feed->delete(); $feed->delete();
return $app->redirect('/admin/publications/list/'); return $app->redirect('/admin/publications/list/');

View File

@@ -15,8 +15,8 @@ use Silex\Application;
use Silex\ControllerProviderInterface; use Silex\ControllerProviderInterface;
use Silex\ControllerCollection; use Silex\ControllerCollection;
use Alchemy\Phrasea\Helper\Record as RecordHelper; use Alchemy\Phrasea\Helper\Record as RecordHelper;
use Symfony\Component\HttpFoundation\Request, use Symfony\Component\HttpFoundation\Request;
Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
/** /**
* *

View File

@@ -479,8 +479,7 @@ class Account implements ControllerProviderInterface
public function accountAuthorizedApps(Application $app, Request $request) public function accountAuthorizedApps(Application $app, Request $request)
{ {
return $app['phraseanet.core']['Twig']->render('account/authorized_apps.html.twig', array( return $app['phraseanet.core']['Twig']->render('account/authorized_apps.html.twig', array(
"apps" => \API_OAuth2_Application::load_app_by_user(\appbox::get_instance($app['phraseanet.core']), $user), "apps" => \API_OAuth2_Application::load_app_by_user(\appbox::get_instance($app['phraseanet.core']), $app['phraseanet.core']->getAuthenticatedUser()),
'user' => $app['phraseanet.core']->getAuthenticatedUser()
)); ));
} }

View File

@@ -268,7 +268,7 @@ class Developers implements ControllerProviderInterface
$error = true; $error = true;
} }
return new JsonResponse(array('success' => ! $error, 'token' => $accessToken)); return new JsonResponse(array('success' => ! $error, 'token' => $accessToken));
} }
/** /**

View File

@@ -30,10 +30,10 @@ class Login implements ControllerProviderInterface
$controllers->get('/', $this->call('login')) $controllers->get('/', $this->call('login'))
->before(function() use ($app) { ->before(function() use ($app) {
return $app['phraseanet.core']['Firewall']->requireNotAuthenticated($app); return $app['phraseanet.core']['Firewall']->requireNotAuthenticated($app);
}); });
@@ -386,10 +386,10 @@ class Login implements ControllerProviderInterface
$appRedirect = $request->get("app"); $appRedirect = $request->get("app");
// try { // try {
$session = $app['phraseanet.appbox']->get_session(); $session = $app['phraseanet.appbox']->get_session();
$session->logout(); $session->logout();
$session->remove_cookies(); $session->remove_cookies();
// } catch (\Exception $e) { // } catch (\Exception $e) {
// return $app->redirect("/" . ($appRedirect ? $appRedirect : 'prod')); // return $app->redirect("/" . ($appRedirect ? $appRedirect : 'prod'));
// } // }
@@ -397,7 +397,6 @@ class Login implements ControllerProviderInterface
return $app->redirect("/login/?logged_out=user" . ($appRedirect ? sprintf("&redirect=/%s", $appRedirect) : "")); return $app->redirect("/login/?logged_out=user" . ($appRedirect ? sprintf("&redirect=/%s", $appRedirect) : ""));
} }
public function login(Application $app, Request $request) public function login(Application $app, Request $request)
{ {
$appbox = $app['phraseanet.appbox']; $appbox = $app['phraseanet.appbox'];
@@ -503,17 +502,16 @@ class Login implements ControllerProviderInterface
$twig = $core->getTwig(); $twig = $core->getTwig();
return $twig->render('login/index.twig', array( return $twig->render('login/index.twig', array(
'module_name' => _('Accueil'), 'module_name' => _('Accueil'),
'notice' => $notice, 'notice' => $notice,
'warning' => $warning, 'warning' => $warning,
'redirect' => $request->get('redirect'), 'redirect' => $request->get('redirect'),
'logged_out' => $request->get('logged_out'), 'logged_out' => $request->get('logged_out'),
'captcha_system' => $captchaSys, 'captcha_system' => $captchaSys,
'login' => new \login(), 'login' => new \login(),
'feeds' => $feeds, 'feeds' => $feeds,
'display_layout' => $registry->get('GV_home_publi') 'display_layout' => $registry->get('GV_home_publi')
)); ));
} }
/** /**

View File

@@ -43,13 +43,13 @@ class Upgrader implements ControllerProviderInterface
); );
}); });
$controllers->get('/status/', function() use ($app) { $controllers->get('/status/', function(Application $app) {
require_once __DIR__ . '/../../../../bootstrap.php'; require_once __DIR__ . '/../../../../bootstrap.php';
return $app->json(\Setup_Upgrade::get_status()); return $app->json(\Setup_Upgrade::get_status());
}); });
$controllers->post('/execute/', function() use ($app) { $controllers->post('/execute/', function(Application $app) {
require_once __DIR__ . '/../../../../bootstrap.php'; require_once __DIR__ . '/../../../../bootstrap.php';
set_time_limit(0); set_time_limit(0);
session_write_close(); session_write_close();
@@ -62,7 +62,7 @@ class Upgrader implements ControllerProviderInterface
/** /**
* @todo Show recomandation instead of redirect * @todo Show recomandation instead of redirect
*/ */
return new $app->redirect('/'); return $app->redirect('/');
}); });
return $controllers; return $controllers;

View File

@@ -27,23 +27,21 @@ class PathFileTest implements ControllerProviderInterface
{ {
$controllers = $app['controllers_factory']; $controllers = $app['controllers_factory'];
$controllers->get('/path/', function( Request $request) { $controllers->get('/path/', function(Application $app, Request $request) {
$path = $request->get('path');
return $app->json(array( return $app->json(array(
'exists' => file_exists($path) 'exists' => file_exists($request->get('path'))
, 'file' => is_file($path) , 'file' => is_file($request->get('path'))
, 'dir' => is_dir($path) , 'dir' => is_dir($request->get('path'))
, 'readable' => is_readable($path) , 'readable' => is_readable($request->get('path'))
, 'writeable' => is_writable($path) , 'writeable' => is_writable($request->get('path'))
, 'executable' => is_executable($path) , 'executable' => is_executable($request->get('path'))
)); ));
}); });
$controllers->get('/url/', function( Request $request) { $controllers->get('/url/', function(Application $app, Request $request) {
$url = $request->get('url');
return $app->json(array('code' => \http_query::getHttpCodeFromUrl($url))); return $app->json(array('code' => \http_query::getHttpCodeFromUrl($request->get('url'))));
}); });
return $controllers; return $controllers;

View File

@@ -38,10 +38,10 @@
{% endif %} {% endif %}
</td> </td>
<td> <td>
{{ row['created_on'] |getDate }} {{ row['created_on'] |formatDate }}
</td> </td>
<td> <td>
{{ row['lastaccess'] |getDate }} {{ row['lastaccess'] |formatDate }}
</td> </td>
<td> <td>
{{ row['ip'] }} {{ row['ip'] }}

View File

@@ -67,7 +67,7 @@
<a href="/admin/publications/feed/{{ feed.get_id() }}/">{{ feed.get_title() }}</a> <a href="/admin/publications/feed/{{ feed.get_id() }}/">{{ feed.get_title() }}</a>
</td> </td>
<td style="text-align: center;"> <td style="text-align: center;">
{{ feed.get_created_on()|formatdate }} {{ feed.get_created_on()|formatDate }}
</td> </td>
<td style="text-align: center;"> <td style="text-align: center;">
{% if feed.get_collection() != null %} {% if feed.get_collection() != null %}

View File

@@ -128,7 +128,7 @@
{{usr.get_applied_template()}} {{usr.get_applied_template()}}
</td> </td>
<td> <td>
{{usr.get_creation_date()|getDate}} {{usr.get_creation_date()|formatDate}}
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}

View File

@@ -45,7 +45,7 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
*/ */
public function testListElement() public function testListElement()
{ {
$originalEm = $this->app['Core']['EM']; $originalEm = $this->app['phraseanet.core']['EM'];
$fileLazaret = $this->getMock('Entities\LazaretFile', array('getRecordsToSubstitute', 'getSession', 'getCollection'), array(), '', false); $fileLazaret = $this->getMock('Entities\LazaretFile', array('getRecordsToSubstitute', 'getSession', 'getCollection'), array(), '', false);
@@ -81,13 +81,13 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$route = '/lazaret/'; $route = '/lazaret/';
$this->app['Core']['EM'] = $em; $this->app['phraseanet.core']['EM'] = $em;
$crawler = $this->client->request( $crawler = $this->client->request(
'GET', $route 'GET', $route
); );
$this->app['Core']['EM'] = $originalEm; $this->app['phraseanet.core']['EM'] = $originalEm;
$this->assertResponseOk($this->client->getResponse()); $this->assertResponseOk($this->client->getResponse());
@@ -101,7 +101,7 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
*/ */
public function testGetElement() public function testGetElement()
{ {
$originalEm = $this->app['Core']['EM']; $originalEm = $this->app['phraseanet.core']['EM'];
$em = $this->getMock('Doctrine\ORM\EntityManager', array('find'), array(), '', false); $em = $this->getMock('Doctrine\ORM\EntityManager', array('find'), array(), '', false);
@@ -114,11 +114,11 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
->with($this->EqualTo('Entities\LazaretFile'), $this->EqualTo($id)) ->with($this->EqualTo('Entities\LazaretFile'), $this->EqualTo($id))
->will($this->returnValue($lazaretFile)); ->will($this->returnValue($lazaretFile));
$this->app['Core']['EM'] = $em; $this->app['phraseanet.core']['EM'] = $em;
$this->client->request('GET', '/lazaret/' . $id . '/'); $this->client->request('GET', '/lazaret/' . $id . '/');
$this->app['Core']['EM'] = $originalEm; $this->app['phraseanet.core']['EM'] = $originalEm;
$response = $this->client->getResponse(); $response = $this->client->getResponse();
@@ -145,7 +145,7 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
*/ */
public function testGetElementException() public function testGetElementException()
{ {
$originalEm = $this->app['Core']['EM']; $originalEm = $this->app['phraseanet.core']['EM'];
$em = $this->getMock('Doctrine\ORM\EntityManager', array('find'), array(), '', false); $em = $this->getMock('Doctrine\ORM\EntityManager', array('find'), array(), '', false);
@@ -156,11 +156,11 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
->with($this->EqualTo('Entities\LazaretFile'), $this->EqualTo($id)) ->with($this->EqualTo('Entities\LazaretFile'), $this->EqualTo($id))
->will($this->returnValue(null)); ->will($this->returnValue(null));
$this->app['Core']['EM'] = $em; $this->app['phraseanet.core']['EM'] = $em;
$this->client->request('GET', '/lazaret/' . $id . '/'); $this->client->request('GET', '/lazaret/' . $id . '/');
$this->app['Core']['EM'] = $originalEm; $this->app['phraseanet.core']['EM'] = $originalEm;
$response = $this->client->getResponse(); $response = $this->client->getResponse();
@@ -175,15 +175,15 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
*/ */
public function testAddElement() public function testAddElement()
{ {
$originalEm = $this->app['Core']['EM']; $originalEm = $this->app['phraseanet.core']['EM'];
//mock Doctrine\ORM\EntityManager //mock Doctrine\ORM\EntityManager
$em = $this->getMock('Doctrine\ORM\EntityManager', array(), array(), '', false); $em = $this->getMock('Doctrine\ORM\EntityManager', array(), array(), '', false);
$lazaretFile = $this->getOneLazaretFile(); $lazaretFile = $this->getOneLazaretFile();
$lazaretFileName = $this->app['Core']->getRegistry()->get('GV_RootPath') . 'tmp/lazaret/' . $lazaretFile->getFilename(); $lazaretFileName = $this->app['phraseanet.core']->getRegistry()->get('GV_RootPath') . 'tmp/lazaret/' . $lazaretFile->getFilename();
$lazaretThumbFileName = $this->app['Core']->getRegistry()->get('GV_RootPath') . 'tmp/lazaret/' . $lazaretFile->getThumbFilename(); $lazaretThumbFileName = $this->app['phraseanet.core']->getRegistry()->get('GV_RootPath') . 'tmp/lazaret/' . $lazaretFile->getThumbFilename();
copy(__DIR__ . '/../../../../testfiles/cestlafete.jpg', $lazaretFileName); copy(__DIR__ . '/../../../../testfiles/cestlafete.jpg', $lazaretFileName);
copy(__DIR__ . '/../../../../testfiles/cestlafete.jpg', $lazaretThumbFileName); copy(__DIR__ . '/../../../../testfiles/cestlafete.jpg', $lazaretThumbFileName);
@@ -233,7 +233,7 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$em->expects($this->once()) $em->expects($this->once())
->method('flush'); ->method('flush');
$this->app['Core']['EM'] = $em; $this->app['phraseanet.core']['EM'] = $em;
$this->client->request('POST', '/lazaret/' . $id . '/force-add/', array( $this->client->request('POST', '/lazaret/' . $id . '/force-add/', array(
'bas_id' => $lazaretFile->getBaseId(), 'bas_id' => $lazaretFile->getBaseId(),
@@ -241,7 +241,7 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
'attributes' => array(1, 2, 3, 4) //Check only the four first attributes 'attributes' => array(1, 2, 3, 4) //Check only the four first attributes
)); ));
$this->app['Core']['EM'] = $originalEm; $this->app['phraseanet.core']['EM'] = $originalEm;
$response = $this->client->getResponse(); $response = $this->client->getResponse();
$this->assertResponseOk($response); $this->assertResponseOk($response);
@@ -257,7 +257,7 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
*/ */
public function testAddElementBadRequestException() public function testAddElementBadRequestException()
{ {
$originalEm = $this->app['Core']['EM']; $originalEm = $this->app['phraseanet.core']['EM'];
//mock Doctrine\ORM\EntityManager //mock Doctrine\ORM\EntityManager
$em = $this->getMock('Doctrine\ORM\EntityManager', array(), array(), '', false); $em = $this->getMock('Doctrine\ORM\EntityManager', array(), array(), '', false);
@@ -272,7 +272,7 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
->with($this->EqualTo('Entities\LazaretFile'), $this->EqualTo($id)) ->with($this->EqualTo('Entities\LazaretFile'), $this->EqualTo($id))
->will($this->returnValue($lazaretFile)); ->will($this->returnValue($lazaretFile));
$this->app['Core']['EM'] = $em; $this->app['phraseanet.core']['EM'] = $em;
//Ommit base_id mandatory param //Ommit base_id mandatory param
$this->client->request('POST', '/lazaret/' . $id . '/force-add/', array( $this->client->request('POST', '/lazaret/' . $id . '/force-add/', array(
@@ -280,7 +280,7 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
'attributes' => array(1, 2, 3, 4) //Check only the four first attributes 'attributes' => array(1, 2, 3, 4) //Check only the four first attributes
)); ));
$this->app['Core']['EM'] = $originalEm; $this->app['phraseanet.core']['EM'] = $originalEm;
$response = $this->client->getResponse(); $response = $this->client->getResponse();
@@ -295,7 +295,7 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
*/ */
public function testAddElementException() public function testAddElementException()
{ {
$originalEm = $this->app['Core']['EM']; $originalEm = $this->app['phraseanet.core']['EM'];
$this->client->request('POST', '/lazaret/99999/force-add/', array( $this->client->request('POST', '/lazaret/99999/force-add/', array(
'bas_id' => 1, 'bas_id' => 1,
@@ -303,7 +303,7 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
'attributes' => array(1, 2, 3, 4) //Check only the four first attributes 'attributes' => array(1, 2, 3, 4) //Check only the four first attributes
)); ));
$this->app['Core']['EM'] = $originalEm; $this->app['phraseanet.core']['EM'] = $originalEm;
$response = $this->client->getResponse(); $response = $this->client->getResponse();
@@ -358,7 +358,7 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
*/ */
public function testAcceptElement() public function testAcceptElement()
{ {
$originalEm = $this->app['Core']['EM']; $originalEm = $this->app['phraseanet.core']['EM'];
//mock Doctrine\ORM\EntityManager //mock Doctrine\ORM\EntityManager
$em = $this->getMock('Doctrine\ORM\EntityManager', array(), array(), '', false); $em = $this->getMock('Doctrine\ORM\EntityManager', array(), array(), '', false);
@@ -423,13 +423,13 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$em->expects($this->once()) $em->expects($this->once())
->method('flush'); ->method('flush');
$this->app['Core']['EM'] = $em; $this->app['phraseanet.core']['EM'] = $em;
$this->client->request('POST', '/lazaret/' . $id . '/accept/', array( $this->client->request('POST', '/lazaret/' . $id . '/accept/', array(
'record_id' => self::$records['record_1']->get_record_id() 'record_id' => self::$records['record_1']->get_record_id()
)); ));
$this->app['Core']['EM'] = $originalEm; $this->app['phraseanet.core']['EM'] = $originalEm;
$response = $this->client->getResponse(); $response = $this->client->getResponse();
$content = json_decode($response->getContent()); $content = json_decode($response->getContent());
@@ -445,7 +445,7 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
*/ */
public function testAcceptElementNoRecordException() public function testAcceptElementNoRecordException()
{ {
$originalEm = $this->app['Core']['EM']; $originalEm = $this->app['phraseanet.core']['EM'];
//mock Doctrine\ORM\EntityManager //mock Doctrine\ORM\EntityManager
$em = $this->getMock('Doctrine\ORM\EntityManager', array(), array(), '', false); $em = $this->getMock('Doctrine\ORM\EntityManager', array(), array(), '', false);
@@ -470,13 +470,13 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$id = 1; $id = 1;
$this->app['Core']['EM'] = $em; $this->app['phraseanet.core']['EM'] = $em;
$this->client->request('POST', '/lazaret/' . $id . '/accept/', array( $this->client->request('POST', '/lazaret/' . $id . '/accept/', array(
'record_id' => self::$records['record_1']->get_record_id() 'record_id' => self::$records['record_1']->get_record_id()
)); ));
$this->app['Core']['EM'] = $originalEm; $this->app['phraseanet.core']['EM'] = $originalEm;
$response = $this->client->getResponse(); $response = $this->client->getResponse();
@@ -506,7 +506,7 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
*/ */
public function testAcceptElementBadRequestException() public function testAcceptElementBadRequestException()
{ {
$originalEm = $this->app['Core']['EM']; $originalEm = $this->app['phraseanet.core']['EM'];
//mock Doctrine\ORM\EntityManager //mock Doctrine\ORM\EntityManager
$em = $this->getMock('Doctrine\ORM\EntityManager', array(), array(), '', false); $em = $this->getMock('Doctrine\ORM\EntityManager', array(), array(), '', false);
@@ -521,12 +521,12 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
->with($this->EqualTo('Entities\LazaretFile'), $this->EqualTo($id)) ->with($this->EqualTo('Entities\LazaretFile'), $this->EqualTo($id))
->will($this->returnValue($lazaretFile)); ->will($this->returnValue($lazaretFile));
$this->app['Core']['EM'] = $em; $this->app['phraseanet.core']['EM'] = $em;
//Ommit record_id mandatory param //Ommit record_id mandatory param
$this->client->request('POST', '/lazaret/' . $id . '/accept/'); $this->client->request('POST', '/lazaret/' . $id . '/accept/');
$this->app['Core']['EM'] = $originalEm; $this->app['phraseanet.core']['EM'] = $originalEm;
$response = $this->client->getResponse(); $response = $this->client->getResponse();
@@ -541,7 +541,7 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
*/ */
public function testThumbnailElement() public function testThumbnailElement()
{ {
$originalEm = $this->app['Core']['EM']; $originalEm = $this->app['phraseanet.core']['EM'];
//mock Doctrine\ORM\EntityManager //mock Doctrine\ORM\EntityManager
$em = $this->getMock('Doctrine\ORM\EntityManager', array(), array(), '', false); $em = $this->getMock('Doctrine\ORM\EntityManager', array(), array(), '', false);
@@ -566,11 +566,11 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
->with($this->EqualTo('Entities\LazaretFile'), $this->EqualTo($id)) ->with($this->EqualTo('Entities\LazaretFile'), $this->EqualTo($id))
->will($this->returnValue($lazaretFile)); ->will($this->returnValue($lazaretFile));
$this->app['Core']['EM'] = $em; $this->app['phraseanet.core']['EM'] = $em;
$this->client->request('GET', '/lazaret/' . $id . '/thumbnail/'); $this->client->request('GET', '/lazaret/' . $id . '/thumbnail/');
$this->app['Core']['EM'] = $originalEm; $this->app['phraseanet.core']['EM'] = $originalEm;
$response = $this->client->getResponse(); $response = $this->client->getResponse();

View File

@@ -9,10 +9,10 @@ class ControllerUsrListsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function createApplication() public function createApplication()
{ {
$app = require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Prod.php'; $app = require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Prod.php';
$app['debug'] = true; $app['debug'] = true;
unset($app['exception_handler']); unset($app['exception_handler']);
return $app; return $app;
} }
@@ -115,7 +115,7 @@ class ControllerUsrListsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->client->request('GET', $route, array(), array(), array("HTTP_CONTENT_TYPE" => "application/json", "HTTP_ACCEPT" => "application/json")); $this->client->request('GET', $route, array(), array(), array("HTTP_CONTENT_TYPE" => "application/json", "HTTP_ACCEPT" => "application/json"));
$response = $this->client->getResponse(); $response = $this->client->getResponse();
var_dump($response->getContent());
$this->assertEquals(200, $response->getStatusCode()); $this->assertEquals(200, $response->getStatusCode());
$this->assertEquals('UTF-8', $response->getCharset()); $this->assertEquals('UTF-8', $response->getCharset());

View File

@@ -2,15 +2,12 @@
namespace Alchemy\Phrasea\Application; namespace Alchemy\Phrasea\Application;
use Symfony\Component\HttpFoundation\Response; use Alchemy\Phrasea\Application as PhraseaApplication;
use Symfony\Component\HttpFoundation\Request;
use Alchemy\Phrasea\Controller\Setup as Controller; use Alchemy\Phrasea\Controller\Setup as Controller;
use Alchemy\Phrasea\Controller\Utils as ControllerUtils; use Alchemy\Phrasea\Controller\Utils as ControllerUtils;
return call_user_func(function() { return call_user_func(function() {
$app = new \Silex\Application(); $app = new PhraseaApplication();
$app['phraseanet.core'] = \bootstrap::getCore();
$app['install'] = true; $app['install'] = true;

View File

@@ -2,13 +2,12 @@
namespace Alchemy\Phrasea\Application; namespace Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Application as PhraseaApplication;
use Alchemy\Phrasea\Controller\Setup as Controller; use Alchemy\Phrasea\Controller\Setup as Controller;
use Alchemy\Phrasea\Controller\Utils as ControllerUtils; use Alchemy\Phrasea\Controller\Utils as ControllerUtils;
return call_user_func(function() { return call_user_func(function() {
$app = new \Silex\Application(); $app = new PhraseaApplication();
$app['phraseanet.core'] = \bootstrap::getCore();
$app['upgrade'] = true; $app['upgrade'] = true;