aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/Command/Integrity/SignCoreTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/Command/Integrity/SignCoreTest.php')
-rw-r--r--tests/lib/Command/Integrity/SignCoreTest.php166
1 files changed, 63 insertions, 103 deletions
diff --git a/tests/lib/Command/Integrity/SignCoreTest.php b/tests/lib/Command/Integrity/SignCoreTest.php
index bbb68e00a84..66227322dda 100644
--- a/tests/lib/Command/Integrity/SignCoreTest.php
+++ b/tests/lib/Command/Integrity/SignCoreTest.php
@@ -39,22 +39,18 @@ class SignCoreTest extends TestCase {
$inputInterface
->expects($this->exactly(3))
->method('getOption')
- ->withConsecutive(
- ['privateKey'],
- ['certificate'],
- ['path'],
- )->willReturnOnConsecutiveCalls(
- null,
- 'certificate',
- 'certificate',
- );
+ ->willReturnMap([
+ ['privateKey', null],
+ ['certificate', 'certificate'],
+ ['path', 'certificate'],
+ ]);
$outputInterface
->expects($this->any())
->method('writeln')
- ->withConsecutive(
- ['--privateKey, --certificate and --path are required.']
- );
+ ->willReturnCallback(function (string $message) {
+ $this->assertEquals('--privateKey, --certificate and --path are required.', $message);
+ });
$this->assertSame(1, self::invokePrivate($this->signCore, 'execute', [$inputInterface, $outputInterface]));
}
@@ -66,22 +62,18 @@ class SignCoreTest extends TestCase {
$inputInterface
->expects($this->exactly(3))
->method('getOption')
- ->withConsecutive(
- ['privateKey'],
- ['certificate'],
- ['path'],
- )->willReturnOnConsecutiveCalls(
- 'privateKey',
- null,
- 'certificate',
- );
+ ->willReturnMap([
+ ['privateKey', 'privateKey'],
+ ['certificate', null],
+ ['path', 'certificate'],
+ ]);
$outputInterface
->expects($this->any())
->method('writeln')
- ->withConsecutive(
- ['--privateKey, --certificate and --path are required.']
- );
+ ->willReturnCallback(function (string $message) {
+ $this->assertEquals('--privateKey, --certificate and --path are required.', $message);
+ });
$this->assertSame(1, self::invokePrivate($this->signCore, 'execute', [$inputInterface, $outputInterface]));
}
@@ -93,32 +85,24 @@ class SignCoreTest extends TestCase {
$inputInterface
->expects($this->exactly(3))
->method('getOption')
- ->withConsecutive(
- ['privateKey'],
- ['certificate'],
- ['path'],
- )->willReturnOnConsecutiveCalls(
- 'privateKey',
- 'certificate',
- 'certificate',
- );
+ ->willReturnMap([
+ ['privateKey', 'privateKey'],
+ ['certificate', 'certificate'],
+ ['path', 'certificate'],
+ ]);
$this->fileAccessHelper
- ->expects($this->any())
->method('file_get_contents')
- ->withConsecutive(
- ['privateKey'],
- )
- ->willReturnOnConsecutiveCalls(
- false,
- );
+ ->willReturnMap([
+ ['privateKey', false],
+ ]);
$outputInterface
->expects($this->any())
->method('writeln')
- ->withConsecutive(
- ['Private key "privateKey" does not exists.']
- );
+ ->willReturnCallback(function (string $message) {
+ $this->assertEquals('Private key "privateKey" does not exists.', $message);
+ });
$this->assertSame(1, self::invokePrivate($this->signCore, 'execute', [$inputInterface, $outputInterface]));
}
@@ -130,34 +114,26 @@ class SignCoreTest extends TestCase {
$inputInterface
->expects($this->exactly(3))
->method('getOption')
- ->withConsecutive(
- ['privateKey'],
- ['certificate'],
- ['path'],
- )->willReturnOnConsecutiveCalls(
- 'privateKey',
- 'certificate',
- 'certificate',
- );
+ ->willReturnMap([
+ ['privateKey', 'privateKey'],
+ ['certificate', 'certificate'],
+ ['path', 'certificate'],
+ ]);
$this->fileAccessHelper
->expects($this->any())
->method('file_get_contents')
- ->withConsecutive(
- ['privateKey'],
- ['certificate'],
- )
- ->willReturnOnConsecutiveCalls(
- file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key'),
- false,
- );
+ ->willReturnMap([
+ ['privateKey', file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key')],
+ ['certificate', false],
+ ]);
$outputInterface
->expects($this->any())
->method('writeln')
- ->withConsecutive(
- ['Certificate "certificate" does not exists.']
- );
+ ->willReturnCallback(function (string $message) {
+ $this->assertEquals('Certificate "certificate" does not exists.', $message);
+ });
$this->assertSame(1, self::invokePrivate($this->signCore, 'execute', [$inputInterface, $outputInterface]));
}
@@ -169,27 +145,19 @@ class SignCoreTest extends TestCase {
$inputInterface
->expects($this->exactly(3))
->method('getOption')
- ->withConsecutive(
- ['privateKey'],
- ['certificate'],
- ['path'],
- )->willReturnOnConsecutiveCalls(
- 'privateKey',
- 'certificate',
- 'certificate',
- );
+ ->willReturnMap([
+ ['privateKey', 'privateKey'],
+ ['certificate', 'certificate'],
+ ['path', 'certificate'],
+ ]);
$this->fileAccessHelper
->expects($this->any())
->method('file_get_contents')
- ->withConsecutive(
- ['privateKey'],
- ['certificate'],
- )
- ->willReturnOnConsecutiveCalls(
- file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key'),
- file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.crt'),
- );
+ ->willReturnMap([
+ ['privateKey', file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key')],
+ ['certificate', file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.crt')],
+ ]);
$this->checker
->expects($this->once())
@@ -199,9 +167,9 @@ class SignCoreTest extends TestCase {
$outputInterface
->expects($this->any())
->method('writeln')
- ->withConsecutive(
- ['Error: My exception message']
- );
+ ->willReturnCallback(function (string $message) {
+ $this->assertEquals('Error: My exception message', $message);
+ });
$this->assertEquals(1, self::invokePrivate($this->signCore, 'execute', [$inputInterface, $outputInterface]));
}
@@ -213,27 +181,19 @@ class SignCoreTest extends TestCase {
$inputInterface
->expects($this->exactly(3))
->method('getOption')
- ->withConsecutive(
- ['privateKey'],
- ['certificate'],
- ['path'],
- )->willReturnOnConsecutiveCalls(
- 'privateKey',
- 'certificate',
- 'certificate',
- );
+ ->willReturnMap([
+ ['privateKey', 'privateKey'],
+ ['certificate', 'certificate'],
+ ['path', 'certificate'],
+ ]);
$this->fileAccessHelper
->expects($this->any())
->method('file_get_contents')
- ->withConsecutive(
- ['privateKey'],
- ['certificate'],
- )
- ->willReturnOnConsecutiveCalls(
- file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key'),
- file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.crt'),
- );
+ ->willReturnMap([
+ ['privateKey', file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key')],
+ ['certificate', file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.crt')],
+ ]);
$this->checker
->expects($this->once())
@@ -242,9 +202,9 @@ class SignCoreTest extends TestCase {
$outputInterface
->expects($this->any())
->method('writeln')
- ->withConsecutive(
- ['Successfully signed "core"']
- );
+ ->willReturnCallback(function (string $message) {
+ $this->assertEquals('Successfully signed "core"', $message);
+ });
$this->assertEquals(0, self::invokePrivate($this->signCore, 'execute', [$inputInterface, $outputInterface]));
}