コード例 #1
0
 /**
  * @test
  */
 public function hiddenFieldsContainDataOfAPreviouslyUploadedResource()
 {
     $mockResource = $this->getMock('TYPO3\\Flow\\Resource\\Resource');
     $mockResource->expects($this->any())->method('getFilename')->will($this->returnValue('theResourceFilename'));
     $mockResource->expects($this->any())->method('getResourcePointer')->will($this->returnValue('theResourcePointer'));
     $resourceData = array('error' => \UPLOAD_ERR_NO_FILE, 'submittedFile' => array('filename' => 'theResourceFilename', 'resourcePointer' => 'theResourcePointer'));
     $this->mockPropertyMapper->expects($this->atLeastOnce())->method('convert')->with($resourceData, 'TYPO3\\Flow\\Resource\\Resource')->will($this->returnValue($mockResource));
     $this->viewHelper->expects($this->atLeastOnce())->method('getValue')->will($this->returnValue($resourceData));
     $expectedResult = '<input type="hidden" name="[submittedFile][filename]" value="theResourceFilename" /><input type="hidden" name="[submittedFile][resourcePointer]" value="theResourcePointer" />';
     $this->viewHelper->initialize();
     $actualResult = $this->viewHelper->render();
     $this->assertSame($expectedResult, $actualResult);
 }
コード例 #2
0
 /**
  * @test
  */
 public function hiddenFieldsContainDataOfBoundPropertyIfNoValueArgumentIsSetAndNoResourceHasBeenUploaded()
 {
     $mockResourceUuid = '79ecda60-1a27-69ca-17bf-a5d9e80e6c39';
     /** @var Result|\PHPUnit_Framework_MockObject_MockObject $mockValidationResults */
     $mockValidationResults = $this->getMockBuilder(\TYPO3\Flow\Error\Result::class)->disableOriginalConstructor()->getMock();
     $mockValidationResults->expects($this->atLeastOnce())->method('hasErrors')->will($this->returnValue(false));
     $this->request->expects($this->atLeastOnce())->method('getInternalArgument')->with('__submittedArgumentValidationResults')->will($this->returnValue($mockValidationResults));
     /** @var Resource|\PHPUnit_Framework_MockObject_MockObject $mockPropertyResource */
     $mockPropertyResource = $this->getMockBuilder(\TYPO3\Flow\Resource\Resource::class)->disableOriginalConstructor()->getMock();
     $mockFormObject = array('foo' => $mockPropertyResource);
     $this->viewHelperVariableContainerData[\TYPO3\Fluid\ViewHelpers\FormViewHelper::class] = array('formObjectName' => 'someObject', 'formObject' => $mockFormObject);
     $mockPersistenceManager = $this->createMock(\TYPO3\Flow\Persistence\PersistenceManagerInterface::class);
     $mockPersistenceManager->expects($this->once())->method('getIdentifierByObject')->with($this->identicalTo($mockPropertyResource))->will($this->returnValue($mockResourceUuid));
     $this->inject($this->viewHelper, 'persistenceManager', $mockPersistenceManager);
     $this->viewHelper->setArguments(array('property' => 'foo'));
     $expectedResult = '<input type="hidden" name="someObject[foo][originallySubmittedResource][__identity]" value="' . $mockResourceUuid . '" />';
     $actualResult = $this->viewHelper->render();
     $this->assertSame($expectedResult, $actualResult);
 }
コード例 #3
0
 /**
  * @test
  */
 public function renderCallsSetErrorClassAttribute()
 {
     $this->viewHelper->expects($this->once())->method('setErrorClassAttribute');
     $this->viewHelper->render();
 }