UPSTREAM BASELINE: nextcloud/spreed v22.0.12 (без изменений)
Type checking / changes (push) Has been cancelled
Type checking / test (push) Has been cancelled
Type checking / typescript-summary (push) Has been cancelled
Node tests / changes (push) Has been cancelled
Node tests / test (push) Has been cancelled
Node tests / test-summary (push) Has been cancelled
Type checking / changes (push) Has been cancelled
Type checking / test (push) Has been cancelled
Type checking / typescript-summary (push) Has been cancelled
Node tests / changes (push) Has been cancelled
Node tests / test (push) Has been cancelled
Node tests / test-summary (push) Has been cancelled
Источник: https://github.com/nextcloud/spreed/archive/refs/tags/v22.0.12.tar.gz С этого коммита ветка официального Nextcloud Talk отрезана (решение владельца 2026-07-06). Все дальнейшие изменения — только наши; версии релизов: 22.0.12-f7.N.
This commit is contained in:
@@ -0,0 +1,167 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
namespace OCA\Talk\Tests\php\Command\Signaling;
|
||||
|
||||
use OCA\Talk\Command\Signaling\Add;
|
||||
use OCP\IConfig;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Test\TestCase;
|
||||
|
||||
class AddTest extends TestCase {
|
||||
protected IConfig&MockObject $config;
|
||||
protected InputInterface&MockObject $input;
|
||||
protected OutputInterface&MockObject $output;
|
||||
protected Add $command;
|
||||
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->config = $this->createMock(IConfig::class);
|
||||
|
||||
$this->command = new Add($this->config);
|
||||
|
||||
$this->input = $this->createMock(InputInterface::class);
|
||||
$this->output = $this->createMock(OutputInterface::class);
|
||||
}
|
||||
|
||||
public function testServerEmptyString(): void {
|
||||
$this->input->method('getArgument')
|
||||
->willReturnCallback(function ($arg) {
|
||||
if ($arg === 'server') {
|
||||
return '';
|
||||
} elseif ($arg === 'secret') {
|
||||
return 'my-test-secret';
|
||||
}
|
||||
throw new \Exception();
|
||||
});
|
||||
$this->input->method('getOption')
|
||||
->with('verify')
|
||||
->willReturn(true);
|
||||
$this->output->expects($this->once())
|
||||
->method('writeln')
|
||||
->with($this->equalTo('<error>Server cannot be empty.</error>'));
|
||||
$this->config->expects($this->never())
|
||||
->method('setAppValue');
|
||||
|
||||
self::invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
}
|
||||
|
||||
public function testSecretEmptyString(): void {
|
||||
$this->input->method('getArgument')
|
||||
->willReturnCallback(function ($arg) {
|
||||
if ($arg === 'server') {
|
||||
return 'wss://signaling.test.com';
|
||||
} elseif ($arg === 'secret') {
|
||||
return '';
|
||||
}
|
||||
throw new \Exception();
|
||||
});
|
||||
$this->input->method('getOption')
|
||||
->with('verify')
|
||||
->willReturn(true);
|
||||
$this->output->expects($this->once())
|
||||
->method('writeln')
|
||||
->with($this->equalTo('<error>Secret cannot be empty.</error>'));
|
||||
$this->config->expects($this->never())
|
||||
->method('setAppValue');
|
||||
|
||||
self::invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
}
|
||||
|
||||
public function testAddServerToEmptyList(): void {
|
||||
$this->input->method('getArgument')
|
||||
->willReturnCallback(function ($arg) {
|
||||
if ($arg === 'server') {
|
||||
return 'wss://signaling.test.com';
|
||||
} elseif ($arg === 'secret') {
|
||||
return 'my-test-secret';
|
||||
}
|
||||
throw new \Exception();
|
||||
});
|
||||
$this->input->method('getOption')
|
||||
->with('verify')
|
||||
->willReturn(true);
|
||||
$this->config->expects($this->once())
|
||||
->method('getAppValue')
|
||||
->with('spreed', 'signaling_servers')
|
||||
->willReturn(json_encode([]));
|
||||
$this->config->expects($this->once())
|
||||
->method('setAppValue')
|
||||
->with(
|
||||
$this->equalTo('spreed'),
|
||||
$this->equalTo('signaling_servers'),
|
||||
$this->equalTo(json_encode([
|
||||
'servers' => [
|
||||
[
|
||||
'server' => 'wss://signaling.test.com',
|
||||
'verify' => true
|
||||
]
|
||||
],
|
||||
'secret' => 'my-test-secret'
|
||||
]))
|
||||
);
|
||||
$this->output->expects($this->once())
|
||||
->method('writeln')
|
||||
->with($this->equalTo('<info>Added signaling server wss://signaling.test.com.</info>'));
|
||||
|
||||
self::invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
}
|
||||
|
||||
public function testAddServerToNonEmptyList(): void {
|
||||
$this->input->method('getArgument')
|
||||
->willReturnCallback(function ($arg) {
|
||||
if ($arg === 'server') {
|
||||
return 'wss://signaling2.test.com';
|
||||
} elseif ($arg === 'secret') {
|
||||
return 'my-test-secret';
|
||||
}
|
||||
throw new \Exception();
|
||||
});
|
||||
$this->input->method('getOption')
|
||||
->with('verify')
|
||||
->willReturn(true);
|
||||
$this->config->expects($this->once())
|
||||
->method('getAppValue')
|
||||
->with('spreed', 'signaling_servers')
|
||||
->willReturn(json_encode([
|
||||
'servers' => [
|
||||
[
|
||||
'server' => 'wss://signaling1.test.com',
|
||||
'verify' => true
|
||||
]
|
||||
],
|
||||
'secret' => 'my-test-secret'
|
||||
]));
|
||||
$this->config->expects($this->once())
|
||||
->method('setAppValue')
|
||||
->with(
|
||||
$this->equalTo('spreed'),
|
||||
$this->equalTo('signaling_servers'),
|
||||
$this->equalTo(json_encode([
|
||||
'servers' => [
|
||||
[
|
||||
'server' => 'wss://signaling1.test.com',
|
||||
'verify' => true
|
||||
],
|
||||
[
|
||||
'server' => 'wss://signaling2.test.com',
|
||||
'verify' => true
|
||||
]
|
||||
],
|
||||
'secret' => 'my-test-secret'
|
||||
]))
|
||||
);
|
||||
$this->output->expects($this->once())
|
||||
->method('writeln')
|
||||
->with($this->equalTo('<info>Added signaling server wss://signaling2.test.com.</info>'));
|
||||
|
||||
self::invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
namespace OCA\Talk\Tests\php\Command\Signaling;
|
||||
|
||||
use OCA\Talk\Command\Signaling\Delete;
|
||||
use OCP\IConfig;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Test\TestCase;
|
||||
|
||||
class DeleteTest extends TestCase {
|
||||
protected IConfig&MockObject $config;
|
||||
protected InputInterface&MockObject $input;
|
||||
protected OutputInterface&MockObject $output;
|
||||
protected Delete $command;
|
||||
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->config = $this->createMock(IConfig::class);
|
||||
|
||||
$this->command = new Delete($this->config);
|
||||
|
||||
$this->input = $this->createMock(InputInterface::class);
|
||||
$this->output = $this->createMock(OutputInterface::class);
|
||||
}
|
||||
|
||||
public function testDeleteIfEmpty(): void {
|
||||
$this->input->method('getArgument')
|
||||
->with('server')
|
||||
->willReturn('wss://signaling.example.com');
|
||||
$this->config->expects($this->once())
|
||||
->method('getAppValue')
|
||||
->with('spreed', 'signaling_servers')
|
||||
->willReturn('');
|
||||
$this->config->expects($this->once())
|
||||
->method('setAppValue')
|
||||
->with(
|
||||
$this->equalTo('spreed'),
|
||||
$this->equalTo('signaling_servers'),
|
||||
$this->equalTo(json_encode([
|
||||
'servers' => [],
|
||||
'secret' => ''
|
||||
]))
|
||||
);
|
||||
$this->output->expects($this->once())
|
||||
->method('writeln')
|
||||
->with($this->equalTo('<info>There is nothing to delete.</info>'));
|
||||
|
||||
self::invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
}
|
||||
|
||||
public function testDelete(): void {
|
||||
$this->input->method('getArgument')
|
||||
->with('server')
|
||||
->willReturn('wss://signaling2.test.com');
|
||||
$this->config->expects($this->once())
|
||||
->method('getAppValue')
|
||||
->with('spreed', 'signaling_servers')
|
||||
->willReturn(json_encode([
|
||||
'servers' => [
|
||||
[
|
||||
'server' => 'wss://signaling1.test.com',
|
||||
'verify' => false,
|
||||
],
|
||||
[
|
||||
'server' => 'wss://signaling2.test.com',
|
||||
'verify' => false,
|
||||
],
|
||||
[
|
||||
'server' => 'wss://signaling3.test.com',
|
||||
'verify' => false,
|
||||
]
|
||||
],
|
||||
'secret' => 'my-test-secret',
|
||||
]));
|
||||
$this->config->expects($this->once())
|
||||
->method('setAppValue')
|
||||
->with(
|
||||
$this->equalTo('spreed'),
|
||||
$this->equalTo('signaling_servers'),
|
||||
$this->equalTo(json_encode([
|
||||
'servers' => [
|
||||
[
|
||||
'server' => 'wss://signaling1.test.com',
|
||||
'verify' => false,
|
||||
],
|
||||
[
|
||||
'server' => 'wss://signaling3.test.com',
|
||||
'verify' => false,
|
||||
]
|
||||
],
|
||||
'secret' => 'my-test-secret',
|
||||
]))
|
||||
);
|
||||
$this->output->expects($this->once())
|
||||
->method('writeln')
|
||||
->with($this->equalTo('<info>Deleted wss://signaling2.test.com.</info>'));
|
||||
|
||||
self::invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
}
|
||||
|
||||
public function testNothingToDelete(): void {
|
||||
$this->input->method('getArgument')
|
||||
->with('server')
|
||||
->willReturn('wss://signaling4.test.com');
|
||||
$this->config->expects($this->once())
|
||||
->method('getAppValue')
|
||||
->with('spreed', 'signaling_servers')
|
||||
->willReturn(json_encode([
|
||||
'servers' => [
|
||||
[
|
||||
'server' => 'wss://signaling1.test.com',
|
||||
'verify' => false,
|
||||
]
|
||||
],
|
||||
'secret' => 'my-test-secret',
|
||||
]));
|
||||
$this->config->expects($this->once())
|
||||
->method('setAppValue')
|
||||
->with(
|
||||
$this->equalTo('spreed'),
|
||||
$this->equalTo('signaling_servers'),
|
||||
$this->equalTo(json_encode([
|
||||
'servers' => [
|
||||
[
|
||||
'server' => 'wss://signaling1.test.com',
|
||||
'verify' => false,
|
||||
]
|
||||
],
|
||||
'secret' => 'my-test-secret',
|
||||
]))
|
||||
);
|
||||
$this->output->expects($this->once())
|
||||
->method('writeln')
|
||||
->with($this->equalTo('<info>There is nothing to delete.</info>'));
|
||||
|
||||
self::invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
namespace OCA\Talk\Tests\php\Command\Signaling;
|
||||
|
||||
use OCA\Talk\Command\Signaling\ListCommand;
|
||||
use OCP\IConfig;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Test\TestCase;
|
||||
|
||||
class ListCommandTest extends TestCase {
|
||||
protected IConfig&MockObject $config;
|
||||
protected InputInterface&MockObject $input;
|
||||
protected OutputInterface&MockObject $output;
|
||||
protected ListCommand&MockObject $command;
|
||||
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->config = $this->createMock(IConfig::class);
|
||||
|
||||
$this->command = $this->getMockBuilder(ListCommand::class)
|
||||
->setConstructorArgs([$this->config])
|
||||
->onlyMethods(['writeMixedInOutputFormat'])
|
||||
->getMock();
|
||||
|
||||
$this->input = $this->createMock(InputInterface::class);
|
||||
$this->output = $this->createMock(OutputInterface::class);
|
||||
}
|
||||
|
||||
public function testEmptyAppConfig(): void {
|
||||
$this->config->expects($this->once())
|
||||
->method('getAppValue')
|
||||
->with('spreed', 'signaling_servers')
|
||||
->willReturn(json_encode([]));
|
||||
|
||||
$this->command->expects($this->once())
|
||||
->method('writeMixedInOutputFormat')
|
||||
->with(
|
||||
$this->equalTo($this->input),
|
||||
$this->equalTo($this->output),
|
||||
$this->equalTo([])
|
||||
);
|
||||
|
||||
self::invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
}
|
||||
|
||||
public function testAppConfigDataChanges(): void {
|
||||
$this->config->expects($this->once())
|
||||
->method('getAppValue')
|
||||
->with('spreed', 'signaling_servers')
|
||||
->willReturn(json_encode([
|
||||
'servers' => [
|
||||
[
|
||||
'server' => 'wss://signaling.example.com',
|
||||
'verify' => true
|
||||
]
|
||||
],
|
||||
'secret' => 'my-test-secret'
|
||||
]));
|
||||
|
||||
$this->command->expects($this->once())
|
||||
->method('writeMixedInOutputFormat')
|
||||
->with(
|
||||
$this->equalTo($this->input),
|
||||
$this->equalTo($this->output),
|
||||
$this->equalTo([
|
||||
'servers' => [
|
||||
[
|
||||
'server' => 'wss://signaling.example.com',
|
||||
'verify' => true
|
||||
]
|
||||
],
|
||||
'secret' => 'my-test-secret'
|
||||
])
|
||||
);
|
||||
|
||||
self::invokePrivate($this->command, 'execute', [$this->input, $this->output]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user