Exemple #1
0
 /**
  * Adds a profile
  *
  * @param FileProfile $profile
  * @return ProfileManager
  * @throws InvalidArgumentException
  */
 public function addProfile(FileProfile $profile)
 {
     $identifier = $profile->getIdentifier();
     if (isset($this->profiles[$identifier])) {
         throw new InvalidArgumentException("Profile '{$identifier}' already exists");
     }
     $this->profiles[$identifier] = $profile;
     $this->eventDispatcher->addSubscriber($profile);
     $event = new FileProfileEvent($profile);
     $this->eventDispatcher->dispatch(Events::PROFILE_AFTER_ADD, $event);
     return $this;
 }
 /**
  * @test
  * @dataProvider provideDataForIsSharedResourceAllowed
  */
 public function isSharedResourceAllowedShouldReturnCorrectResult($expected, $mimetype)
 {
     $this->addMockedVersionsToFileProfile();
     $file = File::create(array('resource' => Resource::create(array('mimetype' => $mimetype))));
     $this->assertEquals($expected, $this->fileProfile->isSharedResourceAllowed($file));
 }