Skip to content
Snippets Groups Projects
Select Git revision
  • 82f58077ae16363ea9ee650936eb053df4cda712
  • main default protected
  • renovate/lock-file-maintenance
  • demo protected
  • person-select-custom
  • dbp-translation-component
  • icon-set-mapping
  • port-i18next-parser
  • remove-sentry
  • favorites-and-recent-files
  • revert-6c632dc6
  • lit2
  • advertisement
  • wc-part
  • automagic
  • publish
  • wip-cleanup
  • demo-file-handling
18 results

i18next-scanner.config.js

Blame
  • ApiTest.php 1.94 KiB
    <?php
    
    declare(strict_types=1);
    
    namespace Dbp\Relay\ExampleBundle\Tests;
    
    use ApiPlatform\Core\Bridge\Symfony\Bundle\Test\ApiTestCase;
    use Symfony\Component\HttpFoundation\Response;
    
    class ApiTest extends ApiTestCase
    {
        /**
         * You can test some basic api functionality here.
         *
         * @return void
         *
         * @throws \Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface
         * @throws \Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface
         * @throws \Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface
         * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface
         */
        public function testBasics()
        {
            $client = self::createClient();
            $response = $client->request('GET', '/example/places');
            $this->assertSame(Response::HTTP_OK, $response->getStatusCode());
    
            $response = $client->request('GET', '/example/places/graz');
            $this->assertSame(Response::HTTP_OK, $response->getStatusCode());
    
            $response = $client->request('DELETE', '/example/places/graz');
            $this->assertSame(Response::HTTP_NO_CONTENT, $response->getStatusCode());
    
            $response = $client->request('PUT', '/example/places/graz', [
                'headers' => [
                    'Content-Type' => 'application/json',
                ],
                'body' => json_encode(['name' => 'foo']),
            ]);
            $this->assertSame(Response::HTTP_OK, $response->getStatusCode());
            $this->assertSame('foo', json_decode($response->getContent(), true)['name']);
        }
    
        /**
         * Test if you can access the api without a user.
         *
         * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface
         */
        public function testNoAuth()
        {
            $client = self::createClient();
            $response = $client->request('GET', '/example/places/graz/loggedin-only');
            $this->assertSame(Response::HTTP_UNAUTHORIZED, $response->getStatusCode());
        }
    }