DocRootLocatorTest.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\App\Test\Unit;
  7. use Magento\Framework\App\DocRootLocator;
  8. class DocRootLocatorTest extends \PHPUnit\Framework\TestCase
  9. {
  10. /**
  11. * @dataProvider isPubDataProvider
  12. *
  13. * @param string $path
  14. * @param bool $isExist
  15. * @param bool $result
  16. */
  17. public function testIsPub($path, $isExist, $result)
  18. {
  19. $request = $this->createMock(\Magento\Framework\App\Request\Http::class);
  20. $request->expects($this->once())->method('getServer')->willReturn($path);
  21. $reader = $this->createMock(\Magento\Framework\Filesystem\Directory\Read::class);
  22. $reader->expects($this->any())->method('isExist')->willReturn($isExist);
  23. $readFactory = $this->createMock(\Magento\Framework\Filesystem\Directory\ReadFactory::class);
  24. $readFactory->expects($this->once())->method('create')->willReturn($reader);
  25. $model = new DocRootLocator($request, $readFactory);
  26. $this->assertSame($result, $model->isPub());
  27. }
  28. /**
  29. * @return array
  30. */
  31. public function isPubDataProvider()
  32. {
  33. return [
  34. ['/some/path/to/root', false, false],
  35. ['/some/path/to/root', true, false],
  36. ['/some/path/to/pub', false, true],
  37. ['/some/path/to/pub', true, false],
  38. ];
  39. }
  40. }