Newer
Older
<?php
/**
* Copyright (c) 2012-2015, 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 RechercheControllerThumbnailTestCase extends AbstractControllerTestCase {
protected
$_storm_default_to_volatile = true,
$_file_system;
public function setUp() {
parent::setUp();
$this->_file_system = $this->mock();
Class_WebService_Vignette::setFileSystem($this->_file_system);

Patrick Barroca
committed
Class_Notice_Thumbnail_ProviderAbstract::setDefaultImageFactory($this->_getCoolImagick());
}
public function tearDown() {
Class_WebService_Vignette::setFileSystem(null);

Patrick Barroca
committed
Class_Notice_Thumbnail_ProviderAbstract::setDefaultImageFactory(null);
parent::tearDown();
}
protected function _getCoolImagick() {
return $this->mock()
->whenCalled('newImage')
->answers($this->mock()
->whenCalled('thumbnailImage')
->answers(true)
->whenCalled('writeImage')
->answers(true));
}
}
class RechercheControllerThumbnailCmsTest extends RechercheControllerThumbnailTestCase {
public function setUp() {
parent::setUp();
$article = $this->fixture('Class_Article',
['id' => 123,
'titre' => 'An article with img',
'contenu' => 'This article should contains an image like this <img src="/images/articles/img.png" />']);
$article->index();
$this->dispatch('recherche/vignette/id_notice/1', true);
}
/** @test */
public function responseShouldRedirectToVignetteUrl() {
$this->assertContains('/temp/vignettes_titre/ANARTICLEWITHIMG-123-----8.jpg',
$this->getResponseLocation());
}
}
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
class RechercheControllerThumbnailAlbumCmsWithImageTest
extends RechercheControllerThumbnailTestCase {
public function setUp() {
parent::setUp();
$album = $this->fixture('Class_Album',
['id' => 777,
'titre' => 'Testing Album',
'visible' => 1,
'status' => Class_Album::STATUS_VALIDATED,
'ressources' => [$this->fixture('Class_AlbumRessource',
['id' => 12,
'fichier' => '12.png'])]]);
$album->index();
$this->dispatch('recherche/vignette/id_notice/1', true);
}
/** @test */
public function shouldRedirectToGeneratedThumbnailUrl() {
$this->assertContains('/temp/vignettes_titre/TESTINGALBUM------101.jpg',
$this->getResponseLocation());
}
}
class RechercheControllerThumbnailAlbumSiteWithImageTest
extends RechercheControllerThumbnailTestCase {
public function setUp() {
parent::setUp();
$album = $this->fixture('Class_Album',
['id' => 777,
'titre' => 'Testing Album',
'visible' => 1,
'status' => Class_Album::STATUS_VALIDATED,
'ressources' => [$this->fixture('Class_AlbumRessource',
['id' => 12,
'poster' => 'linuxfr.jpg',
'url' => 'http://www.linuxfr.org',
'fichier' => '12.png'])]]);
$album->index();
$this->dispatch('recherche/vignette/id_notice/1', true);
}
/** @test */
public function shouldRedirectToGeneratedThumbnailUrl() {
$this->assertContains('/temp/vignettes_titre/TESTINGALBUM------101.jpg',
$this->getResponseLocation());
}
}