diff --git a/Tests/ApiTestCase.php b/Tests/ApiTestCase.php new file mode 100644 index 0000000..2657f16 --- /dev/null +++ b/Tests/ApiTestCase.php @@ -0,0 +1,60 @@ +getMethod($methodName); + $method->setAccessible(true); + return $method->invokeArgs($object, $arguments); + } + + /** + * Sets a private or protected property in defined class instance + * + * @param object $object + * @param string $valueName + * @param $value + * @throws ReflectionException + */ + public function setValue(object $object, string $valueName, $value) + { + $reflection = new ReflectionClass($object); + $property = $reflection->getProperty($valueName); + $property->setAccessible(true); + $property->setValue($object, $value); + } + + /** + * get a private or protected property from defined class instance + * + * @param object $object + * @param string $valueName + * @return mixed + * @throws ReflectionException + */ + public function getValue(object $object, string $valueName): mixed + { + $reflection = new ReflectionClass($object); + $property = $reflection->getProperty($valueName); + $property->setAccessible(true); + return $property->getValue($object); + } +} diff --git a/Tests/ClientTest.php b/Tests/ClientTest.php new file mode 100644 index 0000000..c92ceda --- /dev/null +++ b/Tests/ClientTest.php @@ -0,0 +1,28 @@ +api = new Client($this->fixtureApiKey); + } + + /** + * @test + */ + public function testRun() + { + $this->assertTrue(true); + } +} diff --git a/Tests/README.md b/Tests/README.md new file mode 100644 index 0000000..656b7db --- /dev/null +++ b/Tests/README.md @@ -0,0 +1,11 @@ +# Installation + +``` +composer create-project -s dev --prefer-source --repository="{\"url\": \"gitfhfac@git.d3data.de:D3Private/linkmobility-php-client.git\", \"type\": \"vcs\"}" d3/linkmobility-php-client . +``` + +# Run tests + +``` +./vendor/bin/phpunit [--no-coverage] +``` diff --git a/composer.json b/composer.json index e23b90a..9131273 100644 --- a/composer.json +++ b/composer.json @@ -28,12 +28,14 @@ "ext-json": "*" }, "require-dev": { - "phpunit/phpunit" : "~5.7||~6.0", + "php": "^7.2", + "phpunit/phpunit" : "^8.0", "friendsofphp/php-cs-fixer": "^2.0" }, "autoload": { "psr-4": { - "D3\\LinkmobilityClient\\": "src" + "D3\\LinkmobilityClient\\": "src", + "D3\\LinkmobilityClient\\Tests\\": "Tests" } }, "scripts": { diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..14a145c --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,22 @@ + + + + + ./Tests + + + + + src + + + + + + + +