[BUGFIX] hasProperty ignores meta data properties 88/26688/4
authorSteffen Ritter <info@rs-websystems.de>
Sat, 18 Jan 2014 15:10:31 +0000 (16:10 +0100)
committerWouter Wolters <typo3@wouterwolters.nl>
Thu, 23 Jan 2014 22:25:18 +0000 (23:25 +0100)
Since the split of sys_file to sys_file_metadata the data
is stored in different arrays. The hasProperty method of
AbstractFile is not overriden in File to consider that change.

Resolves: #54012
Releases: 6.2
Change-Id: Iab2b55e56795033c77c1e3f2969d927ba71a4ceb
Reviewed-on: https://review.typo3.org/26688
Reviewed-by: Alexander Stehlik
Tested-by: Alexander Stehlik
Reviewed-by: Frans Saris
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
typo3/sysext/core/Classes/Resource/File.php
typo3/sysext/core/Tests/Unit/Resource/FileTest.php

index 062c573..060a3b7 100644 (file)
@@ -117,6 +117,21 @@ class File extends AbstractFile {
        }
 
        /**
+        * Checks if the file has a (metadata) property which
+        * can be retrieved by "getProperty"
+        *
+        * @param string $key
+        * @return boolean
+        */
+       public function hasProperty($key) {
+               if (!parent::hasProperty($key)) {
+                       return array_key_exists($key, $this->metaDataProperties);
+               }
+               return TRUE;
+       }
+
+
+       /**
         * Returns the properties of this object.
         *
         * @return array
index ff9cb22..079cc2a 100644 (file)
@@ -462,4 +462,21 @@ class FileTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $method->invoke($fixture);
                $this->assertNull($fixture->isIndexed());
        }
+
+       /**
+        * @test
+        */
+       public function hasPropertyReturnsTrueFilePropertyExists() {
+               $fixture = new \TYPO3\CMS\Core\Resource\File(array('testproperty' => 'testvalue'), $this->storageMock);
+               $this->assertTrue($fixture->hasProperty('testproperty'));
+       }
+
+       /**
+        * @test
+        */
+       public function hasPropertyReturnsTrueIfMetadataPropertyExists() {
+               $fixture = $this->getAccessibleMock('TYPO3\\CMS\\Core\\Resource\\File', array('dummy'), array(array(), $this->storageMock));
+               $fixture->_set('metaDataProperties', array('testproperty' => 'testvalue'));
+               $this->assertTrue($fixture->hasProperty('testproperty'));
+       }
 }