<commit_before><?php
namespace Hyperspan\Tests;
use Hyperspan\Response;
use Hyperspan\Formatter;

class ResponseHalTest extends \PHPUnit_Framework_TestCase
{
    public function testSetCustomKeys()
    {
        $res = new Response();
        $res->title = 'Testing Title';

        $expected = array(
            'title' => 'Testing Title'
        );

        $format = new Formatter\Hal($res);
        $this->assertEquals($expected, $format->toArray());
    }

    public function testSetOverridesAnyKey()
    {
        $res = new Response();
        $res->foo = 'newkey';
        $res->setProperties(array(
            'title' => 'Add Item',
            'foo' => 'bar',
            'bar' => 'baz'
        ));

        $expected = array(
            'title' => 'Add Item',
            'foo' => 'newkey',
            'bar' => 'baz'
        );

        $format = new Formatter\Hal($res);
        $this->assertEquals($expected, $format->toArray());
    }

    public function testSetProperties()
    {
        $res = new Response();
        $res->setProperties(array(
            'title' => 'Add Item',
            'foo' => 'bar',
            'bar' => 'baz'
        ));

        $expected = array(
            'title' => 'Add Item',
            'foo' => 'bar',
            'bar' => 'baz'
        );

        $format = new Formatter\Hal($res);
        $this->assertEquals($expected, $format->toArray());
    }

    public function testAddLink()
    {
        $res = new Response();
        $res->addLink('self', 'http://localhost/foo/bar');

        $expected = array(
            '_links' => array(
                'self' => array(
                    'href' => 'http://localhost/foo/bar'
                )
            )
        );

        $format = new Formatter\Hal($res);
        $this->assertEquals($expected, $format->toArray());
    }

    public function testAddLinkArray()
    {
        $res = new Response();
        $res->addLink('self', array(
            'class' => array('foo', 'bar'),
            'href' => 'http://localhost/foo/bar'
        ));

        $expected = array(
            '_links' => array(
                'self' => array(
                    'class' => array('foo', 'bar'),
                    'href' => 'http://localhost/foo/bar'
                )
            )
        );

        $format = new Formatter\Hal($res);
        $this->assertEquals($expected, $format->toArray());
    }
<commit_msg>Add test for Hal properties + links<commit_after><?php
namespace Hyperspan\Tests;
use Hyperspan\Response;
use Hyperspan\Formatter;

class ResponseHalTest extends \PHPUnit_Framework_TestCase
{
    public function testSetCustomKeys()
    {
        $res = new Response();
        $res->title = 'Testing Title';

        $expected = array(
            'title' => 'Testing Title'
        );

        $format = new Formatter\Hal($res);
        $this->assertEquals($expected, $format->toArray());
    }

    public function testSetOverridesAnyKey()
    {
        $res = new Response();
        $res->foo = 'newkey';
        $res->setProperties(array(
            'title' => 'Add Item',
            'foo' => 'bar',
            'bar' => 'baz'
        ));

        $expected = array(
            'title' => 'Add Item',
            'foo' => 'newkey',
            'bar' => 'baz'
        );

        $format = new Formatter\Hal($res);
        $this->assertEquals($expected, $format->toArray());
    }

    public function testSetProperties()
    {
        $res = new Response();
        $res->setProperties(array(
            'title' => 'Add Item',
            'foo' => 'bar',
            'bar' => 'baz'
        ));

        $expected = array(
            'title' => 'Add Item',
            'foo' => 'bar',
            'bar' => 'baz'
        );

        $format = new Formatter\Hal($res);
        $this->assertEquals($expected, $format->toArray());
    }

    public function testAddLink()
    {
        $res = new Response();
        $res->addLink('self', 'http://localhost/foo/bar');

        $expected = array(
            '_links' => array(
                'self' => array(
                    'href' => 'http://localhost/foo/bar'
                )
            )
        );

        $format = new Formatter\Hal($res);
        $this->assertEquals($expected, $format->toArray());
    }

    public function testAddLinkArray()
    {
        $res = new Response();
        $res->addLink('self', array(
            'class' => array('foo', 'bar'),
            'href' => 'http://localhost/foo/bar'
        ));

        $expected = array(
            '_links' => array(
                'self' => array(
                    'class' => array('foo', 'bar'),
                    'href' => 'http://localhost/foo/bar'
                )
            )
        );

        $format = new Formatter\Hal($res);
        $this->assertEquals($expected, $format->toArray());
    }

    public function testAddLinkWithProperties()
    {
        $res = new Response();
        $res->setProperties(array(
            'title' => 'Add Item',
            'foo' => 'bar',
            'bar' => 'baz'
        ));

        $res->addLink('self', 'http://localhost/foo/bar');

        $expected = array(
            'title' => 'Add Item',
            'foo' => 'bar',
            'bar' => 'baz',
            '_links' => array(
                'self' => array(
                    'href' => 'http://localhost/foo/bar'
                )
            )
        );

        $format = new Formatter\Hal($res);
        $this->assertSame($expected, $format->toArray());
    }

{'fraction_non_alphanumeric': 0.1688896899783706, 'fraction_numerical': 0.0, 'mean_word_length': 1.5430797433547205, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 92, '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': '4217314', 'n_tokens_mistral': 1610, 'n_tokens_neox': 1548, 'n_words': 317}