PHP code example of deozza / philarmony-api-tester-bundle

1. Go to this page and download the library: Download deozza/philarmony-api-tester-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

deozza / philarmony-api-tester-bundle example snippets



namespace App\Tests\FooFeature;

use Deozza\PhilarmonyApiTester\Service\TestAsserter;

class FooControllerTest extends TestAsserter
{
    const TEST_DATABASE_PATH = __DIR__."/path/to/db.sql";
  public function setUp()
  {
      parent::setTestDatabasePath(self::TEST_DATABASE_PATH);
      parent::setUp();
  }

  /**
  * @dataProvider addDataProvider
  */
  public function testUnit($kind, $test)
  {
    parent::launchTestByKind($kind, $test);
  }

  public function addDataProvider()
  {
      return [];
  }
}



public function addDataProvider()
  {
      return
      [
        ["kind" => "unit", "test" => ['method'=> 'GET'   , 'url' => 'api/foos'                                    , 'status' => 200, 'out' => 'getAllFoos'] ],
        ["kind" => "unit", "test" => ['method'=> 'POST'  , 'url' => 'api/foos'                                    , 'token' => 'token_user', 'status' => 201, 'in' => 'postValidFoo' , 'out' => 'postedFoo'] ],
        ["kind" => "unit", "test" => ['method'=> 'PATCH' , 'url' => 'api/foo/00400000-0000-5000-a000-000000000000', 'token' => 'token_user', 'status' => 200, 'in' => 'patchValidFoo', 'out' => 'patchedFoo'] ],
        ["kind" => "unit", "test" => ['method'=> 'PUT'   , 'url' => 'api/foo/00400000-0000-5000-a000-000000000000', 'token' => 'token_user', 'status' => 405] ],
        ["kind" => "unit", "test" => ['method'=> 'DELETE', 'url' => 'api/foo/00400000-0000-5000-a000-000000000000', 'token' => 'token_user', 'status' => 204] ],
      ];
  }