Newer
Older
<?php
/**
* Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
*
* 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).
*
* 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
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class BibNumeriqueControllerViewAlbumActionTest extends AbstractControllerTestCase {
/** @test */
public function withoutAlbumShouldRedirect() {
$this->dispatch('/opac/bib-numerique/view-album');
$this->assertRedirect();
}
/** @test */
public function withNonExistisngAlbumShouldRedirect() {
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Album')
->whenCalled('find')
->answers(null);
$this->dispatch('/opac/bib-numerique/view-album/id/999');
$this->assertRedirect();
}
}
abstract class AbstractBibNumeriqueControllerAlbumActionPremierVolumeTestCase extends AbstractControllerTestCase {
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
protected $_album;
public function setUp() {
parent::setUp();
$this->_album = $this->fixture('Class_Album',
['id' => 999,
'titre' => 'Premier volume',
'description' => "On ne peut que reconnaitre le talent de l'artiste !",
'thumbnail_width' => 200,
'thumbnail_left_page_crop_right' => 10,
'thumbnail_right_page_crop_top' => 5,
'op_hauteur_boite' => 500,
'id_origine' => 'DC23',
'pdf' => 'volume1.pdf',
'notice' => $this->fixture('Class_Notice', ['id' => 123])]);
$this->_album
->beDiaporama()
->setCategorie($this->fixture('Class_AlbumCategorie',
['id' => 2,
'libelle' => 'Les enluminures',
'parent_categorie' => $this->fixture('Class_AlbumCategorie',
['id' => 3,
'libelle' => 'La bible de souvigny'])]))
->save();
$im = new Imagick();
$im->newPseudoImage(50, 10, "gradient:red-black");
$im->setImageFormat('jpg');
$this->_album->setRessources(
[$this->fixture('Class_AlbumRessource', ['id' => 1,
'fichier' => '1.jpg',
'image' => $im,
'folio' => '1R3',
'album' => $this->_album]),
$this->fixture('Class_AlbumRessource', ['id' => 2,
'fichier' => '2.jpg',
'album' => $this->_album,
'titre' => 'Procedure de numerisation',
'link_to' => 'http://wikipedia.org/numerisation',
'description' => 'Comment numériser avec joie'])])
->save();
}
class BibNumeriqueControllerAlbumPremierVolumeTestToJSON extends AbstractBibNumeriqueControllerAlbumActionPremierVolumeTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/opac/bib-numerique/album/id/999.json', true);
$this->json = json_decode($this->_response->getBody());
}
/** @test */
function actionShouldBeJSON() {
$this->assertAction('album');
}
/** @test */
public function downloadUrlShouldBeBibNumeriquePdf999() {
$this->assertEquals('/bib-numerique/download_album/id/999.pdf', $this->json->album->download_url);
}
/** @test */
function albumIdShouldBe999() {
$this->assertEquals(999, $this->json->album->id);
}
/** @test */
function albumWidthShouldBe200() {
$this->assertEquals(200, $this->json->album->width);
}
/** @test */
function albumHeightShouldBe40() {
$this->assertEquals(40, $this->json->album->height);
}
/** @test */
function albumTitleShouldBePremierVolume() {
$this->assertEquals('Premier volume', $this->json->album->titre);
}
/** @test */
function albumDescriptionShouldBeOnNePeutQueReconnatre() {
$this->assertEquals("On ne peut que reconnaitre le talent de l'artiste !",
$this->json->album->description);
}
/** @test */
function firstRessourceIdShouldBeOne() {
$this->assertEquals(1, $this->json->album->ressources[0]->id);
}
/** @test */
function firstRessourceFolioNoShouldBeOneRThree() {
$this->assertEquals('1R3', $this->json->album->ressources[0]->foliono);
}
/** @test */
function firstRessourceThumbnailShouldPassResizeParamsOfRightPageCropTopFive() {
$this->assertContains('/bib-numerique/thumbnail/width/200/crop_top/5/crop_right/0/crop_bottom/0/crop_left/0/id/1',
$this->json->album->ressources[0]->thumbnail);
}
/** @test */
function firstRessourceNavigatorThumbnailShouldPassResizeParamsOfRightPageCropTopFiveWidth50() {
$this->assertContains(BASE_URL . '/userfiles/album/999/thumbs/media/1.jpg',
$this->json->album->ressources[0]->navigator_thumbnail);
}
/** @test */
function firstRessourceNavigatorDownloadShouldBeUrlToDownloadRessource() {
$this->assertContains('/bib-numerique/download-resource/id/1',
$this->json->album->ressources[0]->download);
}
/** @test */
function firstRessourceOriginalShouldBeOneDotJpg() {
$this->assertContains('userfiles/album/999/big/media/1.jpg',
$this->json->album->ressources[0]->original);
}
/** @test */
function secondRessourceTitreShouldBeProcedureDeNumerisation() {
$this->assertEquals('Procedure de numerisation', $this->json->album->ressources[1]->titre);
/** @test */
function secondRessourcesLinkToShouldBeWikipedia() {
$this->assertEquals('http://wikipedia.org/numerisation', $this->json->album->ressources[1]->link_to);
}
/** @test */
function secondRessourceDescriptionShouldBeCommentNumeriser() {
$this->assertEquals('Comment numériser avec joie', $this->json->album->ressources[1]->description);
}
/** @test */
function secondRessourceThumbnailShouldPassResizeParamsOfLeftPageCropRightTen() {
$this->assertContains('/bib-numerique/thumbnail/width/200/crop_top/0/crop_right/10/crop_bottom/0/crop_left/0/id/2',
$this->json->album->ressources[1]->thumbnail);
}
class BibNumeriqueControllerAlbumPremierVolumeDisplayMonopageTestToJSON extends AbstractBibNumeriqueControllerAlbumActionPremierVolumeTestCase {
Class_Album::find(999)
->setThumbnailCropTop(12)
->setThumbnailCropLeft(5)
->beMonopage();
$this->dispatch('/opac/bib-numerique/album/id/999.json', true);
$this->json = json_decode($this->_response->getBody());
}
/** @test */
public function playerShouldBeBookMonoWidget() {
$this->assertEquals('BookMonoWidget', $this->json->album->player);
}
/** @test */
function firstRessourceThumbnailShouldPassResizeParams() {
$this->assertContains('/bib-numerique/thumbnail/width/200/crop_top/12/crop_right/0/crop_bottom/0/crop_left/5/id/1',
$this->json->album->ressources[0]->thumbnail);
}
}
class BibNumeriqueControllerAlbumPremierVolumeWithPDFTestToJSON extends AbstractBibNumeriqueControllerAlbumActionPremierVolumeTestCase {
$this->dispatch('/opac/bib-numerique/album/id/999.json', true);
$this->json = json_decode($this->_response->getBody());
}
/** @test */
function secondRessourceNavigatorThumbnailShouldBeEarthLogoDotJpg() {
$this->assertContains(BASE_URL . '/public/opac/images/earth-logo.jpg',
$this->json->album->ressources[1]->navigator_thumbnail);
}
class BibNumeriqueControllerPermalinkTest extends AbstractBibNumeriqueControllerAlbumActionPremierVolumeTestCase {
/** @test */
public function permalinkNoticeWithIdOrigineShouldRdirectToRechercheNotice() {
$this->dispatch('/opac/bib-numerique/notice/ido/DC23');
$this->assertRedirectTo('/opac/recherche/viewnotice/id/123');
}
/** @test */
public function permalinkNoticeWithIdShouldRdirectToRechercheNotice() {
$this->dispatch('/opac/bib-numerique/notice/id/999');
$this->assertRedirectTo('/opac/recherche/viewnotice/id/123');
}
/** @test */
public function permalinkNoticeFolio1R3ShouldRedirectToRechercheNoticeHashPageTwo() {
$this->dispatch('/opac/bib-numerique/notice/id/999/folio/1R3');
$this->assertRedirectTo('/opac/recherche/viewnotice/id/123#/page/2');
}
/** @test */
public function permalinkNoticeWithUnknowAlbumIdShouldRedirectToIndex() {
$this->dispatch('/opac/bib-numerique/notice/id/xyz');
$this->assertRedirectTo('/opac/index');
}
/** @test */
public function permalinkAlbumWithoutNoticeShouldRedirectToIndex() {
$this->_album->setNotice(null);
$this->dispatch('/opac/bib-numerique/notice/id/999');
$this->assertRedirectTo('/opac/index');
}
}
class BibNumeriqueControllerAlbumPremierVolumeWithoutPDFTestToJSON extends AbstractBibNumeriqueControllerAlbumActionPremierVolumeTestCase {
public function setUp() {
parent::setUp();
Class_Album::getLoader()->find(999)->setPdf(null);
$this->dispatch('/opac/bib-numerique/album/id/999.json');
$this->json = json_decode($this->_response->getBody());
}
/** @test */
public function downloadUrlShouldBeNotSet() {
$this->assertEmpty($this->json->album->download_url);
}
class BibNumeriqueControllerDownloadRessourcesTest extends AbstractBibNumeriqueControllerAlbumActionPremierVolumeTestCase {
/** @test */
public function thumbnailIdOneShouldRenderThumbnail() {
$this->dispatch('/opac/bib-numerique/thumbnail/id/1');
$this->assertContains(substr(Class_AlbumRessource::getLoader()->find(1)->getImage()->getImageBlob(), 0, 100),
$this->_response->getBody());
}
}
class BibNumeriqueControllerBookletTest extends AbstractBibNumeriqueControllerAlbumActionPremierVolumeTestCase {
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
public function setUp() {
parent::setUp();
$this->dispatch('/opac/bib-numerique/booklet/id/999');
}
/** @test */
function actionShouldBeBooklet() {
$this->assertAction('booklet');
}
/** @test */
function amberShouldBeLoaded() {
$this->assertXPath('//script[contains(@src, "amber.js")]');
}
/** @test */
function AFIAmberPackageShouldBeLoaded() {
$this->assertXPathContentContains('//script', 'AFI.js', $this->_response->getBody());
}
/** @test */
function AFITestsAmberPackageShouldBeLoaded() {
$this->assertXPathContentContains('//script', 'AFI-Tests.js');
}
/** @test */
function pageShouldContainsCodeToOpenBooklet() {
$this->assertXPathContentContains('//script',
"smalltalk.BibNumAlbum._load_in_scriptsRoot_('/bib-numerique/album/id/999.json', '#booklet_999', '" . BASE_URL . "/amber/afi/souvigny/')",
$this->_response->getBody());
}
class BibNumeriqueControllerViewAlbumActionPremierVolumeTest extends AbstractBibNumeriqueControllerAlbumActionPremierVolumeTestCase {
public function setUp() {
parent::setUp();
Class_Profil::getCurrentProfil()->setSkin('original');
$this->dispatch('/opac/bib-numerique/view-album/id/999', true);
}
/** @test */
public function titreShouldBePremierVolume() {
$this->assertXPathContentContains('//div[@class="titre"]//h1', 'Premier volume');
}
/** @test */
public function categorieAnchorShouldBePresent() {
$this->assertXPathContentContains('//div[@class="breadcrum"]//a', 'Les enluminures');
}
/** @test */
public function ancestorCategorieAnchorShouldBePresent() {
$this->assertXPathContentContains('//div[@class="breadcrum"]//a', 'La bible de souvigny');
}
/** @test */
public function cycleJSShouldBePresentInScriptfirstRessourceShouldBePresent() {
$this->assertXPathContentContains('//script', "\$('div.slideshow-999 .medias').cycle");
}
/** @test */
public function hauteurBoiteShouldBeSetTo500() {
$this->assertXPathContentContains('//script', '"height":"500"');
}
/** @test */
public function viewerScriptShouldBePresent() {
$this->assertXPath('//script[contains(@src, "prettyPhoto.js")]');
}
/** @test */
public function pageBibNumShouldBeHTML5Compliant() {
$this->assertHTML5();
}
class BibNumeriqueControllerViewCategorieActionTest extends AbstractControllerTestCase {
/** @test */
public function withoutAlbumShouldRedirect() {
$this->dispatch('/opac/bib-numerique/view-categorie');
$this->assertRedirect();
}
/** @test */
public function withNonExistisngAlbumShouldRedirect() {
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_AlbumCategorie')
->whenCalled('find')
->answers(null);
$this->dispatch('/opac/bib-numerique/view-categorie/id/999');
$this->assertRedirect();
}
}
class BibNumeriqueControllerViewCategorieActionLesEnluminuresTest extends AbstractControllerTestCase {
Class_AlbumCategorie::getLoader()
->newInstanceWithId(2)
->setLibelle('Les enluminures')
->setParentCategorie(Class_AlbumCategorie::getLoader()
->newInstanceWithId(3)
->setLibelle('La bible de souvigny'))
->setAlbums(array(Class_Album::getLoader()
->newInstanceWithId(999)
->setTitre('Premier volume')
->setFichier('999.jpg')
->setDescription('On ne peut que reconnaitre le talent de l\'artiste !')));
$this->dispatch('/opac/bib-numerique/view-categorie/id/2');
}
/** @test */
public function parentAnchorShouldBePresent() {
$this->assertXPathContentContains('//div[@class="breadcrum"]//a', 'La bible de souvigny');
}
/** @test */
public function albumPremierVolumeShouldBePresent() {
$this->assertXPathContentContains('//div[@class="bibnumerique-albums"]//a', 'Premier volume');
}
/** @test */
public function thumbnailOfPremierVolumeShouldBePresent() {
$this->assertXPath('//div[@class="bibnumerique-albums"]//img[contains(@src, "album/999/thumb_999.jpg")]', $this->_response->getBody());
}
/** @test */
public function noSubcategoryShouldBePresent() {
$this->assertNotXPath('//div[@class="bibnumerique-categories"]');
}
}
abstract class BibNumeriqueControllerBibleDeSouvignyTestCase extends AbstractControllerTestCase {
public function setUp() {
parent::setUp();
Class_AlbumCategorie::getLoader()
->newInstanceWithId(3)
->setLibelle('La bible de souvigny')
->setAlbums(array())
->setSousCategories(array(Class_AlbumCategorie::getLoader()
->newInstanceWithId(2)
->setLibelle('Les enluminures')));
}
class BibNumeriqueControllerViewCategorieActionLaBibleDeSouvignyTest extends BibNumeriqueControllerBibleDeSouvignyTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/opac/bib-numerique/view-categorie/id/3');
}
/** @test */
public function noParentAnchorShouldBePresent() {
$this->assertNotXPath('//div[@class="breadcrum"]//a');
}
/** @test */
public function noAlbumShouldBePresent() {
$this->assertNotXPath('//div[@class="albums"]');
}
/** @test */
public function subcategoryAnchorShouldBePresent() {
$this->assertXPathContentContains('//div[@class="bibnumerique-categories"]//a', 'Les enluminures');
}
abstract class BibNumeriqueControllerAlbumMultiMediasTestCase extends AbstractControllerTestCase {
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
protected $_xpath;
public function setUp() {
parent::setUp();
$this->_xpath = new Storm_Test_XPathXML();
$album = Class_Album::newInstanceWithId(999)
->beDiaporama()
->setTitre('Plein de medias')
->setSousTitre('Pour tester')
->setAuteur('Suzanne Collins')
->setEditeur('Gallimard')
->setAnnee(2001)
->setNoticeId(500)
->setIdOrigine("A888")
->setCote('50')
->setDateMaj('2012-02-17 10:00:00')
->setDescription('<p>pour passer la soirée</p>')
->setNotes(['305$a' => 'XXe siècle',
'200$b' => 'Parchemin',
'316$a' => 'Reliure restaurée en 1980 par la BN.'])
->setIdLang('lat')
->setDroits('CC-BY-SA')
->setRessources([Class_AlbumRessource::newInstanceWithId(2)
->setFichier('mimi_jolie.mp3')
->setTitre('Emilie jolie')
->setOrdre(1)
->setPoster('mimi_jolie.png'),
Class_AlbumRessource::newInstanceWithId(4)
->setFichier('dark_night.mp4')
->setTitre('Batman Dark Knight')
->setPoster('batman.jpg')
->setOrdre(2)
->setDescription('Une nouvelle aventure du justicier noir'),
Class_AlbumRessource::newInstanceWithId(5)
->setUrl('http://progressive.totaleclips.com.edgesuite.net/107/e107950_227.mp4')
->setTitre('Hunger Games')
->setOrdre(3)
->setPoster('hunger.jpg'),
Class_AlbumRessource::newInstanceWithId(6)
->setFichier('Monsieur l\'escargot.mp3')
->setTitre('Monsieur l\'escargot')
->setOrdre(4)
->setPoster('l\'escargot.jpg'),
Class_AlbumRessource::newInstanceWithId(7)
->setUrl('https://vimeo.com/43395780')
->setTitre('Vimeo')
->setOrdre(5)
->setPoster('vimeo.jpg'),
Class_AlbumRessource::newInstanceWithId(8)
->setFichier('moonchild.mpeg')
->setTitre('Iron Maiden: "Moonchild" live')
->setOrdre(6)
->setPoster('moonchild.jpg'),
Class_AlbumRessource::newInstanceWithId(9)
->setFichier('the_prophecy.mp3')
->setOrdre(7)]);
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_AlbumCategorie')
->whenCalled('findAllBy')
->answers([])
->whenCalled('findAllBy')
->with(['parent_id' => 0])
->answers([ Class_AlbumCategorie::newInstanceWithId('33')
->setAlbums([$album])
->setLibelle('Comics')]);
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Album')
->whenCalled('findAll')
->answers([$album])
->whenCalled('findAllBy')
->with(['cat_id'=>'33'])
->answers([$album]);
}
class BibNumeriqueControllerAlbumMultiMediasXSPFTest extends BibNumeriqueControllerAlbumMultiMediasTestCase {
public function setUp() {
parent::setUp();
$this->_xpath->registerNameSpace('xspf', 'http://xspf.org/ns/0/');
$this->dispatch('/opac/bib-numerique/album-xspf-playlist/id/999.xspf', true);
}
/** @test */
public function headerShouldContainsContentTypeXspf() {
$this->assertHeaderContains('Content-Type', 'application/xspf+xml');
}
/** @test */
public function headerShouldContainsContentDispositionAttachment() {
$this->assertHeaderContains('Content-Disposition', 'attachment');
}
/** @test */
public function xmlVersionShouldOneDotZero() {
$this->_xpath->assertXmlVersion($this->_response->getBody(), "1.0");
}
/** @test */
public function xmlEncodingShouldBeUtf8() {
$this->_xpath->assertXmlEncoding($this->_response->getBody(), "UTF-8");
}
/** @test */
public function firstTrackTitleShouldBeMimiJolie() {
$this->_xpath->assertXPathContentContains($this->_response->getBody(),
'//xspf:playlist/xspf:trackList/xspf:track/xspf:title',
'Emilie jolie');
}
/** @test */
public function firstTrackImageShouldBeMimiJolieDotPng() {
$this->_xpath->assertXPathContentContains($this->_response->getBody(),
'//xspf:playlist/xspf:trackList/xspf:track/xspf:image',
'http://localhost' . BASE_URL . '/userfiles/album/999/thumbs/media/mimi_jolie.png');
}
/** @test */
public function firstTrackLocationShouldBeMimiJolieDotMp3() {
$this->_xpath->assertXPathContentContains($this->_response->getBody(),
'//xspf:playlist/xspf:trackList/xspf:track/xspf:location',
'http://localhost' . BASE_URL . '/bib-numerique/play-ressource/id/6.mp3');
}
/** @test */
public function secondTrackTitleShouldBeBatmanDarkKnight() {
$this->_xpath->assertXPathContentContains($this->_response->getBody(),
'//xspf:playlist/xspf:trackList/xspf:track/xspf:title',
'Batman Dark Knight');
}
/** @test */
public function thirdTrackLocationShouldBeTotaleClipsDotCom() {
$this->_xpath->assertXPathContentContains($this->_response->getBody(),
'//xspf:playlist/xspf:trackList/xspf:track/xspf:location',
'http://localhost' . BASE_URL . '/bib-numerique/play-ressource/id/5.mp4');
}
/** @test */
public function fourthTrackLocationShouldBeUrlEncoded() {
$this->_xpath->assertXPathContentContains($this->_response->getBody(),
'//xspf:playlist/xspf:trackList/xspf:track/xspf:location',
'play-ressource/id/2.mp3');
}
/** @test */
public function seventhTrackTitleShouldBeTheProphecy() {
$this->_xpath->assertXPathContentContains($this->_response->getBody(),
'//xspf:playlist/xspf:trackList/xspf:track/xspf:title',
'The prophecy');
}
/** @test */
public function vimeoTrackLocationShouldBeOriginalUrl() {
$this->_xpath->assertXPathContentContains($this->_response->getBody(),
'//xspf:playlist/xspf:trackList/xspf:track/xspf:location',
'https://vimeo.com/43395780');
}
}
class BibNumeriqueControllerAlbumMultiMediasRSSTest extends BibNumeriqueControllerAlbumMultiMediasTestCase {
$this->_xpath->registerNameSpace('itunes', 'http://www.itunes.com/dtds/podcast-1.0.dtd');
$this->dispatch('/opac/bib-numerique/album-rss-feed/id/999.xml', true);
}
/** @test */
public function xmlVersionShouldOneDotZero() {
$this->_xpath->assertXmlVersion($this->_response->getBody(), "1.0");
}
/** @test */
public function xmlEncodingShouldBeUtf8() {
$this->_xpath->assertXmlEncoding($this->_response->getBody(), "utf-8");
}
/** @test */
public function headerShouldContainsContentTypeRss() {
$this->assertHeaderContains('Content-Type', 'application/rss+xml');
}
/** @test */
public function titleShouldBePleinDeMedias() {
$this->_xpath->assertXPathContentContains($this->_response->getBody(),
'//channel/title',
'Plein de medias');
}
/** @test */
public function itunesImageShouldBeNoticeThumbnail() {
$this->_xpath->assertXPath($this->_response->getBody(),
'//channel/itunes:image[@href="http://localhost'.BASE_URL.'/bib-numerique/notice-thumbnail/ido/A888"]');
}
/** @test */
public function descriptionShouldBePourPasserLaSoiree() {
$this->_xpath->assertXPathContentContains($this->_response->getBody(),
'//channel/description',
'<p>pour passer la soirée</p>');
}
/** @test */
public function itunesSummaryShouldBePourPasserLaSoiree() {
$this->_xpath->assertXPathContentContains($this->_response->getBody(),
'//channel/itunes:summary',
'<p>pour passer la soirée</p>');
}
/** @test */
public function linkShouldBeBibNumeriqueNoticeIdoA888() {
$this->_xpath->assertXPathContentContains($this->_response->getBody(),
'//channel/link',
'http://localhost'.BASE_URL.'/bib-numerique/notice/ido/A888');
}
/** @test */
public function pubDateShouldBeFri17Feb2012() {
$this->_xpath->assertXPathContentContains($this->_response->getBody(),
'//channel/pubDate',
'Fri, 17 Feb 2012');
}
/** @test */
public function firstItemTitleShouldBeEmilieJolie() {
$this->_xpath->assertXPathContentContains($this->_response->getBody(),
'//channel/item[1]/title',
'Emilie jolie');
}
/** @test */
public function firstItemLinkShouldBeMediaMimiJolieMp3() {
$this->_xpath->assertXPathContentContains($this->_response->getBody(),
'//channel/item[1]/link',
'http://localhost'.BASE_URL.'/bib-numerique/play-ressource/id/2.mp3');
}
/** @test */
public function firstItemEnclosureShouldBeMediaMimiJolieMp3() {
$this->_xpath->assertXPath($this->_response->getBody(),
'//channel/item[1]/enclosure[@url="http://localhost'.BASE_URL.'/bib-numerique/play-ressource/id/2.mp3"][@type="audio/mpeg"]');
}
/** @test */
public function firstItemITunesOrderShouldBeOne() {
$this->_xpath->assertXPathContentContains($this->_response->getBody(),
'//channel/item[1]/itunes:order',
'1');
}
/** @test */
public function firstItemGUIDShouldBeMediaMimiJolieMp3() {
$this->_xpath->assertXPathContentContains($this->_response->getBody(),
'//channel/item[1]/guid',
'http://localhost'.BASE_URL.'/bib-numerique/play-ressource/id/2.mp3');
}
/** @test */
public function firstItemItunesImageShouldBeMimiJolie() {
$this->_xpath->assertXPath($this->_response->getBody(),
'//channel/item[1]/itunes:image[@href="http://localhost'.BASE_URL.'/userfiles/album/999/thumbs/media/mimi_jolie.png"]');
}
/** @test */
public function secondItemTitleShouldBeDarkKnight() {
$this->_xpath->assertXPathContentContains($this->_response->getBody(),
'//channel/item[2]/title',
'Batman Dark Knight');
}
/** @test */
public function secondItemDescriptionShouldBeAventureJusticierNoir() {
$this->_xpath->assertXPathContentContains($this->_response->getBody(),
'//channel/item[2]/description',
'Une nouvelle aventure du justicier noir');
}
/** @test */
public function firstItemITunesOrderShouldBeTwo() {
$this->_xpath->assertXPathContentContains($this->_response->getBody(),
'//channel/item[2]/itunes:order',
'2');
}
/** @test */
public function seventhItemTitleShouldBeTheProphecy() {
$this->_xpath->assertXPathContentContains($this->_response->getBody(),
'//channel/item[7]/title',
'The prophecy');
}
class BibNumeriqueControllerPlayRessourceTest extends BibNumeriqueControllerAlbumMultiMediasTestCase {
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
protected $_web_analytics_client;
public function setUp() {
parent::setUp();
$this->_web_analytics_client = Storm_Test_ObjectWrapper::mock()
->whenCalled('trackEvent')
->answers(true);
ZendAfi_Controller_Action_Helper_TrackEvent::setDefaultWebAnalyticsClient($this->_web_analytics_client);
}
/** @test */
public function forRessourceFiveShouldRedirectToTotaleClipsDotCom() {
$this->dispatch('/opac/bib-numerique/play-ressource/id/5.mp3', true);
$this->assertRedirectTo('http://progressive.totaleclips.com.edgesuite.net/107/e107950_227.mp4');
return $this->_web_analytics_client;
}
/**
* @test
* @depends forRessourceFiveShouldRedirectToTotaleClipsDotCom
*/
public function forRessourceFiveAnalyticsTrackerShouldHaveReceivedPlayEvent($client) {
$this->assertEquals(['bib-numerique',
'lecture', '"titre: Hunger Games","album: Plein de medias","auteur: Suzanne Collins","editeur: Gallimard","publication: 2001","piste: 3","droits: CC-BY-SA","source: http://localhost'.BASE_URL.'/bib-numerique/notice/id/5.mp3/ido/A888/folio/5"',
5],
$client->getAttributesForLastCallOn('trackEvent'));
}
/** @test */
public function forRessourceSixShouldRedirectMonsieurEscargot() {
$this->dispatch('/opac/bib-numerique/play-ressource/id/6.mp3', true);
$this->assertRedirectTo('http://localhost'.BASE_URL.'/userfiles/album/999/big/media/Monsieur%20l%27escargot.mp3');
}
/**
* @test
*/
public function forRessourceMoonchildAnalyticsTrackerShouldEscapeQuotes() {
$this->dispatch('/opac/bib-numerique/play-ressource/id/8.mp3', true);
$this->assertEquals(['bib-numerique',
'lecture',
'"titre: Iron Maiden: \"Moonchild\" live","album: Plein de medias","auteur: Suzanne Collins","editeur: Gallimard","publication: 2001","piste: 6","droits: CC-BY-SA","source: http://localhost'.BASE_URL.'/bib-numerique/notice/id/8.mp3/ido/A888/folio/moonchild"',
8],
$this->_web_analytics_client->getAttributesForLastCallOn('trackEvent'));
}

llaffont
committed
class BibNumeriqueControllerFullScreenEpubTest extends BibNumeriqueControllerAlbumMultiMediasTestCase {
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
protected
$_path_epub_temp;
public function setUp() {
parent::setUp();
$fixtures_epub_path = realpath(dirname(__FILE__)).'/../../../../fixtures/lesson.epub';
$album_epub_path = USERFILESPATH.'/album/999/big/media/lesson.epub';
$epub_content = file_get_contents($fixtures_epub_path);
$this->_path_epub_temp = PATH_TEMP.'epubimport'.md5($album_epub_path).'.epub';
$file_writer = Storm_Test_ObjectWrapper::mock()
->whenCalled('fileExists')
->with($album_epub_path)
->answers(true)
->whenCalled('getContents')
->with($album_epub_path)
->answers($epub_content)
->whenCalled('putContents')
->with($this->_path_epub_temp,
$epub_content)
->willDo(
function($path, $content) use ($epub_content) {
return file_put_contents($this->_path_epub_temp, $epub_content);
})
->beStrict();
ZendAfi_View_Helper_MonocleReaderServerSide::setFileWriter($file_writer);
Class_EpubReader::setFileWriter($file_writer);
Class_Album::newInstanceWithId(999)
->beEPUB()
->setTitre('Informatique')
->setRessources([Class_AlbumRessource::newInstanceWithId(4)
->setFichier('lesson.epub')
->setTitre('Pragmatic Programmers')
->setVignette('pragprog.jpg')]);
$this->dispatch('/opac/bib-numerique/full-screen/id/4', true);
}
public function tearDown() {
unlink($this->_path_epub_temp);
ZendAfi_View_Helper_MonocleReaderServerSide::setFileWriter(null);
Class_EpubReader::setFileWriter(null);
parent::tearDown();
}
/** @test */