<commit_before><?php

use Avetmiss\Fields\Field;


class FieldTest extends TestCase
{

	// make, lenght, name, in should all return a Field object
	public function testFluentBuilder()
	{
		$field = Field::make('any');
		$this->assertInstanceOf('Avetmiss\Fields\Field', $field);

		$field->lenght(10);
		$this->assertInstanceOf('Avetmiss\Fields\Field', $field);

		$field->name('foo');
		$this->assertInstanceOf('Avetmiss\Fields\Field', $field);

		$field->in(['foo', 'bar']);
		$this->assertInstanceOf('Avetmiss\Fields\Field', $field);

		$field->pad('x');
		$this->assertInstanceOf('Avetmiss\Fields\Field', $field);
	}


	public function testInWithValidValue()
	{
		$field = Field::make('any')->name('foo')->lenght(10)->in(['bar']);
		$field->setValue('bar');

		$this->assertEquals('bar       ', $field->render());
	}


	/**
	 * @expectedException \UnexpectedValueException
	 */
	public function testInWithInvalidValue()
	{
		$field = Field::make('any')->name('foo')->lenght(10)->in(['bar']);
		$field->setValue('fiddy');
	}


	public function testPad()
	{
		$field = Field::make('any')->name('foo')->lenght(10)->pad('.');
		$field->setValue('bar');

		$this->assertEquals('.......bar', $field->render());
	}


	/**
	 * @expectedException \InvalidArgumentException
	 */
	public function testLenghtShouldBeInt()
	{
		$field = Field::make('any')->lenght('5');
	}


	public function testExportSpacesPad()
	{
		$field = Field::make('any')->name('foo')->lenght(10);
		$field->setValue('bar');

		// bar with 7 spaces
		$this->assertEquals('bar       ', $field->render());
	}


	public function testCutIfLenghtIsToLong()
	{
		$field = Field::make('any')->name('foo')->lenght(10);

		// 12 characters
		$field->setValue('foobarfoobar');

		$this->assertEquals(10, strlen($field->render())); 
	}


	/**
	 * @expectedException Exception
	 */
	public function testInvalidDateFormat()
	{
		$field = Field::make('date')->name('foo')->lenght(8);
		$field->setValue('foo');
	}


	/**
	 * @expectedException Exception
	 */
	public function testValidDateFormat()
	{
		$field = Field::make('date')->name('foo')->lenght(8);
		$field->setValue(02032014);
	}
}<commit_msg>formatting<commit_after><?php

use Avetmiss\Fields\Field;


class FieldTest extends TestCase
{


	/**
	 * @expectedException \InvalidArgumentException
	 */
	public function testLenghtShouldBeInt()
	{
		$field = Field::make('any')->lenght('5');
	}


	public function testExportSpacesPad()
	{
		$field = Field::make('any')->name('foo')->lenght(10);
		$field->setValue('bar');

		// bar with 7 spaces
		$this->assertEquals('bar       ', $field->render());
	}


	public function testCutIfLenghtIsToLong()
	{
		$field = Field::make('any')->name('foo')->lenght(10);

		// 12 characters
		$field->setValue('foobarfoobar');

		$this->assertEquals(10, strlen($field->render())); 
	}


	/**
	 * @expectedException Exception
	 */
	public function testInvalidDateFormat()
	{
		$field = Field::make('date')->name('foo')->lenght(8);
		$field->setValue('foo');
	}


	/**
	 * @expectedException Exception
	 */
	public function testValidDateFormat()
	{
		$field = Field::make('date')->name('foo')->lenght(8);
		$field->setValue(02032014);
	}
	

	// make, lenght, name, in, pad should all return a Field object
	public function testFluentBuilder()
	{
		$field = Field::make('any');
		$this->assertInstanceOf('Avetmiss\Fields\Field', $field);

		$field->lenght(10);
		$this->assertInstanceOf('Avetmiss\Fields\Field', $field);

		$field->name('foo');
		$this->assertInstanceOf('Avetmiss\Fields\Field', $field);

		$field->in(['foo', 'bar']);
		$this->assertInstanceOf('Avetmiss\Fields\Field', $field);

		$field->pad('.');
		$this->assertInstanceOf('Avetmiss\Fields\Field', $field);
	}


	public function testInWithValidValue()
	{
		$field = Field::make('any')->name('foo')->lenght(10)->in(['bar']);
		$field->setValue('bar');

		$this->assertEquals('bar       ', $field->render());
	}


	/**
	 * @expectedException \UnexpectedValueException
	 */
	public function testInWithInvalidValue()
	{
		$field = Field::make('any')->name('foo')->lenght(10)->in(['bar']);
		$field->setValue('fiddy');
	}


	public function testPad()
	{
		$field = Field::make('any')->name('foo')->lenght(10)->pad('.');
		$field->setValue('bar');

		$this->assertEquals('.......bar', $field->render());
	}
}
{'fraction_non_alphanumeric': 0.22170686456400743, 'fraction_numerical': 0.012987012987012988, 'mean_word_length': 4.6232073011734025, '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': '725963', 'n_tokens_mistral': 1601, 'n_tokens_neox': 1443, 'n_words': 213}