1
0

PhpOutputBufferingTest.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\Settings\Tests;
  8. use OCA\Settings\SetupChecks\PhpOutputBuffering;
  9. use OCP\IL10N;
  10. use OCP\SetupCheck\SetupResult;
  11. use PHPUnit\Framework\MockObject\MockObject;
  12. use Test\TestCase;
  13. class PhpOutputBufferingTest extends TestCase {
  14. /** @var IL10N|MockObject */
  15. private $l10n;
  16. protected function setUp(): void {
  17. parent::setUp();
  18. $this->l10n = $this->getMockBuilder(IL10N::class)
  19. ->disableOriginalConstructor()->getMock();
  20. $this->l10n->expects($this->any())
  21. ->method('t')
  22. ->willReturnCallback(function ($message, array $replace) {
  23. return vsprintf($message, $replace);
  24. });
  25. }
  26. /*
  27. * output_buffer is PHP_INI_PERDIR and cannot changed at runtime.
  28. * Run this test with -d output_buffering=1 to validate the fail case.
  29. */
  30. public function testPass(): void {
  31. $check = new PhpOutputBuffering($this->l10n);
  32. $this->assertEquals(SetupResult::SUCCESS, $check->run()->getSeverity());
  33. }
  34. }