PHP Classes

File: tests/Repository/SessionPostRepositoryTest.php

Recommend this page to a friend!
  Classes of Kacper Rowinski   OneClickCaptcha   tests/Repository/SessionPostRepositoryTest.php   Download  
File: tests/Repository/SessionPostRepositoryTest.php
Role: Unit test script
Content type: text/plain
Description: Unit test script
Class: OneClickCaptcha
CAPTCHA validation based on user clicks on circles
Author: By
Last change: Update of tests/Repository/SessionPostRepositoryTest.php
Date: 6 months ago
Size: 1,703 bytes
 

Contents

Class file image Download
<?php
declare(strict_types=1);

use
OneClickCaptcha\Repository\SessionStorageInterfaceRepository;
use
PHPUnit\Framework\TestCase;

/**
 * Class SessionPostRepositoryTest
 */
class SessionPostRepositoryTest extends TestCase
{
   
/**
     * @var SessionStorageInterfaceRepository
     */
   
private $sessionPostRepository;

    public function
setUp()
    {
       
$this->sessionPostRepository = new SessionStorageInterfaceRepository();
    }

   
/**
     * @test
     */
   
public function shouldStartSession(): void
   
{
       
$this->assertEquals(PHP_SESSION_ACTIVE, session_status());
    }

   
/**
     * @test
     */
   
public function shouldSave(): void
   
{
       
$this->sessionPostRepository->save(1, 2, 3);

       
$this->assertEquals(1, $this->sessionPostRepository->get(SessionStorageInterfaceRepository::POSITION_X));
       
$this->assertEquals(2, $this->sessionPostRepository->get(SessionStorageInterfaceRepository::POSITION_Y));
       
$this->assertEquals(3, $this->sessionPostRepository->get(SessionStorageInterfaceRepository::RADIUS));
    }

   
/**
     * @test
     */
   
public function shouldSaveLastRequest(): void
   
{
       
$this->sessionPostRepository->saveLastRequest(2, 3);

       
$this->assertEquals(
            [
SessionStorageInterfaceRepository::POSITION_X => 2, SessionStorageInterfaceRepository::POSITION_Y => 3],
           
$this->sessionPostRepository->get(SessionStorageInterfaceRepository::LAST_REQUEST)
        );
    }

   
/**
     * @test
     */
   
public function shouldGetNULL(): void
   
{
       
$this->assertEquals(null, $this->sessionPostRepository->get('foo'));
    }
}