Verified Commit d275b6f1 authored by Dave Long's avatar Dave Long
Browse files

test: #3569426 Convert expectation-less test mocks to stubs - Package Manager module

By: dcam
By: smustgrave
parent 014cc526
Loading
Loading
Loading
Loading
Loading
+2 −1
Changes for core/modules/package_manager/tests/src/Unit/EventWithPackageListTraitTest.php: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
namespace Drupal\Tests\package_manager\Unit;

use Drupal\package_manager\Event\EventWithPackageListTrait;
use Drupal\package_manager\SandboxManagerBase;
use Drupal\Tests\UnitTestCase;
use PHPUnit\Framework\Attributes\CoversTrait;
use PHPUnit\Framework\Attributes\DataProvider;
@@ -34,7 +35,7 @@ class EventWithPackageListTraitTest extends UnitTestCase {
   */
  #[DataProvider('providerGetPackages')]
  public function testGetPackages(array $runtime_packages, array $dev_packages, array $expected_runtime_packages, array $expected_dev_packages): void {
    $stage = $this->createMock('\Drupal\package_manager\SandboxManagerBase');
    $stage = $this->createStub(SandboxManagerBase::class);

    $events = [
      '\Drupal\package_manager\Event\PostRequireEvent',
+3 −3
Changes for core/modules/package_manager/tests/src/Unit/LoggingBeginnerTest.php: 3 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -27,9 +27,9 @@ class LoggingBeginnerTest extends UnitTestCase {
  public function testDecoratedBeginnerIsCalled(): void {
    $decorated = $this->createMock(BeginnerInterface::class);

    $activeDir = $this->createMock(PathInterface::class);
    $stagingDir = $this->createMock(PathInterface::class);
    $stagingDir->expects($this->any())
    $activeDir = $this->createStub(PathInterface::class);
    $stagingDir = $this->createStub(PathInterface::class);
    $stagingDir
      ->method('absolute')
      ->willReturn('staging-dir');

+4 −4
Changes for core/modules/package_manager/tests/src/Unit/LoggingCommitterTest.php: 4 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -27,12 +27,12 @@ class LoggingCommitterTest extends UnitTestCase {
  public function testDecoratedCommitterIsCalled(): void {
    $decorated = $this->createMock(CommitterInterface::class);

    $stagingDir = $this->createMock(PathInterface::class);
    $stagingDir->expects($this->any())
    $stagingDir = $this->createStub(PathInterface::class);
    $stagingDir
      ->method('absolute')
      ->willReturn('staging-dir');
    $activeDir = $this->createMock(PathInterface::class);
    $activeDir->expects($this->any())
    $activeDir = $this->createStub(PathInterface::class);
    $activeDir
      ->method('absolute')
      ->willReturn('active-dir');

+3 −3
Changes for core/modules/package_manager/tests/src/Unit/LoggingStagerTest.php: 3 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -27,9 +27,9 @@ class LoggingStagerTest extends UnitTestCase {
  public function testDecoratedStagerIsCalled(): void {
    $decorated = $this->createMock(StagerInterface::class);

    $activeDir = $this->createMock(PathInterface::class);
    $stagingDir = $this->createMock(PathInterface::class);
    $stagingDir->expects($this->any())
    $activeDir = $this->createStub(PathInterface::class);
    $stagingDir = $this->createStub(PathInterface::class);
    $stagingDir
      ->method('absolute')
      ->willReturn('staging-dir');

+1 −1
Changes for core/modules/package_manager/tests/src/Unit/PathLocatorTest.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -122,7 +122,7 @@ public function testWebRoot(string $app_root, string $project_root, string $expe
      ])
      ->getMock();

    $path_locator->method('getProjectRoot')->willReturn($project_root);
    $path_locator->expects($this->atLeastOnce())->method('getProjectRoot')->willReturn($project_root);
    $this->assertSame($expected_web_root, $path_locator->getWebRoot());
  }

Loading