-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add build and update in ForceExecutionHelper
- Loading branch information
1 parent
d22d3d6
commit 132fc75
Showing
3 changed files
with
86 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace PHPSTORM_META; | ||
|
||
use RichCongress\TestTools\Helper\ForceExecutionHelper; | ||
|
||
override( | ||
ForceExecutionHelper::build(0), | ||
type(0) | ||
); | ||
|
||
override( | ||
ForceExecutionHelper::update(0), | ||
type(0) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,14 +13,16 @@ | |
* @author Nicolas Guilloux <[email protected]> | ||
* @copyright 2014 - 2020 RichCongress (https://www.richcongress.com) | ||
* | ||
* @covers \RichCongress\TestTools\Helper\ForceExecutionHelper | ||
* @covers \RichCongress\TestTools\Helper\ForceExecutionHelper | ||
*/ | ||
class ForceExecutionHelperTest extends TestCase | ||
{ | ||
public function testCannotInstanciateHelper(): void | ||
{ | ||
$this->expectException(\Error::class); | ||
$this->expectExceptionMessage('Call to private RichCongress\TestTools\Helper\ForceExecutionHelper::__construct()'); | ||
$this->expectExceptionMessage( | ||
'Call to private RichCongress\TestTools\Helper\ForceExecutionHelper::__construct()' | ||
); | ||
|
||
new ForceExecutionHelper(); | ||
} | ||
|
@@ -37,7 +39,9 @@ public function testExecuteMethod(): void | |
public function testExecuteMethodWithBadObject(): void | ||
{ | ||
$this->expectException(\LogicException::class); | ||
$this->expectExceptionMessage('Cannot call a non static method without the instanciated object for ' . DummyEntity::class); | ||
$this->expectExceptionMessage( | ||
'Cannot call a non static method without the instanciated object for ' . DummyEntity::class | ||
); | ||
|
||
ForceExecutionHelper::executeMethod(DummyEntity::class, 'setName', 'ThisIsATest'); | ||
} | ||
|
@@ -68,7 +72,9 @@ public function testSetValue(): void | |
public function testSetValueWithBadObject(): void | ||
{ | ||
$this->expectException(\LogicException::class); | ||
$this->expectExceptionMessage('Cannot call a non static property without the instanciated object for ' . DummyEntity::class); | ||
$this->expectExceptionMessage( | ||
'Cannot call a non static property without the instanciated object for ' . DummyEntity::class | ||
); | ||
|
||
ForceExecutionHelper::setValue(DummyEntity::class, 'name', 'ThisIsATest'); | ||
} | ||
|
@@ -95,4 +101,35 @@ public function testWithBadObjectType(): void | |
|
||
ForceExecutionHelper::setValue(0.1, 'staticName', 'ThisIsATest'); | ||
} | ||
|
||
public function testBuild(): void | ||
{ | ||
$object = ForceExecutionHelper::build( | ||
DummyEntity::class, | ||
[ | ||
'name' => 'ThisIsATest', | ||
'keyname' => 'KeyName', | ||
] | ||
); | ||
|
||
self::assertInstanceOf(DummyEntity::class, $object); | ||
self::assertSame('ThisIsATest', $object->getName()); | ||
self::assertSame('KeyName', $object->getKeyname()); | ||
} | ||
|
||
public function testUpdate(): void | ||
{ | ||
$object = new DummyEntity(); | ||
$result = ForceExecutionHelper::update( | ||
$object, | ||
[ | ||
'name' => 'ThisIsATest', | ||
'keyname' => 'KeyName', | ||
] | ||
); | ||
|
||
self::assertSame($object, $result); | ||
self::assertSame('ThisIsATest', $object->getName()); | ||
self::assertSame('KeyName', $object->getKeyname()); | ||
} | ||
} |