<?php

namespace Buckhill\Support\tests\units\Noop;

use atoum\test;
use Buckhill\Support\Noop\DotNotation as DotNot;

class DotNotation extends test
{
    public function testDotNotationAccessor()
    {
        $this
            ->given($property = [
                'nested' => [
                    'key' => 'value'
                ],
                'single' => 'level'
            ])
            ->and($model = [
                'nested' => [
                    'model' => [
                        'bool' => true
                    ]
                ],
                'flat' => null
            ])

            ->and($dotnot = new DotNot($property, $model))

            ->then
                ->string($dotnot->dotNotationFromProperty('prop', 'nested.key'))->isEqualTo('value')
                ->variable($dotnot->dotNotationFromProperty('prop', 'flat'))->isNull()
                ->boolean($dotnot->dotNotationFromModel('nested.model.bool'))->isTrue()
                ->variable($dotnot->dotNotationFromModel('flat'))->isNull()
            ;
    }
}