Skip to content

Commit

Permalink
Add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
shochdoerfer committed Jun 19, 2021
1 parent 884c1f3 commit 12c6d82
Showing 1 changed file with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,54 @@ public function throwsExceptionForUnknownMethodNames(): void

$this->extension->getMethod($this->classReflection, 'someOtherMethod');
}

/**
* @test
* @dataProvider isMethodSupportedDataprovider
* @param string $method
* @param bool $expectedResult
*/
public function hasMethodDetectsDataObjectClass(string $method, bool $expectedResult): void
{
$this->classReflection->expects(self::once())
->method('getParentClassesNames')
->willReturn([]);
$this->classReflection->expects(self::once())
->method('getName')
->willReturn('Magento\Framework\DataObject');

self::assertSame($expectedResult, $this->extension->hasMethod($this->classReflection, $method));
}

/**
* @test
* @dataProvider isMethodSupportedDataprovider
* @param string $method
* @param bool $expectedResult
*/
public function hasMethodDetectsDataObjectParentClass(string $method, bool $expectedResult): void
{
$this->classReflection->expects(self::once())
->method('getParentClassesNames')
->willReturn(['Magento\Framework\DataObject']);
$this->classReflection->expects(self::once())
->method('getName')
->willReturn('Magento\Framework\Shell\Response');

self::assertSame($expectedResult, $this->extension->hasMethod($this->classReflection, $method));
}

/**
* @return mixed[]
*/
public function isMethodSupportedDataprovider(): array
{
return [
['getTest', true],
['setTest', true],
['unsetTest', true],
['hasText', true],
['someOtherMethod', false],
];
}
}

0 comments on commit 12c6d82

Please sign in to comment.