Fix unit tests for BlockLegacyClientPlugin

This commit is contained in:
Thomas Müller 2016-10-24 22:38:22 +02:00 committed by Morris Jobke
parent 1c39b30d50
commit 9df3869bfc
No known key found for this signature in database
GPG Key ID: 9CE5ED29E7FCD38A
1 changed files with 10 additions and 15 deletions

View File

@ -26,6 +26,7 @@
namespace OCA\DAV\Tests\unit\Connector\Sabre;
use OCA\DAV\Connector\Sabre\BlockLegacyClientPlugin;
use PHPUnit_Framework_MockObject_MockObject;
use Test\TestCase;
use OCP\IConfig;
@ -35,7 +36,7 @@ use OCP\IConfig;
* @package OCA\DAV\Tests\unit\Connector\Sabre
*/
class BlockLegacyClientPluginTest extends TestCase {
/** @var IConfig */
/** @var IConfig | \PHPUnit_Framework_MockObject_MockObject */
private $config;
/** @var BlockLegacyClientPlugin */
private $blockLegacyClientVersionPlugin;
@ -69,10 +70,8 @@ class BlockLegacyClientPluginTest extends TestCase {
* @expectedExceptionMessage Unsupported client version.
*/
public function testBeforeHandlerException($userAgent) {
/** @var \Sabre\HTTP\RequestInterface $request */
$request = $this->getMockBuilder('\Sabre\HTTP\RequestInterface')
->disableOriginalConstructor()
->getMock();
/** @var \Sabre\HTTP\RequestInterface | PHPUnit_Framework_MockObject_MockObject $request */
$request = $this->createMock('\Sabre\HTTP\RequestInterface');
$request
->expects($this->once())
->method('getHeader')
@ -82,7 +81,7 @@ class BlockLegacyClientPluginTest extends TestCase {
$this->config
->expects($this->once())
->method('getSystemValue')
->with('minimum.supported.desktop.version', '1.7.0')
->with('minimum.supported.desktop.version', '2.0.0')
->will($this->returnValue('1.7.0'));
$this->blockLegacyClientVersionPlugin->beforeHandler($request);
@ -106,10 +105,8 @@ class BlockLegacyClientPluginTest extends TestCase {
* @param string $userAgent
*/
public function testBeforeHandlerSuccess($userAgent) {
/** @var \Sabre\HTTP\RequestInterface $request */
$request = $this->getMockBuilder('\Sabre\HTTP\RequestInterface')
->disableOriginalConstructor()
->getMock();
/** @var \Sabre\HTTP\RequestInterface | PHPUnit_Framework_MockObject_MockObject $request */
$request = $this->createMock('\Sabre\HTTP\RequestInterface');
$request
->expects($this->once())
->method('getHeader')
@ -119,17 +116,15 @@ class BlockLegacyClientPluginTest extends TestCase {
$this->config
->expects($this->once())
->method('getSystemValue')
->with('minimum.supported.desktop.version', '1.7.0')
->with('minimum.supported.desktop.version', '2.0.0')
->will($this->returnValue('1.7.0'));
$this->blockLegacyClientVersionPlugin->beforeHandler($request);
}
public function testBeforeHandlerNoUserAgent() {
/** @var \Sabre\HTTP\RequestInterface $request */
$request = $this->getMockBuilder('\Sabre\HTTP\RequestInterface')
->disableOriginalConstructor()
->getMock();
/** @var \Sabre\HTTP\RequestInterface | PHPUnit_Framework_MockObject_MockObject $request */
$request = $this->createMock('\Sabre\HTTP\RequestInterface');
$request
->expects($this->once())
->method('getHeader')