Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix mocks to support >=5.5.14 and >=5.4.30 #11230

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationRequestHandler;
use Symfony\Component\Form\Tests\AbstractRequestHandlerTest;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\File\UploadedFile;

/**
* @author Bernhard Schussek <[email protected]>
Expand Down Expand Up @@ -47,8 +48,6 @@ protected function getRequestHandler()

protected function getMockFile()
{
return $this->getMockBuilder('Symfony\Component\HttpFoundation\File\UploadedFile')
->setConstructorArgs(array(__DIR__.'/../../Fixtures/foo', 'foo'))
->getMock();
return new UploadedFile(__DIR__.'/../../Fixtures/foo', 'foo');
}
}
45 changes: 45 additions & 0 deletions src/Symfony/Component/HttpFoundation/Resources/stubs/FakeFile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\HttpFoundation\Resources\stubs;

use Symfony\Component\HttpFoundation\File\File as OrigFile;

class FakeFile extends OrigFile
{
private $realpath;

public function __construct($realpath, $path)
{
$this->realpath = $realpath;
parent::__construct($path, false);
}

public function isReadable()
{
return true;
}

public function getRealpath()
{
return $this->realpath;
}

public function getSize()
{
return 42;
}

public function getMTime()
{
return time();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
use Symfony\Component\HttpFoundation\Resources\stubs\FakeFile;

class BinaryFileResponseTest extends ResponseTestCase
{
Expand Down Expand Up @@ -179,18 +180,7 @@ public function testXAccelMapping($realpath, $mapping, $virtual)
$request->headers->set('X-Sendfile-Type', 'X-Accel-Redirect');
$request->headers->set('X-Accel-Mapping', $mapping);

$file = $this->getMockBuilder('Symfony\Component\HttpFoundation\File\File')
->setConstructorArgs(array(__DIR__.'/File/Fixtures/test'))
->getMock();
$file->expects($this->any())
->method('getRealPath')
->will($this->returnValue($realpath));
$file->expects($this->any())
->method('isReadable')
->will($this->returnValue(true));
$file->expects($this->any())
->method('getMTime')
->will($this->returnValue(time()));
$file = new FakeFile($realpath, __DIR__.'/File/Fixtures/test');

BinaryFileResponse::trustXSendFileTypeHeader();
$response = new BinaryFileResponse($file);
Expand Down