Skip to content
Snippets Groups Projects
Commit 356fd31a authored by Tim Rohaly's avatar Tim Rohaly
Browse files

Merge branch '3457486-phpstan-call-to' into '4.0.x'

Issue #3457486 by TR: Phpstan: Call to deprecated method getMockForAbstractClass()

See merge request !42
parents 197a1494 1714bbc5
No related branches found
No related tags found
No related merge requests found
Pipeline #254418 failed
......@@ -39,7 +39,7 @@ class RulesAdminAccessTest extends RulesIntegrationTestBase {
$action = $this->getMockBuilder(RulesActionBase::class)
->disableOriginalConstructor()
->onlyMethods(['getPluginDefinition'])
->getMockForAbstractClass();
->getMock();
$action
->expects($this->exactly(2))
......
......@@ -23,10 +23,7 @@ class RulesActionBaseTest extends RulesUnitTestBase {
// Set the expected exception class. There is no message to check for.
$this->expectException(InvalidPluginDefinitionException::class);
$rules_action_base = $this->getMockForAbstractClass(
RulesActionBase::class,
[[], '', '']
);
$rules_action_base = new RulesActionBaseTestStub([], '', '');
$rules_action_base->summary();
}
......@@ -36,10 +33,7 @@ class RulesActionBaseTest extends RulesUnitTestBase {
* @covers ::summary
*/
public function testSummaryParsingTheLabelAnnotation(): void {
$rules_action_base = $this->getMockForAbstractClass(
RulesActionBase::class,
[[], '', ['label' => 'something']]
);
$rules_action_base = new RulesActionBaseTestStub([], '', ['label' => 'something']);
$this->assertEquals('something', $rules_action_base->summary());
}
......@@ -51,11 +45,15 @@ class RulesActionBaseTest extends RulesUnitTestBase {
public function testTranslatedLabel(): void {
$translation_wrapper = $this->prophesize(TranslatableMarkup::class);
$translation_wrapper->__toString()->willReturn('something');
$rules_action_base = $this->getMockForAbstractClass(
RulesActionBase::class,
[[], '', ['label' => $translation_wrapper->reveal()]]
);
$rules_action_base = new RulesActionBaseTestStub([], '', ['label' => $translation_wrapper->reveal()]);
$this->assertEquals('something', $rules_action_base->summary());
}
}
/**
* Class providing a concrete class extending RulesActionBase.
*/
class RulesActionBaseTestStub extends RulesActionBase {
}
<?php
declare(strict_types=1);
namespace Drupal\Tests\rules\Unit;
use Drupal\Core\Logger\LoggerChannelInterface;
......@@ -17,51 +15,19 @@ use Drupal\rules\Engine\ExpressionManagerInterface;
class RulesConditionContainerTest extends RulesUnitTestBase {
/**
* Creates a mocked condition container.
*
* @param array $methods
* The methods to mock.
* @param string $class
* The name of the created mock class.
* Tests negating the result of the condition container.
*
* @return \Drupal\rules\Engine\ConditionExpressionContainerInterface
* The mocked condition container.
* @covers ::negate
* @covers ::isNegated
*/
protected function getMockConditionContainer(array $methods = [], string $class = 'RulesConditionContainerMock'): ConditionExpressionContainerInterface {
return $this->getMockForAbstractClass(
ConditionExpressionContainer::class, [
public function testNegate(): void {
$container = new RulesConditionContainerTestStub([
[],
'test_id',
[],
$this->prophesize(ExpressionManagerInterface::class)->reveal(),
$this->prophesize(LoggerChannelInterface::class)->reveal(),
], $class, TRUE, TRUE, TRUE, $methods
);
}
/**
* Tests adding conditions to the condition container.
*
* @covers ::addExpressionObject
*/
public function testAddExpressionObject(): void {
$container = $this->getMockConditionContainer();
$container->addExpressionObject($this->trueConditionExpression->reveal());
$property = new \ReflectionProperty($container, 'conditions');
$property->setAccessible(TRUE);
$this->assertEquals([$this->trueConditionExpression->reveal()], array_values($property->getValue($container)));
}
/**
* Tests negating the result of the condition container.
*
* @covers ::negate
* @covers ::isNegated
*/
public function testNegate(): void {
$container = $this->getMockForAbstractClass(RulesConditionContainerTestStub::class, [], '', FALSE);
]);
$this->assertFalse($container->isNegated());
$this->assertTrue($container->execute());
......@@ -83,6 +49,8 @@ class RulesConditionContainerTest extends RulesUnitTestBase {
/**
* Tests that an expression can be retrieved by UUID.
*
* @covers ::getExpression
*/
public function testLookupExpression(): void {
$container = $this->getMockForAbstractClass(RulesConditionContainerTestStub::class, [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment