/** * @test */ public function updatePropertiesMarksPropertyAsChangedOnlyOnce() { $fixture = new \TYPO3\CMS\Core\Resource\File(array('uid' => 1, 'foo' => 'asdf', 'baz' => 'fdsw', 'identifier' => '/test'), $this->storageMock); $fixture->updateProperties(array('foo' => 'foobar', 'baz' => 'foobaz')); $fixture->updateProperties(array('foo' => 'fdsw', 'baz' => 'asdf')); $this->assertEquals(array('foo', 'baz'), $fixture->getUpdatedProperties()); }
/** * @test */ public function updatePropertiesReloadsStorageObjectIfStorageChanges() { $mockedNewStorage = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE); $mockedOldStorage = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE); $fixture = new \TYPO3\CMS\Core\Resource\File(array('uid' => 1, 'foo' => 'asdf', 'baz' => 'fdsw', 'identifier' => '/test', 'storage' => $mockedOldStorage)); $mockedRepository = $this->getMock('TYPO3\\CMS\\Core\\Resource\\StorageRepository'); $mockedRepository->expects($this->once())->method('findByUid')->with(2)->will($this->returnValue($mockedNewStorage)); \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Resource\\StorageRepository', $mockedRepository); $fixture->updateProperties(array('storage' => 2)); $this->assertSame($mockedNewStorage, $fixture->getStorage()); }