This commit is contained in:
Ade Attwood 2017-06-24 12:36:23 +01:00
parent 8da166736b
commit ec3e74ffb3
13 changed files with 168 additions and 100 deletions

View file

@ -1,11 +1,15 @@
{ {
"name": "adeattwood/yii-helpers", "name": "adeattwood/yii-helpers",
"description": "Helpers for the yii2 framework", "description": "Helpers for the yii2 framework",
"version": "1",
"time": "2017-06-24 11:25:22",
"type": "library", "type": "library",
"authors": [ "authors": [
{ {
"name": "Ade Attwood", "name": "Ade Attwood",
"email": "attwood16@googlemail.com" "email": "attwood16@googlemail.com",
"homepage": "http:/adeattwood.co.uk",
"role": "Developer"
} }
], ],
"minimum-stability": "stable", "minimum-stability": "stable",

View file

@ -20,9 +20,9 @@ class ArrayObject extends \ArrayObject
/** /**
* __construct * __construct
* *
* @param mixed $array * @param mixed $array The array to put into the array object
* @param mixed $flags * @param mixed $flags The falgs of the object
* @param string $iterator_class * @param string $iterator_class The iterator class
* *
* @return void * @return void
*/ */
@ -51,7 +51,7 @@ class ArrayObject extends \ArrayObject
/** /**
* Gets a random value from the array * Gets a random value from the array
* *
* @param int $count * @param int $count How many items to return
* *
* @return int|array * @return int|array
*/ */
@ -81,17 +81,8 @@ class ArrayObject extends \ArrayObject
* *
* @return string The html for the table * @return string The html for the table
*/ */
public function toTable( public function toTable( $transpose = false, $recursive = false, $typeHint = true, $tableOptions = [ 'class' => 'table table-bordered table-striped' ], $keyOptions = [], $valueOptions = [ 'style' => 'cursor: default; border-bottom: 1px #aaa dashed;' ], $null = '<span class="not-set">(not set)</span>' )
$transpose = false, {
$recursive = false,
$typeHint = true,
$tableOptions = ['class' => 'table table-bordered table-striped'],
$keyOptions = [],
$valueOptions = ['style' => 'cursor: default; border-bottom: 1px #aaa dashed;'],
$null = '<span class="not-set">(not set)</span>'
) {
// Sanity check
if ( empty( ( array )$this ) ) { if ( empty( ( array )$this ) ) {
return false; return false;
} }

View file

@ -96,7 +96,6 @@ class Dumper
foreach ( $methods as $method ) { foreach ( $methods as $method ) {
$prop = ''; $prop = '';
if ( $method->isPublic() ) { if ( $method->isPublic() ) {

View file

View file

@ -2,10 +2,29 @@
namespace adeattwood\helpers\tests\_data; namespace adeattwood\helpers\tests\_data;
/**
* @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 ModelOne extends \yii\base\Model class ModelOne extends \yii\base\Model
{ {
/**
* The first test proprety
*
* @var string
*/
public $propOne; public $propOne;
/**
* The validation rules for the model
*
* @return array
*/
public function rules() public function rules()
{ {
return [ return [

View file

@ -1,9 +1,15 @@
<?php <?php
namespace Helper; namespace Helper;
// here you can define custom actions /**
// all public methods declared in helper class will be available in $I * @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 Unit extends \Codeception\Module class Unit extends \Codeception\Module
{ {

View file

@ -1,7 +1,14 @@
<?php <?php
/** /**
* @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
*
* Inherited Methods * Inherited Methods
* @method void wantToTest($text) * @method void wantToTest($text)
* @method void wantTo($text) * @method void wantTo($text)
@ -19,8 +26,4 @@
class UnitTester extends \Codeception\Actor class UnitTester extends \Codeception\Actor
{ {
use _generated\UnitTesterActions; use _generated\UnitTesterActions;
/**
* Define custom actions here
*/
} }

View file

@ -3,6 +3,15 @@
use adeattwood\helpers\ArrayHelper; use adeattwood\helpers\ArrayHelper;
use adeattwood\helpers\tests\_data\ModelOne; 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 class ArrayHelperCest
{ {

View file

@ -2,6 +2,15 @@
use adeattwood\helpers\ArrayObject; use adeattwood\helpers\ArrayObject;
/**
* @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 ArrayObjectCest class ArrayObjectCest
{ {
public $arrayObject; public $arrayObject;
@ -48,5 +57,4 @@ class ArrayObjectCest
$I->assertContains( '<table class="table table-bordered table-striped">', $table ); $I->assertContains( '<table class="table table-bordered table-striped">', $table );
$I->assertContains( '<span title="string" style="cursor: default; border-bottom: 1px #aaa dashed;">Value One</span>', $table ); $I->assertContains( '<span title="string" style="cursor: default; border-bottom: 1px #aaa dashed;">Value One</span>', $table );
} }
} }

30
tests/unit/EnumCest.php Normal file
View file

@ -0,0 +1,30 @@
<?php
use adeattwood\helpers\Enum;
/**
* @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 EnumCest
{
public function _before( UnitTester $I )
{
}
public function _after( UnitTester $I )
{
}
public function testNumberArray( UnitTester $I )
{
$I->assertEquals( Enum::formatBytes( 28434322.25 ), "27.12 MB" );
$I->assertEquals( Enum::formatBytes( 17328347842.25, 3 ), "16.138 GB" );
}
}

View file

@ -19,4 +19,3 @@ $config = [
]; ];
( new yii\web\Application( $config ) ); ( new yii\web\Application( $config ) );