Skip to content

Commit

Permalink
First pass at implementing unit testing
Browse files Browse the repository at this point in the history
  • Loading branch information
ericsizemore committed Dec 24, 2023
1 parent 5ad4bf9 commit e6d4cad
Show file tree
Hide file tree
Showing 7 changed files with 2,043 additions and 25 deletions.
26 changes: 14 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ require 'vendor/autoload.php';

LibrariesIO splits the different endpoints based on their "component":

* Esi\LibrariesIO\Platform
* Platform::makeRequest() does not require an $endpoint, though you can pass 'platforms'.
* Esi\LibrariesIO\Project
* Project::makeRequest() takes an 'endpoint' parameter to specify which subset you are looking for.
* Esi\LibrariesIO\LibrariesIO::platform()
* does not require an $endpoint, though you can pass 'platforms'.
* Esi\LibrariesIO\LibrariesIO::project()
* takes an 'endpoint' parameter to specify which subset you are looking for.
* Current endpoints are:
* contributors
* dependencies
Expand All @@ -45,14 +45,14 @@ LibrariesIO splits the different endpoints based on their "component":
* project
* search
* sourceRank
* Esi\LibrariesIO\Repository
* Repository::makeRequest() takes an 'endpoint' parameter to specify which subset you are looking for.
* Esi\LibrariesIO\LibrariesIO::repository()
* takes an 'endpoint' parameter to specify which subset you are looking for.
* Current endpoints are:
* dependencies
* projects
* repository
* Esi\LibrariesIO\User
* User::makeRequest() takes an 'endpoint' parameter to specify which subset you are looking for.
* Esi\LibrariesIO\LibrariesIO::user()
* takes an 'endpoint' parameter to specify which subset you are looking for.
* Current endpoints are:
* dependencies
* packages
Expand All @@ -69,10 +69,10 @@ As an example, let's say you want to get a list of the available platforms. To d
```php
<?php

use Esi\LibrariesIO\Platform;
use Esi\LibrariesIO\LibrariesIO;

$api = new Platform('..yourapikey..', \sys_get_temp_dir());
$response = $api->makeRequest();
$api = new LibrariesIO('..yourapikey..', \sys_get_temp_dir());
$response = $api->platform();

print_r($api->toArray($response));

Expand Down Expand Up @@ -104,7 +104,9 @@ Array

## Testing

Unit testing is not yet implemented, but will be in a future release via PHPUnit.
Unit testing is handled by PHPUnit. Given the nature of this library, with it's purpose being to interact with a live API, testing is somewhat limited.

No actual calls are made to the libraries.io API while performing tests. Instead, mock data and mocked class instances are used to test the library is working properly.

## Documentation

Expand Down
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
},
"require-dev": {
"phpstan/phpstan": "^1.11",
"phpstan/phpstan-strict-rules": "^1.6"
"phpstan/phpstan-strict-rules": "^1.6",
"phpunit/phpunit": "^10.5",
"phpstan/phpstan-phpunit": "^1.4"
},
"autoload": {
"psr-4": { "Esi\\LibrariesIO\\": "src/" }
Expand All @@ -38,6 +40,7 @@
"security": "https://github.com/ericsizemore/librariesio/security/policy"
},
"scripts": {
"test": "vendor/bin/phpunit --coverage-clover=build/logs/clover.xml --coverage-html=build/logs/coverage --display-deprecations --display-warnings --globals-backup",
"phpstan": "vendor/bin/phpstan analyse -c phpstan.neon"
},
"minimum-stability": "dev",
Expand Down
Loading

0 comments on commit e6d4cad

Please sign in to comment.