2014-11-13 11:44:30 -08:00
|
|
|
<?php
|
|
|
|
|
|
2017-01-17 14:30:19 +00:00
|
|
|
namespace Illuminate\Tests\Database;
|
|
|
|
|
|
2018-10-03 22:05:43 +02:00
|
|
|
use Illuminate\Database\Query\Processors\SQLiteProcessor;
|
2019-09-10 17:16:05 +02:00
|
|
|
use PHPUnit\Framework\TestCase;
|
2016-12-30 21:31:11 +01:00
|
|
|
|
|
|
|
|
class DatabaseSQLiteProcessorTest extends TestCase
|
2015-06-01 16:26:53 +01:00
|
|
|
{
|
2023-10-26 21:50:57 +03:30
|
|
|
public function testProcessColumns()
|
2015-06-01 15:56:31 +01:00
|
|
|
{
|
2018-10-03 22:05:43 +02:00
|
|
|
$processor = new SQLiteProcessor;
|
2014-11-13 11:44:30 -08:00
|
|
|
|
2023-10-26 21:50:57 +03:30
|
|
|
$listing = [
|
2024-05-11 03:24:21 +08:00
|
|
|
['name' => 'id', 'type' => 'INTEGER', 'nullable' => '0', 'default' => '', 'primary' => '1', 'extra' => 1],
|
|
|
|
|
['name' => 'name', 'type' => 'varchar', 'nullable' => '1', 'default' => 'foo', 'primary' => '0', 'extra' => 1],
|
|
|
|
|
['name' => 'is_active', 'type' => 'tinyint(1)', 'nullable' => '0', 'default' => '1', 'primary' => '0', 'extra' => 1],
|
2024-08-14 22:54:14 +01:00
|
|
|
['name' => 'with/slash', 'type' => 'tinyint(1)', 'nullable' => '0', 'default' => '1', 'primary' => '0', 'extra' => 1],
|
2023-10-26 21:50:57 +03:30
|
|
|
];
|
|
|
|
|
$expected = [
|
2024-03-04 18:43:36 +03:30
|
|
|
['name' => 'id', 'type_name' => 'integer', 'type' => 'integer', 'collation' => null, 'nullable' => false, 'default' => '', 'auto_increment' => true, 'comment' => null, 'generation' => null],
|
|
|
|
|
['name' => 'name', 'type_name' => 'varchar', 'type' => 'varchar', 'collation' => null, 'nullable' => true, 'default' => 'foo', 'auto_increment' => false, 'comment' => null, 'generation' => null],
|
|
|
|
|
['name' => 'is_active', 'type_name' => 'tinyint', 'type' => 'tinyint(1)', 'collation' => null, 'nullable' => false, 'default' => '1', 'auto_increment' => false, 'comment' => null, 'generation' => null],
|
2024-08-14 22:54:14 +01:00
|
|
|
['name' => 'with/slash', 'type_name' => 'tinyint', 'type' => 'tinyint(1)', 'collation' => null, 'nullable' => false, 'default' => '1', 'auto_increment' => false, 'comment' => null, 'generation' => null],
|
2023-10-26 21:50:57 +03:30
|
|
|
];
|
2014-11-13 11:44:30 -08:00
|
|
|
|
2023-10-26 21:50:57 +03:30
|
|
|
$this->assertEquals($expected, $processor->processColumns($listing));
|
2014-12-18 09:28:55 +00:00
|
|
|
|
2015-06-01 15:56:31 +01:00
|
|
|
// convert listing to objects to simulate PDO::FETCH_CLASS
|
2015-06-01 16:26:53 +01:00
|
|
|
foreach ($listing as &$row) {
|
2015-06-01 15:56:31 +01:00
|
|
|
$row = (object) $row;
|
|
|
|
|
}
|
2014-12-18 09:28:55 +00:00
|
|
|
|
2023-10-26 21:50:57 +03:30
|
|
|
$this->assertEquals($expected, $processor->processColumns($listing));
|
2015-06-01 15:56:31 +01:00
|
|
|
}
|
2014-11-13 11:44:30 -08:00
|
|
|
}
|