TYPO3 CMS  TYPO3_6-2
FileReferenceTest.php
Go to the documentation of this file.
1 <?php
3 
23 
27  protected $singletonInstances = array();
28 
29  public function setUp() {
32  }
33 
34  public function tearDown() {
36  parent::tearDown();
37  }
38 
44  protected function prepareFixture(array $fileReferenceProperties, array $originalFileProperties) {
45  $fixture = $this->getAccessibleMock('TYPO3\\CMS\\Core\\Resource\\FileReference', array('dummy'), array(), '', FALSE);
46  $originalFileMock = $this->getAccessibleMock('TYPO3\\CMS\\Core\\Resource\\File', array(), array(), '', FALSE);
47  $originalFileMock->expects($this->any())
48  ->method('getProperties')
49  ->will($this->returnValue($originalFileProperties)
50  );
51  $fixture->_set('originalFile', $originalFileMock);
52  $fixture->_set('propertiesOfFileReference', $fileReferenceProperties);
53 
54  return $fixture;
55  }
56 
60  public function propertiesDataProvider() {
61  return array(
62  'File properties correctly override file reference properties' => array(
63  array(
64  'title' => NULL,
65  'description' => 'fileReferenceDescription',
66  'alternative' => '',
67  ),
68  array(
69  'title' => 'fileTitle',
70  'description' => 'fileDescription',
71  'alternative' => 'fileAlternative',
72  'file_only_property' => 'fileOnlyPropertyValue',
73  ),
74  array(
75  'title' => 'fileTitle',
76  'description' => 'fileReferenceDescription',
77  'alternative' => '',
78  'file_only_property' => 'fileOnlyPropertyValue',
79  ),
80  )
81  );
82  }
83 
91  public function getPropertiesReturnsMergedPropertiesAndRespectsNullValues(array $fileReferenceProperties, array $originalFileProperties, array $expectedMergedProperties) {
92  $fixture = $this->prepareFixture($fileReferenceProperties, $originalFileProperties);
93  $actual = $fixture->getProperties();
94  $this->assertSame($expectedMergedProperties, $actual);
95  }
96 
104  public function hasPropertyReturnsTrueForAllMergedPropertyKeys($fileReferenceProperties, $originalFileProperties, $expectedMergedProperties) {
105  $fixture = $this->prepareFixture($fileReferenceProperties, $originalFileProperties);
106  foreach ($expectedMergedProperties as $key => $_) {
107  $this->assertTrue($fixture->hasProperty($key));
108  }
109  }
110 
118  public function getPropertyReturnsAllMergedPropertyKeys($fileReferenceProperties, $originalFileProperties, $expectedMergedProperties) {
119  $fixture = $this->prepareFixture($fileReferenceProperties, $originalFileProperties);
120  foreach ($expectedMergedProperties as $key => $expectedValue) {
121  $this->assertSame($expectedValue, $fixture->getProperty($key));
122  }
123  }
124 
133  public function getPropertyThrowsExceptionForNotAvailableProperty($fileReferenceProperties, $originalFileProperties) {
134  $fixture = $this->prepareFixture($fileReferenceProperties, $originalFileProperties);
135  $fixture->getProperty($this->getUniqueId('nothingHere'));
136  }
137 
145  public function getPropertyDoesNotThrowExceptionForPropertyOnlyAvailableInOriginalFile($fileReferenceProperties, $originalFileProperties) {
146  $fixture = $this->prepareFixture($fileReferenceProperties, $originalFileProperties);
147  $this->assertSame($originalFileProperties['file_only_property'], $fixture->getProperty('file_only_property'));
148  }
149 
158  public function getReferencePropertyThrowsExceptionForPropertyOnlyAvailableInOriginalFile($fileReferenceProperties, $originalFileProperties) {
159  $fixture = $this->prepareFixture($fileReferenceProperties, $originalFileProperties);
160  $fixture->getReferenceProperty('file_only_property');
161  }
162 }
getPropertiesReturnsMergedPropertiesAndRespectsNullValues(array $fileReferenceProperties, array $originalFileProperties, array $expectedMergedProperties)
prepareFixture(array $fileReferenceProperties, array $originalFileProperties)
hasPropertyReturnsTrueForAllMergedPropertyKeys($fileReferenceProperties, $originalFileProperties, $expectedMergedProperties)
getReferencePropertyThrowsExceptionForPropertyOnlyAvailableInOriginalFile($fileReferenceProperties, $originalFileProperties)
getPropertyDoesNotThrowExceptionForPropertyOnlyAvailableInOriginalFile($fileReferenceProperties, $originalFileProperties)
static resetSingletonInstances(array $newSingletonInstances)
getAccessibleMock( $originalClassName, array $methods=array(), array $arguments=array(), $mockClassName='', $callOriginalConstructor=TRUE, $callOriginalClone=TRUE, $callAutoload=TRUE)
getPropertyThrowsExceptionForNotAvailableProperty($fileReferenceProperties, $originalFileProperties)
getPropertyReturnsAllMergedPropertyKeys($fileReferenceProperties, $originalFileProperties, $expectedMergedProperties)