You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
846 B
55 lines
846 B
11 years ago
|
<?php
|
||
|
|
||
|
namespace yiiunit\extensions\sphinx;
|
||
|
|
||
|
use yii\sphinx\ColumnSchema;
|
||
|
|
||
|
/**
|
||
|
* @group sphinx
|
||
|
*/
|
||
|
class ColumnSchemaTest extends SphinxTestCase
|
||
|
{
|
||
|
/**
|
||
|
* Data provider for [[testTypeCast]]
|
||
|
* @return array test data.
|
||
|
*/
|
||
|
public function dataProviderTypeCast()
|
||
|
{
|
||
|
return [
|
||
|
[
|
||
|
'integer',
|
||
|
'integer',
|
||
|
5,
|
||
|
5
|
||
|
],
|
||
|
[
|
||
|
'integer',
|
||
|
'integer',
|
||
|
'5',
|
||
|
5
|
||
|
],
|
||
|
[
|
||
|
'string',
|
||
|
'string',
|
||
|
5,
|
||
|
'5'
|
||
|
],
|
||
|
];
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @dataProvider dataProviderTypeCast
|
||
|
*
|
||
|
* @param $type
|
||
|
* @param $phpType
|
||
|
* @param $value
|
||
|
* @param $expectedResult
|
||
|
*/
|
||
|
public function testTypeCast($type, $phpType, $value, $expectedResult)
|
||
|
{
|
||
|
$columnSchema = new ColumnSchema();
|
||
|
$columnSchema->type = $type;
|
||
|
$columnSchema->phpType = $phpType;
|
||
|
$this->assertEquals($expectedResult, $columnSchema->typecast($value));
|
||
|
}
|
||
|
}
|