<commit_before><?php

namespace Shrink0r\Configr\Tests\Property;

use PHPUnit_Framework_TestCase;
use Shrink0r\Configr\Error;
use Shrink0r\Configr\Exception;
use Shrink0r\Configr\Ok;
use Shrink0r\Configr\Property\SequenceProperty;
use Shrink0r\Configr\SchemaInterface;

class SequencePropertyTest extends PHPUnit_Framework_TestCase
{
    public function testValidateOk()
    {
        $mockSchema = $this->getMockBuilder(SchemaInterface::class)->getMock();

        $property = new SequenceProperty(
            $mockSchema,
            'value',
            [
                'required' => true,
                'one_of' => [ 'int', 'string', 'float', 'bool' ]
            ]
        );
        $result = $property->validate([ 'value' => [ true, 23, 42.0, 'foo' ] ]);

        $this->assertInstanceOf(Ok::class, $result);
    }

    public function testValidateError()
    {
        $mockSchema = $this->getMockBuilder(SchemaInterface::class)->getMock();

        $property = new SequenceProperty($mockSchema, 'value', [ 'required' => true, 'one_of' => [ 'fqcn' ] ]);
        $result = $property->validate([ 'value' => [ SequenceProperty::class, TheVoid::class ] ]);
        $expectedErrors = [ 1 => [ Error::CLASS_NOT_EXISTS ] ];

        $this->assertInstanceOf(Error::class, $result);
        $this->assertEquals($expectedErrors, $result->unwrap());
    }

    public function testValidateAnyOk()
    {
        $mockSchema = $this->getMockBuilder(SchemaInterface::class)->getMock();

        $property = new SequenceProperty($mockSchema, 'value', [ 'required' => true, 'one_of' => [ 'any' ] ]);
        $result = $property->validate([ 'value' => [ 23, 'foobar', [ 'foo', 'bar' ] ] ]);

        $this->assertInstanceOf(Ok::class, $result);
    }

    public function testInvalidCustomType()
    {
        $this->expectException(Exception::class);
        $this->expectExceptionMessage("Unable to resolve 'moep' to a custom type-definition.");

        $mockSchema = $this->getMockBuilder(SchemaInterface::class)->getMock();

        $property = new SequenceProperty($mockSchema, 'value', [ 'required' => true, 'one_of' => [ '&moep' ] ]);
        $property->validate([ 'value' => [ 23 ] ]);
    } // @codeCoverageIgnore

    public function testInvalidPropertyType()<commit_msg>added seq-prop testcase<commit_after><?php

namespace Shrink0r\Configr\Tests\Property;

use PHPUnit_Framework_TestCase;
use Shrink0r\Configr\Error;
use Shrink0r\Configr\Exception;
use Shrink0r\Configr\Ok;
use Shrink0r\Configr\Property\SequenceProperty;
use Shrink0r\Configr\SchemaInterface;

class SequencePropertyTest extends PHPUnit_Framework_TestCase
{
    public function testValidateOk()
    {
        $mockSchema = $this->getMockBuilder(SchemaInterface::class)->getMock();

        $property = new SequenceProperty(
            $mockSchema,
            'value',
            [
                'required' => true,
                'one_of' => [ 'int', 'string', 'float', 'bool' ]
            ]
        );
        $result = $property->validate([ 'value' => [ true, 23, 42.0, 'foo' ] ]);

        $this->assertInstanceOf(Ok::class, $result);
    }

    public function testValidateError()
    {
        $mockSchema = $this->getMockBuilder(SchemaInterface::class)->getMock();

        $property = new SequenceProperty($mockSchema, 'value', [ 'required' => true, 'one_of' => [ 'fqcn' ] ]);
        $result = $property->validate([ 'value' => [ SequenceProperty::class, TheVoid::class ] ]);
        $expectedErrors = [ 1 => [ Error::CLASS_NOT_EXISTS ] ];

        $this->assertInstanceOf(Error::class, $result);
        $this->assertEquals($expectedErrors, $result->unwrap());
    }

    public function testInvalidValue()
    {
        $mockSchema = $this->getMockBuilder(SchemaInterface::class)->getMock();

        $property = new SequenceProperty($mockSchema, 'value', [ 'required' => true, 'one_of' => [ 'fqcn' ] ]);
        $result = $property->validate([ 'value' => 'meh' ]);
        $expectedErrors = [ Error::NON_ARRAY ];

        $this->assertInstanceOf(Error::class, $result);
        $this->assertEquals($expectedErrors, $result->unwrap());
    }

    public function testValidateAnyOk()
    {
        $mockSchema = $this->getMockBuilder(SchemaInterface::class)->getMock();

        $property = new SequenceProperty($mockSchema, 'value', [ 'required' => true, 'one_of' => [ 'any' ] ]);
        $result = $property->validate([ 'value' => [ 23, 'foobar', [ 'foo', 'bar' ] ] ]);

        $this->assertInstanceOf(Ok::class, $result);
    }

    public function testInvalidCustomType()
    {
        $this->expectException(Exception::class);
        $this->expectExceptionMessage("Unable to resolve 'moep' to a custom type-definition.");

        $mockSchema = $this->getMockBuilder(SchemaInterface::class)->getMock();

        $property = new SequenceProperty($mockSchema, 'value', [ 'required' => true, 'one_of' => [ '&moep' ] ]);
        $property->validate([ 'value' => [ 23 ] ]);
    } // @codeCoverageIgnore

    public function testInvalidPropertyType()
{'fraction_non_alphanumeric': 0.16541055136850455, 'fraction_numerical': 0.006346687822292741, 'mean_word_length': 3.266497461928934, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 76, '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': '4377033', 'n_tokens_mistral': 1542, 'n_tokens_neox': 1486, 'n_words': 266}