<commit_before><?php

namespace ManagerTest\Config;

use Manager\Config\Node;
use Manager\Exception\MissingConfigException;
use Silex\Application;

class NodeTest extends \PHPUnit_Framework_TestCase
{
    public function testCheckForTheConfigKey()
    {
        /** @var \Silex\Application||PHPUnit_Framework_MockObject_MockObject $appMock */
        $appMock = $this->getMockBuilder(Application::class)
            ->disableOriginalConstructor()
            ->getMock();

        $appMock->expects($this->once())
            ->method('offsetExists')
            ->with('manager-config');

        $this->setExpectedException(MissingConfigException::class);

        new Node($appMock);
    }
}<commit_msg>Improve tests for Config\Node class<commit_after><?php

namespace ManagerTest\Config;

use Manager\Config\Node;
use Manager\Exception\MissingConfigException;
use Silex\Application;

/**
 * Tests for {@see \Manager\Config\Node}
 *
 * @author <NAME> <<EMAIL>>
 *
 * @group  Unitary
 * @covers \Manager\Config\Node
 */
class NodeTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @dataProvider getWrongConfiguration
     *
     * @param $wrongConfig
     */
    public function testCheckForTheConfigKey($wrongConfig)
    {
        /** @var \Silex\Application||PHPUnit_Framework_MockObject_MockObject $appMock */
        $appMock = $this->getMockBuilder(Application::class)
            ->disableOriginalConstructor()
            ->getMock();

        $appMock->expects($this->once())
            ->method('offsetExists')
            ->with('manager-config')
            ->willReturn(true);

        $appMock->expects($this->any())
            ->method('offsetGet')
            ->with('manager-config')
            ->willReturn($wrongConfig);

        $this->setExpectedException(MissingConfigException::class);
        new Node($appMock, 'dummy', 'index');
    }

    public function testCreateNodeWithOnlyRequiredConfigUsesTheDefaultValues()
    {
        /** @var \Silex\Application||PHPUnit_Framework_MockObject_MockObject $appMock */
        $appMock = $this->getMockBuilder(Application::class)
            ->disableOriginalConstructor()
            ->getMock();

        $appMock->expects($this->any())
            ->method('offsetExists')
            ->with('manager-config')
            ->will(
                $this->returnValue([
                    'manager' => [

                    ],
                ]
                ));

        $appMock->expects($this->any())
            ->method('offsetGet')
            ->with('manager-config')
            ->will(
                $this->returnValue([
                    'manager' => [
                        'dummy' => [
                            'index' => [
                                'columns' => []
                            ],
                        ],
                    ],
                ]));

        $node = new Node($appMock, 'dummy', 'index');
        $this->assertSame(10, $node->getItemPerPage());
        $this->assertSame([], $node->getColumns());
        $this->assertSame('dummy', $node->getDbTable());
        $this->assertSame('Manager: dummy', $node->getHeader());
        $this->assertSame('setting', $node->getIcon());
        $this->assertEmpty($node->getQuery());
        $this->assertNull($node->getSearch());
    }

    public function getWrongConfiguration()
    {
        return [
            [
                [],
            ],
            [
                [
                    'manager' => [],
                ],
            ],
            [
                [
                    'manager' => [
                        'dummy' => [],
                    ],
                ],
            ],
            [
                [
                    'manager' => [
                        'dummy' => [
                            'index' => [],
                        ],
                    ],
                ],
            ],
        ];
    }
}
{'fraction_non_alphanumeric': 0.14379746835443039, 'fraction_numerical': 0.0005063291139240507, 'mean_word_length': 1.5408360128617364, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 68, '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': '5598658', 'n_tokens_mistral': 1028, 'n_tokens_neox': 991, 'n_words': 137}