<commit_before><?php

namespace Wilson\tests;

use GuzzleHttp\Client;
use PHPUnit_Framework_TestCase;

class UserControllerTest extends PHPUnit_Framework_TestCase
{
    protected $client;
    protected $token;

    public function setup()
    {
        $this->client = new Client(['base_uri' => 'http://checkpoint3.app']);

        $response = $this->client->post('/auth/login', ['query' => ['username' => 'Wil', 'password' => 'password']]);

        $this->token = json_decode($response->getBody());
    }

    public function testRegister()
    {
        $response = $this->client->post('/register', [
            'query' => [
                'username' => 'testuser',
                'password' => '<PASSWORD>',
                'name' => '<NAME>'
            ]
        ]);

        $expected = "User registration successful.";
        $actual = json_decode($response->getBody());

        $this->assertEquals($expected, $actual);
    }

    public function testLogin()
    {
        $response = $this->client->post('/auth/login', ['query' => ['username' => 'Wil', 'password' => 'password']]);

        $returnedValue = json_decode($response->getBody());

        $this->assertInternalType('string', $returnedValue);
        $this->assertEquals('200', $response->getStatusCode());
    }

    public function testLogout()
    {
        $response = $this->client->get('/auth/logout', ['headers' => ['Authorization' => $this->token]]);

        $expected = "You've logged out successfully.";
        $actual = json_decode($response->getBody());

        $this->assertEquals($expected, $actual);
    }
}<commit_msg>(feature) Comment tests in UserControllerTest.php<commit_after><?php

namespace Wilson\tests;

use GuzzleHttp\Client;
use PHPUnit_Framework_TestCase;

class UserControllerTest extends PHPUnit_Framework_TestCase
{
    protected $client;
    protected $token;

    public function setup()
    {
        $this->client = new Client(['base_uri' => 'http://checkpoint3.app']);

        $response = $this->client->post('/auth/login', ['query' => ['username' => 'Wil', 'password' => 'password']]);

        $this->token = json_decode($response->getBody());
    }

    /**
     * Test if a user can actually be registered or not
     */
    public function testRegister()
    {
        $response = $this->client->post('/register', [
            'query' => [
                'username' => 'testuser',
                'password' => '<PASSWORD>',
                'name' => '<NAME>'
            ]
        ]);

        $expected = "User registration successful.";
        $actual = json_decode($response->getBody());

        $this->assertEquals($expected, $actual);
    }

    /**
     * Test login module, and that a token is actually returned upon successful user login
     */
    public function testLogin()
    {
        $response = $this->client->post('/auth/login', ['query' => ['username' => 'Wil', 'password' => 'password']]);

        $this->assertInternalType('string', json_decode($response->getBody()));
        $this->assertEquals('200', $response->getStatusCode());
    }

    /**
     * Test logout functionality
     */
    public function testLogout()
    {
        $response = $this->client->get('/auth/logout', ['headers' => ['Authorization' => $this->token]]);

        $expected = "You've logged out successfully.";
        $actual = json_decode($response->getBody());

        $this->assertEquals($expected, $actual);
    }
}
{'fraction_non_alphanumeric': 0.1769141531322506, 'fraction_numerical': 0.002320185614849188, 'mean_word_length': 2.7086021505376343, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 73, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '943002', 'n_tokens_mistral': 963, 'n_tokens_neox': 928, 'n_words': 197}