OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
firebase
/
vendor
/
ramsey
/
collection
/
tests
/
Tool
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
08/12/2024 10:34:29 AM
rwxr-xr-x
📁
Mock
-
08/12/2024 10:36:07 AM
rwxr-xr-x
📄
ValueExtractorTraitTest.php
2.38 KB
08/12/2024 10:34:29 AM
rw-r--r--
📄
ValueToStringTraitTest.php
3.21 KB
08/12/2024 10:34:29 AM
rw-r--r--
Editing: ValueExtractorTraitTest.php
Close
<?php declare(strict_types=1); namespace Ramsey\Collection\Test\Tool; use Ramsey\Collection\Exception\InvalidPropertyOrMethod; use Ramsey\Collection\Test\TestCase; use Ramsey\Collection\Tool\ValueExtractorTrait; /** * Cover up all possible outcomes of the ValueExtractorTrait. */ class ValueExtractorTraitTest extends TestCase { public function testShouldRaiseExceptionWhenPropertyOrMethodNotExist(): void { $test = new class { use ValueExtractorTrait; /** * @return mixed */ public function __invoke(string $propertyOrMethod) { return $this->extractValue($this, $propertyOrMethod); } public function getType(): string { return 'foo'; } }; $this->expectException(InvalidPropertyOrMethod::class); $this->expectExceptionMessage('Method or property "undefinedMethod" not defined in'); $test('undefinedMethod'); } public function testShouldExtractValueByMethod(): void { $test = new class { use ValueExtractorTrait; /** * @return mixed */ public function __invoke(string $propertyOrMethod) { return $this->extractValue($this, $propertyOrMethod); } public function testMethod(): string { return 'works!'; } public function getType(): string { return 'bar'; } }; $this->assertSame('works!', $test('testMethod'), 'Could not extract value by method'); } public function testShouldExtractValueByProperty(): void { $test = new class { use ValueExtractorTrait; public string $testProperty = 'works!'; /** * @return mixed */ public function __invoke(string $propertyOrMethod) { return $this->extractValue($this, $propertyOrMethod); } public function getType(): string { return 'baz'; } }; $this->assertSame('works!', $test('testProperty'), 'Could not extract value by property'); } }