Пример #1
0
 /**
  * Tests getting all options for a regular user.
  */
 public function testGetOptionsForRegularUser()
 {
     $this->expectEvent(ContaoCoreEvents::IMAGE_SIZES_USER);
     $this->expectExampleImageSizes();
     /** @var BackendUser|\PHPUnit_Framework_MockObject_MockObject $user */
     $user = $this->getMock('Contao\\BackendUser');
     $user->isAdmin = false;
     // Allow only one image size
     $user->imageSizes = serialize(['42']);
     $options = $this->imageSizes->getOptionsForUser($user);
     $this->assertArrayNotHasKey('relative', $options);
     $this->assertArrayNotHasKey('exact', $options);
     $this->assertArrayHasKey('image_sizes', $options);
     $this->assertArrayHasKey('42', $options['image_sizes']);
     // Allow only some TL_CROP options
     $user->imageSizes = serialize(['proportional', 'box']);
     $options = $this->imageSizes->getOptionsForUser($user);
     $this->assertArrayHasKey('relative', $options);
     $this->assertArrayNotHasKey('exact', $options);
     $this->assertArrayNotHasKey('image_sizes', $options);
     // Allow nothing
     $user->imageSizes = serialize([]);
     $options = $this->imageSizes->getOptionsForUser($user);
     $this->assertEquals([], $options);
 }