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', 'turn_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', 'turn_servers') ->willReturn(json_encode([ [ 'server' => 'turn1.test.com', 'secret' => 'my-sercret-1', 'protocols' => 'tcp', ], [ 'server' => 'turn2.test.com', 'secret' => 'my-sercret-2', 'protocols' => 'udp,tcp', ], ])); $this->command->expects($this->once()) ->method('writeMixedInOutputFormat') ->with( $this->equalTo($this->input), $this->equalTo($this->output), $this->equalTo([ [ 'server' => 'turn1.test.com', 'secret' => 'my-sercret-1', 'protocols' => 'tcp', ], [ 'server' => 'turn2.test.com', 'secret' => 'my-sercret-2', 'protocols' => 'udp,tcp', ], ]) ); self::invokePrivate($this->command, 'execute', [$this->input, $this->output]); } }