Yii2 framework backup
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.
 
 
 
 
 

69 lines
1.6 KiB

<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yiiunit\framework\db;
use yii\db\ColumnSchemaBuilder;
use yii\db\Schema;
use yiiunit\TestCase;
/**
* ColumnSchemaBuilderTest tests ColumnSchemaBuilder
*/
class ColumnSchemaBuilderTest extends TestCase
{
/**
* @param string $type
* @param integer $length
* @return ColumnSchemaBuilder
*/
public function getColumnSchemaBuilder($type, $length = null)
{
return new ColumnSchemaBuilder($type, $length);
}
/**
* @return array
*/
public function unsignedProvider()
{
return [
['integer', Schema::TYPE_INTEGER, null, [
['unsigned'],
]],
['integer(10)', Schema::TYPE_INTEGER, 10, [
['unsigned'],
]],
];
}
/**
* @dataProvider unsignedProvider
*/
public function testUnsigned($expected, $type, $length, $calls)
{
$this->checkBuildString($expected, $type, $length, $calls);
}
/**
* @param string $expected
* @param string $type
* @param integer $length
* @param array $calls
*/
public function checkBuildString($expected, $type, $length, $calls)
{
$builder = $this->getColumnSchemaBuilder($type, $length);
foreach ($calls as $call) {
$method = array_shift($call);
call_user_func_array([$builder, $method], $call);
}
self::assertEquals($expected, $builder->__toString());
}
}