Skip to content
Snippets Groups Projects
Commit 943d62ec authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

dev #59717 : widget versionning tests start

parent 10490b98
Branches
Tags
3 merge requests!2334Master,!2191Dev#59717 versionning des configurations de boites,!2185Dev#59717 versionning des configurations de boites
Pipeline #1317 passed with stage
in 11 minutes and 44 seconds
......@@ -173,7 +173,7 @@ class VersionningArticleVersionTest extends VersionningAdminTestCase {
/** @test */
public function titleShouldBeVersionDu20Mars2017() {
public function titleShouldBeVersionOfArticleAnArticle() {
$this->assertXPathContentContains('//h1', 'Version de l\'article : "An article"');
}
......@@ -467,7 +467,7 @@ class VersionningArticelEditPostTest extends VersionningAdminTestCase {
/** @test */
public function versionFileNameShouldContainsProfileIdAndUserIdAndDatetime() {
public function versionFileNameShouldContainsArticleIdAndUserIdAndDatetime() {
$this->assertContains('/temp/versions/article/27/2017-03-20_112408_666.json',
$this->_file_name);
}
......
<?php
/**
* Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
abstract class VersionningWidgetTestCase extends Admin_AbstractControllerTestCase {
protected
$_storm_default_to_volatile = true,
$_file_system;
public function setUp() {
parent::setUp();
$this->_file_system = $this->mock();
Class_Version_FilePersistence::setFileSystem($this->_file_system);
Class_Version_FilePersistence::setTimeSource(new TimeSourceForTest('2017-04-25 11:24:08'));
Class_Folder_Manager::setFileSystem($this->_file_system);
$profil = $this->fixture('Class_Profil', ['id' => 1]);
$profil->updateModuleConfigAccueil(3, ['type_module' => 'NEWS',
'division' => 1])
->assertSave();
}
public function tearDown() {
Class_Version_FilePersistence::setFileSystem(null);
Class_Version_FilePersistence::setTimeSource(null);
Class_Folder_Manager::setFileSystem(null);
parent::tearDown();
}
}
class VersionningWidgetEditPostTest extends VersionningWidgetTestCase {
protected
$_file_name,
$_file_content,
$_file_directory,
$_posted_data;
public function setUp() {
parent::setUp();
$this->_file_system
->whenCalled('file_exists')->answers(false)
->whenCalled('is_readable')->answers(false)
->whenCalled('mkdir')
->willDo(function($name, $mode, $parents)
{
$this->_file_directory = $name;
return true;
})
->whenCalled('file_put_contents')
->willDo(function($name, $content)
{
$this->_file_name = $name;
$this->_file_content = $content;
});
$this->_posted_data = ["titre" => "L'agenda du bouquet",
"id_categorie" => "18-93-88",
"id_items" => "",
"display_cat_select" => "0",
"nb_events" => "9",
"display_calendar" => "0",
"mode-affichage" => "wall",
"styles_reload" => "0",
"display_event_info" => "none",
"event_filter" => "none",
"enabled_filters" => "",
"display_full_page" => "0",
"display_mode" => "Summary",
"display_order" => "DebutPublicationDesc",
"boite" => "",
"rss_avis" => "0"];
$this->postDispatch('/admin/widget/edit-widget/id/3/id_profil/1/render/popup',
$this->_posted_data);
}
/** @test */
public function versionFileDirectoryShouldBeCreated() {
$this->assertContains('/temp/versions/widget/1_3',
$this->_file_directory);
}
/** @test */
public function versionFileNameShouldContainsProfileWidgetAndUserIdAndDateTime() {
$this->assertContains('/temp/versions/widget/1_3/2017-04-25_112408_666.json',
$this->_file_name);
}
/** @test */
public function versionFileContentShouldContainsPostedData() {
$this->assertEquals($this->_posted_data,
json_decode($this->_file_content, true));
}
}
class VersionningWidgetAccueilWithVersionsTest extends VersionningWidgetTestCase {
public function setUp() {
parent::setUp();
$this->_file_system
->whenCalled('is_readable')->answers(true)
->whenCalled('scandir')
->answers(['.', '..',
'2017-03-20_112408_33.json',
'2017-03-19_103345_32.json',
'2017-03-19_102612_32.json',]);
$this->onLoaderOfModel('Class_Article')
->whenCalled('getArticlesByPreferences')
->answers([]);
$this->dispatch('/opac/index/index/id_profil/1', true);
}
/** @test */
public function versionLinkOfWidgetShouldBePresent() {
$this->assertXPath('//a[contains(@href, "/admin/widget/version/id_profil/1/id/3")][@data-popup="true"]',
$this->_response->getBody());
}
}
class VersionningWidgetVersionTest extends VersionningWidgetTestCase {
protected $_dialog = [];
public function setUp() {
parent::setUp();
$this->fixture('Class_Users',
['id' => 33,
'login' => 'Albator',
'password' => 'arc4di4']);
$this->_file_system
->whenCalled('is_readable')->answers(true)
->whenCalled('scandir')
->answers(['.', '..',
'2017-03-20_112408_33.json',
'2017-03-19_103345_32.json',
'2017-03-19_102612_32.json',])
->whenCalled('file_get_contents')
->answers(json_encode(["titre" => "L'agenda du bouquet",
"id_categorie" => "18-93-88",
"id_items" => "",
"display_cat_select" => "0",
"nb_events" => "9",
"display_calendar" => "0",
"mode-affichage" => "wall",
"styles_reload" => "0",
"display_event_info" => "none",
"event_filter" => "none",
"enabled_filters" => "",
"display_full_page" => "0",
"display_mode" => "Summary",
"display_order" => "DebutPublicationDesc",
"boite" => "",
"rss_avis" => "0"]));
;
$this->dispatch('/admin/widget/version/id_profil/1/id/3/render/popup', true);
$this->_dialog = json_decode($this->_response->getBody(), true);
}
/** @test */
public function titleShouldBeVersionOfWidgetNews() {
$this->assertEquals('Version de : "Boite articles"', $this->_dialog['title']);
}
/** @test */
public function versionColumnShouldContainsDateAndUser() {
$this->assertContains('20 mars 2017 11:24:08, Albator',
$this->_dialog['content']);
}
/** @test */
public function widgetTitleShouldBeMarkedAsModified() {
$this->assertContains('<tr class="modified"><td class="droite"><label for="titre">Titre de la boite',
$this->_dialog['content'],
$this->_dialog['content']);
}
}
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment