<?php

namespace Ingot\Tests\Normalizer;

use Ingot\Normalizer\NetGroupNormalizer;
use Symfony\Component\Config\FileLocator;

class NetGroupNormalizerTest extends \PHPUnit_Framework_TestCase
{
    public function setUp()
    {
        $this->locator = new FileLocator(__DIR__ . '/../Fixtures');
    }

    /**
     * @test
     */
    public function it_does_nothing_when_file_not_found()
    {
        $normalizer = new NetGroupNormalizer($this->locator, 'badalalala.json');

        $this->assertEquals('#not.name#', $normalizer->normalize('#not.name#'));
    }

    /**
     * @dataProvider normalizationStrings
     * @test
     */
    public function it_normalizes_based_on_file($pattern, $expected)
    {
        $normalizer = new NetGroupNormalizer($this->locator);

        $this->assertEquals($expected, $normalizer->normalize($pattern));
    }

    public function normalizationStrings()
    {
        return array(
            array('value', 'value'),
            array('#redis.host#', 'stage-redis01'),
            array('#redis.port#', 6379),
            array('#app.name#', 'grundfos-lion'),
            array('#app.type#', 'symfony'),
            array('#app.env.APP_BRANCH#', 'ng'),
        );
    }
}
