|
@@ -7,6 +7,7 @@ use Muzich\CoreBundle\Tests\lib\Security\Context as SecurityContextTest;
|
7
|
7
|
use Muzich\CoreBundle\Security\Context as SecurityContext;
|
8
|
8
|
use Muzich\CoreBundle\Tests\lib\Security\ContextTestCases;
|
9
|
9
|
use Muzich\CoreBundle\lib\Collection\ElementCollectionManager;
|
|
10
|
+use Muzich\CoreBundle\Entity\Playlist;
|
10
|
11
|
|
11
|
12
|
class PlaylistControllerTest extends FunctionalTest
|
12
|
13
|
{
|
|
@@ -156,12 +157,22 @@ class PlaylistControllerTest extends FunctionalTest
|
156
|
157
|
}
|
157
|
158
|
}
|
158
|
159
|
|
159
|
|
- protected function checkPlaylistElements($playlist, $elements)
|
|
160
|
+ protected function checkPlaylistElements(Playlist $playlist, $elements, $exists = true, $check_count = true)
|
160
|
161
|
{
|
161
|
|
- $this->assertEquals(count($elements), $this->crawler->filter('li.playlist_element')->count());
|
|
162
|
+ $this->goToPage($this->generateUrl('playlist', array(
|
|
163
|
+ 'playlist_id' => $playlist->getId(),
|
|
164
|
+ 'user_slug' => $playlist->getOwner()->getSlug()
|
|
165
|
+ )));
|
|
166
|
+
|
|
167
|
+ if ($check_count)
|
|
168
|
+ $this->assertEquals(count($elements), $this->crawler->filter('li.playlist_element')->count());
|
|
169
|
+
|
162
|
170
|
foreach ($elements as $element)
|
163
|
171
|
{
|
164
|
|
- $this->exist('a[data-id="'.$element->getId().'"]');
|
|
172
|
+ if ($exists)
|
|
173
|
+ $this->exist('a[data-id="'.$element->getId().'"]');
|
|
174
|
+ if (!$exists)
|
|
175
|
+ $this->notExist('a[data-id="'.$element->getId().'"]');
|
165
|
176
|
}
|
166
|
177
|
}
|
167
|
178
|
|
|
@@ -517,4 +528,51 @@ class PlaylistControllerTest extends FunctionalTest
|
517
|
528
|
$this->assertTrue(!is_null($playlist_in_database));
|
518
|
529
|
}
|
519
|
530
|
|
|
531
|
+ public function testAddPrivateLinks()
|
|
532
|
+ {
|
|
533
|
+ $this->init();
|
|
534
|
+ $this->initReadContextData();
|
|
535
|
+ $this->connectUser('bux', 'toor');
|
|
536
|
+
|
|
537
|
+ $this->goToPage($this->generateUrl('playlist', array('user_slug' => $this->users['bux']->getSlug(), 'playlist_id' => $this->playlists['bux_1_pub']->getId())));
|
|
538
|
+ $this->exist('div.private_links form');
|
|
539
|
+ $this->exist('a.open_playlist_private_links');
|
|
540
|
+
|
|
541
|
+ $this->addSomePrivateLinks($this->playlists['bux_1_pub'], $private_links = array(
|
|
542
|
+ 'https://soundcloud.com/st-tetik/read-only-memories-g-noush',
|
|
543
|
+ 'https://soundcloud.com/triby/triby-extrait-next-liveset',
|
|
544
|
+ 'http://blog.bux.fr'
|
|
545
|
+ ));
|
|
546
|
+ $elements = $this->checkElementExistanceAndPresenceInPlaylistWithUrls($private_links, $this->playlists['bux_1_pub']);
|
|
547
|
+
|
|
548
|
+ $this->checkPlaylistElements($this->playlists['bux_1_pub'], $elements, true, false);
|
|
549
|
+
|
|
550
|
+ $this->disconnectUser();
|
|
551
|
+ $this->connectUser('paul', 'toor');
|
|
552
|
+
|
|
553
|
+ $this->checkPlaylistElements($this->playlists['bux_1_pub'], $elements, false, false);
|
|
554
|
+ }
|
|
555
|
+
|
|
556
|
+ protected function addSomePrivateLinks(Playlist $playlist, $links)
|
|
557
|
+ {
|
|
558
|
+ $this->tests_cases->playlistAddPrivateLinks($playlist, $links);
|
|
559
|
+ $this->isResponseRedirection();
|
|
560
|
+ }
|
|
561
|
+
|
|
562
|
+ protected function checkElementExistanceAndPresenceInPlaylistWithUrls($urls_to_check, Playlist $playlist)
|
|
563
|
+ {
|
|
564
|
+ $elements = array();
|
|
565
|
+ foreach ($urls_to_check as $url_to_check)
|
|
566
|
+ {
|
|
567
|
+ $element_to_check = $this->findOneBy('Element', array('url' => $url_to_check));
|
|
568
|
+ $this->assertTrue(!is_null($element_to_check));
|
|
569
|
+ $elements[] = $element_to_check;
|
|
570
|
+ $playlist_to_check = $this->findOneBy('Playlist', array('id' => $playlist->getId()));
|
|
571
|
+ $this->assertTrue(!is_null($playlist_to_check));
|
|
572
|
+ $this->assertTrue($playlist_to_check->haveElement($element_to_check));
|
|
573
|
+ }
|
|
574
|
+
|
|
575
|
+ return $elements;
|
|
576
|
+ }
|
|
577
|
+
|
520
|
578
|
}
|