Refactor ExportTest

This commit is contained in:
Benoît Burnichon
2016-02-26 15:04:02 +01:00
parent 37bcd1d909
commit 04131a3479

View File

@@ -1,6 +1,7 @@
<?php <?php
namespace Alchemy\Tests\Phrasea\Controller\Prod; namespace Alchemy\Tests\Phrasea\Controller\Prod;
use Alchemy\Phrasea\Model\Entities\User;
/** /**
* @group functional * @group functional
@@ -130,22 +131,28 @@ class ExportTest extends \PhraseanetAuthenticatedWebTestCase
*/ */
public function testExportFtp() public function testExportFtp()
{ {
if (!self::$DI['app']['conf']->get(['registry', 'ftp', 'ftp-enabled'])) { $app = $this->getApplication();
self::$DI['app']['conf']->set(['registry', 'ftp', 'ftp-enabled'], true);
if (!$app['conf']->get(['registry', 'ftp', 'ftp-enabled'])) {
$app['conf']->set(['registry', 'ftp', 'ftp-enabled'], true);
self::$GV_activeFTP = true; self::$GV_activeFTP = true;
} }
/** @var User $user */
$user = self::$DI['user'];
//inserted rows from this function are deleted in tearDownAfterClass //inserted rows from this function are deleted in tearDownAfterClass
self::$DI['client']->request('POST', '/prod/export/ftp/', [ $this->getClient()->request('POST', '/prod/export/ftp/', [
'lst' => self::$DI['record_1']->get_serialize_key(), 'lst' => $this->getRecord1()->get_serialize_key(),
'user_dest' => self::$DI['user']->getId(), 'user_dest' => $user->getId(),
'address' => 'local.phrasea.test', 'address' => 'local.phrasea.test',
'login' => self::$DI['user']->getEmail(), 'login' => $user->getEmail(),
'dest_folder' => '/home/test/', 'dest_folder' => '/home/test/',
'prefix_folder' => 'test2/', 'prefix_folder' => 'test2/',
'obj' => ['preview'] 'obj' => ['preview']
]); ]);
$response = self::$DI['client']->getResponse(); $response = $this->getClient()->getResponse();
$this->assertTrue($response->isOk()); $this->assertTrue($response->isOk());
$datas = (array) json_decode($response->getContent()); $datas = (array) json_decode($response->getContent());
$this->assertArrayHasKey('success', $datas); $this->assertArrayHasKey('success', $datas);
@@ -161,13 +168,13 @@ class ExportTest extends \PhraseanetAuthenticatedWebTestCase
{ {
$this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailRecordsExport'); $this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailRecordsExport');
self::$DI['client']->request('POST', '/prod/export/mail/', [ $this->getClient()->request('POST', '/prod/export/mail/', [
'lst' => self::$DI['record_1']->get_serialize_key(), 'lst' => $this->getRecord1()->get_serialize_key(),
'destmail' => 'user@example.com', 'destmail' => 'user@example.com',
'obj' => ['preview'], 'obj' => ['preview'],
]); ]);
$response = self::$DI['client']->getResponse(); $response = $this->getClient()->getResponse();
$this->assertTrue($response->isOk()); $this->assertTrue($response->isOk());
} }
@@ -177,8 +184,8 @@ class ExportTest extends \PhraseanetAuthenticatedWebTestCase
*/ */
public function testRequireAuthentication() public function testRequireAuthentication()
{ {
$this->logout(self::$DI['app']); $this->logout($this->getApplication());
self::$DI['client']->request('POST', '/prod/export/multi-export/'); $this->getClient()->request('POST', '/prod/export/multi-export/');
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); $this->assertTrue($this->getClient()->getResponse()->isRedirect());
} }
} }