gitlab-com-adeattwood-yii2-.../tests/unit/ArrayHelperCest.php
Ade Attwood ec3e74ffb3 phpcs
2017-06-24 12:36:23 +01:00

58 lines
1.4 KiB
PHP

<?php
use adeattwood\helpers\ArrayHelper;
use adeattwood\helpers\tests\_data\ModelOne;
/**
* @category PHP
* @package adeattwood\yii-helpers
* @author Ade Attwood <attwood16@googlemail.com>
* @copyright 2017 adeattwood.co.uk
* @license BSD-2-Clause http://adeattwood.co.uk/license.html
* @link adeattwood.co.uk
* @since v0.1
*/
class ArrayHelperCest
{
public function _before( UnitTester $I )
{
}
public function _after( UnitTester $I )
{
}
public function testNumberArray( UnitTester $I )
{
$array = ArrayHelper::numberArray( 10, 2, 2 );
$I->assertEquals( $array[ 2 ], 2 );
$I->assertFalse( isset( $array[ 3 ] ) );
$I->assertEquals( $array[ 4 ], 4 );
}
public function testNumberArrayWithStep( UnitTester $I )
{
$array = ArrayHelper::numberArray( 10 );
$I->assertEquals( $array[ 0 ], 0 );
$I->assertEquals( $array[ 10 ], 10 );
$I->assertFalse( isset( $array[ 11 ] ) );
}
public function testParseAttribute( UnitTester $I )
{
$model = new ModelOne;
$model->propOne = "test";
$data = ArrayHelper::parseAttribute( $model, 'propOne' );
$I->assertEquals( $data->format, 'text' );
$I->assertEquals( $data->lable, 'Prop One' );
$I->assertEquals( $data->value, 'test' );
$I->assertEquals( $data->raw, 'test' );
}
}