Skip to content
Snippets Groups Projects

hotline #159109 : fix CVS audio tracks detection

Merged Patrick Barroca requested to merge hotline#159109_extraits_sonores_856_ko into master
Compare and Show latest version
2 files
+ 121
181
Preferences
Compare changes
Files
2
<?php
/**
* Copyright (c) 2012-2021, 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
*/
class ChiliRecordMediaDispatchTest extends AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
$this->fixture(Class_TypeDoc::class,
['id' => 3,
'label' => 'disc',
'famille_id' => Class_CodifTypeDoc::SONORE
]);
$unimarc = (new Class_NoticeUnimarc_Fluent)
->zoneWithContent('001', '12345')
->zoneWithChildren('200', ['f' => 'Loow'])
->zoneWithChildren('464', ['t' => 'Lotus out of water',
'3' => 'https://my-super-sound/lotus_out_of_water.mp3'])
->zoneWithChildren('464', ['t' => 'Milking song',
'3' => 'https://my-super-sound/milking_song.mp3'])
->zoneWithChildren('464', ['t' => 'Boisson Divine',
'3' => 'https://youtube.com/watch?v=12341513O'])
->zoneWithChildren('464', ['t' => 'Spirits From Tuva',
'3' => 'https://ma-discotheque.org/Hunn-Huur-Tu/song']);
$record = $this->fixture(Class_Notice::class,
['id' => 456,
'titre_principal' => 'Beethoven pour les petits maestros',
'unimarc' => $unimarc->render(),
'type_doc' => 3,
'clef_oeuvre' => 'BEETHOVEN',
'url_vignette' => 'big_picture_300x300.jpg',
'facettes' => 'T3 G13 M12']);
$this->_buildTemplateProfil(['id' => 72,
'template' => 'Chili']);
$web_client = $this
->mock()->beStrict()
->whenCalled('getResponse')
->with('https://www.last.fm/music/Loow/+images/')
->answers((new Class_Testing_HttpResponse)->setBody('
<html lang="fr">
<head></head>
<body>
<ul class="image-list">
<li class="image-list-item">
<a href="/music/Sh%C5%8D+Aimoto/+images/" class="image-list-link">
<img class="image-list-image"
src="https://lastfm-img2.akamaized.net/i/u/avatar170s/big_picture_300x300.jpg"
alt="None">
</a>
</li>
</ul>
</body>
</html>'));
Intonation_Library_LastFm::setWebClient($web_client);
Class_CosmoVar::setValueOf('url_services', 'https://cache-server.org');
Class_WebService_Afi::setHttpClient($this
->mock()
->whenCalled('open_url')
->answers(json_encode(['source' => 'testing',
'player' => '<iframe src="https://www.super-trailers.org/?media=18397590" style="width:500px; height:400px" frameborder="0"></iframe>'])));
$this->dispatch('/opac/noticeajax/media/id/456');
}
public function tearDown() {
Intonation_Library_LastFm::setWebClient(null);
parent::tearDown();
}
/** @test */
public function milkingSongShouldBeDisplayAsATrack() {
$this->assertXPathContentContains('//div[@class="list-group bg-transparent no_border"]//a[@data-track-url = "https://my-super-sound/milking_song.mp3"]//span[@class = "track_title"]', 'Milking song');
}
/** @test */
public function spiritsFromTuvaShouldBeDisplayAsTrack() {
$this->assertXPathContentContains('//div[@class="list-group bg-transparent no_border"]//a[@data-track-url = "https://ma-discotheque.org/Hunn-Huur-Tu/song"]//span[@class = "track_title"]', 'Spirits From Tuva');
}
/** @test */
public function lotusOutOfWaterSongShouldBeDisplayAsYoutube() {
$this->assertXPathContentContains('//div[@class="list-group bg-transparent no_border"]//a[@data-track-url = "https://my-super-sound/lotus_out_of_water.mp3"][contains(@onclick, "$(\'.audio_player\').attr(\'src\',$(this).attr(\'data-track-url\'));")]//span[@class = "track_title"][following-sibling::span[@class="track_source"][text()="CVS"]]', 'Lotus out of water');
}
/** @test */
public function playerShouldBePresent() {
$this->assertXPath('//audio');
}
/** @test */
public function trailersShouldBeInWall() {
$this->assertXPath('//div[@class="masonry-content"]//iframe[@src = "https://www.super-trailers.org/?media=18397590"]');
}
/** @test */
public function boissonDivineShouldBeInSeparateList() {
$this->assertXPathContentContains('//div[contains(@class,"youtube_tracks")]//span', 'Boisson Divine');
}
/** @test */
public function boissionDivineIframeShouldBePresent() {
$this->assertXPath('//div[contains(@class,"youtube_tracks")]//iframe[@src = "https://youtube.com/watch?v=12341513O"]');
}
}
class ChiliRecordMediaDispatchWithEmptyMessageTest extends AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
$record = $this->fixture('Class_Notice',
['id' => 456,
'titre_principal' => 'Beethoven pour les petits maestros',
'type_doc' => 1,
'clef_oeuvre' => 'BEETHOVEN',
'url_vignette' => 'big_picture_300x300.jpg',
'facettes' => 'T3 G13 M12']);
$this->_buildTemplateProfil(['id' => 72,
'template' => 'Chili']);
$this->dispatch('/opac/noticeajax/media/id/456');
}
/** @test */
public function emptyWallFirtItemShouldBePresent() {
$this->assertXPath('//div[@class="masonry-content"]//div[@class = "empty_media empty_media_first_item"]');
}
/** @test */
public function fiveEmptyMediaShouldBePresent() {
$this->assertXPathCount('//div[@class="masonry-content"]//div[contains(@class, "empty_media")]', 5);
}
}