kaingnx / visible-unit
Simplified unit testing on non-visible properties and methods.
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Type:phpunit
Requires
- php: >=5.6.0
- phpunit/phpunit: ^5.7.14|^6.0
Requires (Dev)
- phpunit/phpunit: ^5.7.14|^6.0
This package is auto-updated.
Last update: 2024-05-09 06:00:49 UTC
README
Simplified unit testing on non-visible properties and methods. This repository is intended for development use only, since its main purpose is to bypass class visibility in unit testing.
Usage
Run composer require --dev kaingnx/visible-unit
Unit Testing
// src/Your/Path/ExampleUnitTest.php namespace Your\Namespace\Test; use VisibleUnit\Reflections\BaseReflection; use Your\Namespace\YourObject; class ExampleUnitTest { /** * Set Up * * @return void */ public function setUp() { $this->yourObject = new YourObject(); $this->mockReflection = new BaseReflection($this->yourObject); } /** * Test Example Prop and Method * * @return void */ public function testExamplePropAndMethod() { $this->mockReflection->invokeMethod('privateOrProtectedMethod'); $privateOrProtectedProp = $this->mockReflection->getPropValue('privateOrProtectedProp'); } }
More Info
See source of:
src/Reflections/BaseReflection.php
tests/TestCase/Reflections/BaseReflectionTest.php
tests/TestClass/MockAccessObject.php