PHP code example of wondernetwork / slim-kernel-testing-harness

1. Go to this page and download the library: Download wondernetwork/slim-kernel-testing-harness 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/ */

    

wondernetwork / slim-kernel-testing-harness example snippets


use WonderNetwork\SlimKernelTestingHarness\KernelHttpClient as Core;
$httpClient = Core\SlimKernelHttpClient::create($slimApp);

class AdminUseCasesFacade {
    use KernelHttpClientUseCase;
    
    public function listOrders(): OrderListAssertion {
        return OrderListAssertion::ofJsonResponse(
            $this->httpClient->json()->get('/api/v1/orders')
        );
    }
}

class CustomerUseCasesFacade {
    use KernelHttpClientUseCase;
    
    public function makeOrder(string $productId): void {
        return $this->httpClient->post('/api/v1/orders', ['product' => $productId]);
    }
}


CustomerUseCasesFacade
  ::of($httpClient)
  ->expectFailure()
  ->makeOrder($invalidProductId)

class OrderListAssertion {
    use JsonListResponseAssertion;
    
    public function first(): OrderItemAssertion {
        return new OrderItemAssertion($this->items->getFirstItemData());
    }
}