NumberSalesByDateTest.php 1007 octets
Newer Older
<?php

use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpClient\HttpClient;

class NumberSalesByDateTest extends TestCase
{
    public function testGetRequest()
    {
Kévin Leroux's avatar
Kévin Leroux a validé
        // Create a client and send a GET request to the API
        $client = HttpClient::create();
        // create the get request
        $response = $client->request('GET', 'http://caddy/number_sales_by_date/day/2021-01-12/2021-12-31?page=1', [
            'headers' => ['accept' => 'application/ld+json']
        ]);
        // Assert that the response is successful
        $this->assertEquals(200, $response->getStatusCode());
        // Assert that the response is in JSON
        $this->assertStringContainsString('application/ld+json', $response->getHeaders()['content-type'][0]);
        // Assert that the response contains the expected properties
        $this->assertStringContainsString('date', $response->getContent());
        $this->assertStringContainsString('numberSales', $response->getContent());
Kévin Leroux's avatar
Kévin Leroux a validé
}
?>