Fix getMock Command/Intergrity

This commit is contained in:
Roeland Jago Douma 2016-09-07 19:42:23 +02:00
parent 4066f04c4b
commit 9ea2153e9b
No known key found for this signature in database
GPG Key ID: 1E152838F164D13B
2 changed files with 31 additions and 32 deletions

View File

@ -24,6 +24,8 @@ use OC\Core\Command\Integrity\SignApp;
use OC\IntegrityCheck\Checker; use OC\IntegrityCheck\Checker;
use OC\IntegrityCheck\Helpers\FileAccessHelper; use OC\IntegrityCheck\Helpers\FileAccessHelper;
use OCP\IURLGenerator; use OCP\IURLGenerator;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Test\TestCase; use Test\TestCase;
class SignAppTest extends TestCase { class SignAppTest extends TestCase {
@ -38,12 +40,9 @@ class SignAppTest extends TestCase {
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
$this->checker = $this->getMockBuilder('\OC\IntegrityCheck\Checker') $this->checker = $this->createMock(Checker::class);
->disableOriginalConstructor()->getMock(); $this->fileAccessHelper = $this->createMock(FileAccessHelper::class);
$this->fileAccessHelper = $this->getMockBuilder('\OC\IntegrityCheck\Helpers\FileAccessHelper') $this->urlGenerator = $this->createMock(IURLGenerator::class);
->disableOriginalConstructor()->getMock();
$this->urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator')
->disableOriginalConstructor()->getMock();
$this->signApp = new SignApp( $this->signApp = new SignApp(
$this->checker, $this->checker,
$this->fileAccessHelper, $this->fileAccessHelper,
@ -52,8 +51,8 @@ class SignAppTest extends TestCase {
} }
public function testExecuteWithMissingPath() { public function testExecuteWithMissingPath() {
$inputInterface = $this->getMock('\Symfony\Component\Console\Input\InputInterface'); $inputInterface = $this->createMock(InputInterface::class);
$outputInterface = $this->getMock('\Symfony\Component\Console\Output\OutputInterface'); $outputInterface = $this->createMock(OutputInterface::class);
$inputInterface $inputInterface
->expects($this->at(0)) ->expects($this->at(0))
@ -80,8 +79,8 @@ class SignAppTest extends TestCase {
} }
public function testExecuteWithMissingPrivateKey() { public function testExecuteWithMissingPrivateKey() {
$inputInterface = $this->getMock('\Symfony\Component\Console\Input\InputInterface'); $inputInterface = $this->createMock(InputInterface::class);
$outputInterface = $this->getMock('\Symfony\Component\Console\Output\OutputInterface'); $outputInterface = $this->createMock(OutputInterface::class);
$inputInterface $inputInterface
->expects($this->at(0)) ->expects($this->at(0))
@ -108,8 +107,8 @@ class SignAppTest extends TestCase {
} }
public function testExecuteWithMissingCertificate() { public function testExecuteWithMissingCertificate() {
$inputInterface = $this->getMock('\Symfony\Component\Console\Input\InputInterface'); $inputInterface = $this->createMock(InputInterface::class);
$outputInterface = $this->getMock('\Symfony\Component\Console\Output\OutputInterface'); $outputInterface = $this->createMock(OutputInterface::class);
$inputInterface $inputInterface
->expects($this->at(0)) ->expects($this->at(0))
@ -136,8 +135,8 @@ class SignAppTest extends TestCase {
} }
public function testExecuteWithNotExistingPrivateKey() { public function testExecuteWithNotExistingPrivateKey() {
$inputInterface = $this->getMock('\Symfony\Component\Console\Input\InputInterface'); $inputInterface = $this->createMock(InputInterface::class);
$outputInterface = $this->getMock('\Symfony\Component\Console\Output\OutputInterface'); $outputInterface = $this->createMock(OutputInterface::class);
$inputInterface $inputInterface
->expects($this->at(0)) ->expects($this->at(0))
@ -170,8 +169,8 @@ class SignAppTest extends TestCase {
} }
public function testExecuteWithNotExistingCertificate() { public function testExecuteWithNotExistingCertificate() {
$inputInterface = $this->getMock('\Symfony\Component\Console\Input\InputInterface'); $inputInterface = $this->createMock(InputInterface::class);
$outputInterface = $this->getMock('\Symfony\Component\Console\Output\OutputInterface'); $outputInterface = $this->createMock(OutputInterface::class);
$inputInterface $inputInterface
->expects($this->at(0)) ->expects($this->at(0))
@ -209,8 +208,8 @@ class SignAppTest extends TestCase {
} }
public function testExecute() { public function testExecute() {
$inputInterface = $this->getMock('\Symfony\Component\Console\Input\InputInterface'); $inputInterface = $this->createMock(InputInterface::class);
$outputInterface = $this->getMock('\Symfony\Component\Console\Output\OutputInterface'); $outputInterface = $this->createMock(OutputInterface::class);
$inputInterface $inputInterface
->expects($this->at(0)) ->expects($this->at(0))

View File

@ -23,6 +23,8 @@ namespace Test\Command\Integrity;
use OC\Core\Command\Integrity\SignCore; use OC\Core\Command\Integrity\SignCore;
use OC\IntegrityCheck\Checker; use OC\IntegrityCheck\Checker;
use OC\IntegrityCheck\Helpers\FileAccessHelper; use OC\IntegrityCheck\Helpers\FileAccessHelper;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Test\TestCase; use Test\TestCase;
class SignCoreTest extends TestCase { class SignCoreTest extends TestCase {
@ -35,10 +37,8 @@ class SignCoreTest extends TestCase {
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
$this->checker = $this->getMockBuilder('\OC\IntegrityCheck\Checker') $this->checker = $this->createMock(Checker::class);
->disableOriginalConstructor()->getMock(); $this->fileAccessHelper = $this->createMock(FileAccessHelper::class);
$this->fileAccessHelper = $this->getMockBuilder('\OC\IntegrityCheck\Helpers\FileAccessHelper')
->disableOriginalConstructor()->getMock();
$this->signCore = new SignCore( $this->signCore = new SignCore(
$this->checker, $this->checker,
$this->fileAccessHelper $this->fileAccessHelper
@ -46,8 +46,8 @@ class SignCoreTest extends TestCase {
} }
public function testExecuteWithMissingPrivateKey() { public function testExecuteWithMissingPrivateKey() {
$inputInterface = $this->getMock('\Symfony\Component\Console\Input\InputInterface'); $inputInterface = $this->createMock(InputInterface::class);
$outputInterface = $this->getMock('\Symfony\Component\Console\Output\OutputInterface'); $outputInterface = $this->createMock(OutputInterface::class);
$inputInterface $inputInterface
->expects($this->at(0)) ->expects($this->at(0))
@ -69,8 +69,8 @@ class SignCoreTest extends TestCase {
} }
public function testExecuteWithMissingCertificate() { public function testExecuteWithMissingCertificate() {
$inputInterface = $this->getMock('\Symfony\Component\Console\Input\InputInterface'); $inputInterface = $this->createMock(InputInterface::class);
$outputInterface = $this->getMock('\Symfony\Component\Console\Output\OutputInterface'); $outputInterface = $this->createMock(OutputInterface::class);
$inputInterface $inputInterface
->expects($this->at(0)) ->expects($this->at(0))
@ -92,8 +92,8 @@ class SignCoreTest extends TestCase {
} }
public function testExecuteWithNotExistingPrivateKey() { public function testExecuteWithNotExistingPrivateKey() {
$inputInterface = $this->getMock('\Symfony\Component\Console\Input\InputInterface'); $inputInterface = $this->createMock(InputInterface::class);
$outputInterface = $this->getMock('\Symfony\Component\Console\Output\OutputInterface'); $outputInterface = $this->createMock(OutputInterface::class);
$inputInterface $inputInterface
->expects($this->at(0)) ->expects($this->at(0))
@ -126,8 +126,8 @@ class SignCoreTest extends TestCase {
} }
public function testExecuteWithNotExistingCertificate() { public function testExecuteWithNotExistingCertificate() {
$inputInterface = $this->getMock('\Symfony\Component\Console\Input\InputInterface'); $inputInterface = $this->createMock(InputInterface::class);
$outputInterface = $this->getMock('\Symfony\Component\Console\Output\OutputInterface'); $outputInterface = $this->createMock(OutputInterface::class);
$inputInterface $inputInterface
->expects($this->at(0)) ->expects($this->at(0))
@ -165,8 +165,8 @@ class SignCoreTest extends TestCase {
} }
public function testExecute() { public function testExecute() {
$inputInterface = $this->getMock('\Symfony\Component\Console\Input\InputInterface'); $inputInterface = $this->createMock(InputInterface::class);
$outputInterface = $this->getMock('\Symfony\Component\Console\Output\OutputInterface'); $outputInterface = $this->createMock(OutputInterface::class);
$inputInterface $inputInterface
->expects($this->at(0)) ->expects($this->at(0))