<commit_before><?php

namespace gamringer\JSONPointer\Test;

use \gamringer\JSONPointer\Pointer;

class PointerTest extends \PHPUnit_Framework_TestCase
{
	/**
     * Tests that the pointer correctly stores and returns the target
     */
	public function testStoresTarget()
	{
        $target = [
            "foo" => ["bar", "baz"],
            "" => 0,
            "a/b" => 1,
            "c%d" => 2,
            "e^f" => 3,
            "g|h" => 4,
            "i\\j" => 5,
            "k\"l" => 6,
            " " => 7,
            "m~n" => 8
        ];
		$pointer = new Pointer($target);

		$this->assertEquals($pointer->getTarget(), $target);

		return $pointer;
	}

	/**
     * @dataProvider invalidTargetProvider
     * @depends testStoresTarget
     * @expectedException \gamringer\JSONPointer\Exception
     */
    public function testFailsInvalidTarget($target, Pointer $pointer)
    {
        $pointer->setTarget($target);
    }

    /**
     * @depends testStoresTarget
     * @dataProvider pathProvider
     */
    public function testGetPathValue($path, Pointer $pointer)
    {
        $pointer->get($path);
    }

    /**
     * @depends testStoresTarget
     */
    public function testSetPathValue(Pointer $pointer)
    {
        $value = 'bar';
        $pointer->set('/foo', $value);

        $this->assertEquals($pointer->get('/foo'), $value);
    }

    /**
     * @depends testStoresTarget
     * @dataProvider unsetPathProvider
     * @expectedException \gamringer\JSONPointer\Exception
     */
    public function testRemovePathValue($path, Pointer $pointer)
    {
        $pointer->remove($path);
        $pointer->get($path);
    }

    /**
     * @depends testStoresTarget
     * @dataProvider unsetPathProvider
     * @expectedException \gamringer\JSONPointer\Exception
     */
    public function testRemoveUnsetPathValue($path, Pointer $pointer)
    {
        $pointer->remove('/bar');
    }

    /**
     * Tests that root value can be unset
     */
    public function testUnsetRootValue()
    {
        $target = [
            "foo" => ["bar", "baz"],
            "" => 0,
            "a/b" => 1,
            "c%d" => 2,
            "e^f" => 3,
            "g|h" => 4,
            "i\\j" => 5,
            "k\"l" => 6,
            " " => 7,
            "m~n" => 8
        ];
        $pointer = new Pointer($target);

        $this->assertEquals($pointer->getTarget(), $target);
        $pointer->remove('');
        $this->assertEquals(null, $target);
    }

    /**
     * @depends testStoresTarget
     * @expectedException \gamringer\JSONPointer\Exception
     */
    public function testInvalidUnsetPathValue(Pointer $pointer)
    {
        $pointer->remove('foo');
    }
<commit_msg>Added test for replacing root value<commit_after><?php

namespace gamringer\JSONPointer\Test;

use \gamringer\JSONPointer\Pointer;

class PointerTest extends \PHPUnit_Framework_TestCase
{
	/**
     * Tests that the pointer correctly stores and returns the target
     */
	public function testStoresTarget()
	{
        $target = [
            "foo" => ["bar", "baz"],
            "" => 0,
            "a/b" => 1,
            "c%d" => 2,
            "e^f" => 3,
            "g|h" => 4,
            "i\\j" => 5,
            "k\"l" => 6,
            " " => 7,
            "m~n" => 8
        ];
		$pointer = new Pointer($target);

		$this->assertEquals($pointer->getTarget(), $target);

		return $pointer;
	}

	/**
     * @dataProvider invalidTargetProvider
     * @depends testStoresTarget
     * @expectedException \gamringer\JSONPointer\Exception
     */
    public function testFailsInvalidTarget($target, Pointer $pointer)
    {
        $pointer->setTarget($target);
    }

    /**
     * @depends testStoresTarget
     * @dataProvider pathProvider
     */
    public function testGetPathValue($path, Pointer $pointer)
    {
        $pointer->get($path);
    }

    /**
     * @depends testStoresTarget
     */
    public function testSetPathValue(Pointer $pointer)
    {
        $value = 'bar';
        $pointer->set('/foo', $value);

        $this->assertEquals($pointer->get('/foo'), $value);
    }

    /**
     * @depends testStoresTarget
     * @dataProvider unsetPathProvider
     * @expectedException \gamringer\JSONPointer\Exception
     */
    public function testRemovePathValue($path, Pointer $pointer)
    {
        $pointer->remove($path);
        $pointer->get($path);
    }

    /**
     * @depends testStoresTarget
     * @dataProvider unsetPathProvider
     * @expectedException \gamringer\JSONPointer\Exception
     */
    public function testRemoveUnsetPathValue($path, Pointer $pointer)
    {
        $pointer->remove('/bar');
    }

    /**
     * Tests that root value can be unset
     */
    public function testUnsetRootValue()
    {
        $target = [
            "foo" => ["bar", "baz"],
            "" => 0,
            "a/b" => 1,
            "c%d" => 2,
            "e^f" => 3,
            "g|h" => 4,
            "i\\j" => 5,
            "k\"l" => 6,
            " " => 7,
            "m~n" => 8
        ];
        $pointer = new Pointer($target);

        $this->assertEquals($pointer->getTarget(), $target);
        $pointer->remove('');
        $this->assertEquals(null, $target);
    }

    /**
     * Tests that root value can be replaced
     */
    public function testReplaceRootValue()
    {
        $target = [
            "foo" => ["bar", "baz"],
            "" => 0,
            "a/b" => 1,
            "c%d" => 2,
            "e^f" => 3,
            "g|h" => 4,
            "i\\j" => 5,
            "k\"l" => 6,
            " " => 7,
            "m~n" => 8
        ];

        $newTarget = 'foo';

        $pointer = new Pointer($target);

        $this->assertEquals($pointer->getTarget(), $target);
        $pointer->set('', $newTarget);
        $this->assertEquals($newTarget, $target);
    }

    /**
     * @depends testStoresTarget
     * @expectedException \gamringer\JSONPointer\Exception
     */
    public function testInvalidUnsetPathValue(Pointer $pointer)
    {
        $pointer->remove('foo');
    }

{'fraction_non_alphanumeric': 0.1567692054614246, 'fraction_numerical': 0.007402533311399902, 'mean_word_length': 1.838468720821662, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 87, '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': '7422865', 'n_tokens_mistral': 1919, 'n_tokens_neox': 1817, 'n_words': 356}