|  | @@ -310,7 +310,6 @@ class PlaylistControllerTest extends FunctionalTest
 | 
	
		
			
			| 310 | 310 |    protected function updatePlaylistOrder($playlist, $elements)
 | 
	
		
			
			| 311 | 311 |    {
 | 
	
		
			
			| 312 | 312 |      $response = $this->tests_cases->playlistUpdateOrder($playlist->getId(), $elements);
 | 
	
		
			
			| 313 |  | -    $this->outputDebug();
 | 
	
		
			
			| 314 | 313 |      $this->jsonResponseIsSuccess($response);
 | 
	
		
			
			| 315 | 314 |    }
 | 
	
		
			
			| 316 | 315 |    
 | 
	
	
		
			
			|  | @@ -368,4 +367,69 @@ class PlaylistControllerTest extends FunctionalTest
 | 
	
		
			
			| 368 | 367 |      $this->tests_cases->playlistremoveElement($playlist->getId(), $element->getId());
 | 
	
		
			
			| 369 | 368 |    }
 | 
	
		
			
			| 370 | 369 |    
 | 
	
		
			
			|  | 370 | +  public function testCopyWhenAddingElementToPickedPlaylist()
 | 
	
		
			
			|  | 371 | +  {
 | 
	
		
			
			|  | 372 | +    $this->init();
 | 
	
		
			
			|  | 373 | +    $this->initCopysContextData();
 | 
	
		
			
			|  | 374 | +    $this->connectUser('bux', 'toor');
 | 
	
		
			
			|  | 375 | +    
 | 
	
		
			
			|  | 376 | +    $this->checkPlaylistPickedBy($this->playlists['bob_pub'], $this->users['bux']);
 | 
	
		
			
			|  | 377 | +    $this->addElementAndCopyPlaylist($this->playlists['bob_pub'], $this->elements['azyd']);
 | 
	
		
			
			|  | 378 | +    $this->playlists['bux_bob_pub'] = $this->findOneBy('Playlist', array(
 | 
	
		
			
			|  | 379 | +      'name' => 'A travers l\'espace',
 | 
	
		
			
			|  | 380 | +      'owner' => $this->users['bux']->getId()
 | 
	
		
			
			|  | 381 | +    ));
 | 
	
		
			
			|  | 382 | +    $this->assertTrue(!is_null($this->playlists['bux_bob_pub']));
 | 
	
		
			
			|  | 383 | +    $this->checkPlaylistOwnedBy($this->playlists['bux_bob_pub'], $this->users['bux']);
 | 
	
		
			
			|  | 384 | +  }
 | 
	
		
			
			|  | 385 | +  
 | 
	
		
			
			|  | 386 | +  protected function initCopysContextData()
 | 
	
		
			
			|  | 387 | +  {
 | 
	
		
			
			|  | 388 | +    $this->initReadContextData();
 | 
	
		
			
			|  | 389 | +    $this->elements['azyd'] = $this->findOneBy('Element', 'AZYD AZYLUM Live au Café Provisoire'); 
 | 
	
		
			
			|  | 390 | +  }
 | 
	
		
			
			|  | 391 | +  
 | 
	
		
			
			|  | 392 | +  protected function checkPlaylistPickedBy($playlist, $user)
 | 
	
		
			
			|  | 393 | +  {
 | 
	
		
			
			|  | 394 | +    $this->assertTrue($playlist->havePickerUser($user));
 | 
	
		
			
			|  | 395 | +  }
 | 
	
		
			
			|  | 396 | +  
 | 
	
		
			
			|  | 397 | +  protected function addElementAndCopyPlaylist($playlist, $element)
 | 
	
		
			
			|  | 398 | +  {
 | 
	
		
			
			|  | 399 | +    $response = $this->tests_cases->playlistAddElementAndCopy($playlist->getId(), $element->getId());
 | 
	
		
			
			|  | 400 | +    $this->jsonResponseIsSuccess($response);
 | 
	
		
			
			|  | 401 | +  }
 | 
	
		
			
			|  | 402 | +  
 | 
	
		
			
			|  | 403 | +  protected function checkPlaylistOwnedBy($playlist, $user)
 | 
	
		
			
			|  | 404 | +  {
 | 
	
		
			
			|  | 405 | +    $this->assertEquals($playlist->getOwner()->getId(), $user->getId());
 | 
	
		
			
			|  | 406 | +  }
 | 
	
		
			
			|  | 407 | +  
 | 
	
		
			
			|  | 408 | +  protected function checkPlaylistNotOwnedBy($playlist, $user)
 | 
	
		
			
			|  | 409 | +  {
 | 
	
		
			
			|  | 410 | +    $this->assertNotEquals($playlist->getOwner()->getId(), $user->getId());
 | 
	
		
			
			|  | 411 | +  }
 | 
	
		
			
			|  | 412 | +  
 | 
	
		
			
			|  | 413 | +  public function testCopyWhenPickedPlaylistDeleted()
 | 
	
		
			
			|  | 414 | +  {
 | 
	
		
			
			|  | 415 | +    $this->init();
 | 
	
		
			
			|  | 416 | +    $this->initCopysContextData();
 | 
	
		
			
			|  | 417 | +    $this->connectUser('bob', 'toor');
 | 
	
		
			
			|  | 418 | +    
 | 
	
		
			
			|  | 419 | +    $this->checkPlaylistPickedBy($this->playlists['bob_pub'], $this->users['bux']);
 | 
	
		
			
			|  | 420 | +    $this->checkPlaylistNotOwnedBy($this->playlists['bob_pub'], $this->users['bux']);
 | 
	
		
			
			|  | 421 | +    $this->deletePlaylist($this->playlists['bob_pub']);
 | 
	
		
			
			|  | 422 | +    $this->playlists['bux_bob_pub'] = $this->findOneBy('Playlist', array('name' => 'A travers l\'espace'));
 | 
	
		
			
			|  | 423 | +    $this->assertTrue(!is_null($this->playlists['bux_bob_pub']));
 | 
	
		
			
			|  | 424 | +    $this->checkPlaylistOwnedBy($this->playlists['bux_bob_pub'], $this->users['bux']);
 | 
	
		
			
			|  | 425 | +  }
 | 
	
		
			
			|  | 426 | +  
 | 
	
		
			
			|  | 427 | +  protected function deletePlaylist($playlist)
 | 
	
		
			
			|  | 428 | +  {
 | 
	
		
			
			|  | 429 | +    $this->tests_cases->playlistDelete($playlist->getId());
 | 
	
		
			
			|  | 430 | +    $this->isResponseRedirection();
 | 
	
		
			
			|  | 431 | +    $this->followRedirection();
 | 
	
		
			
			|  | 432 | +    $this->isResponseSuccess();
 | 
	
		
			
			|  | 433 | +  }
 | 
	
		
			
			|  | 434 | +  
 | 
	
		
			
			| 371 | 435 |  }
 |