Skip to content

Commit

Permalink
test file compress by retort
Browse files Browse the repository at this point in the history
  • Loading branch information
howyi committed Oct 13, 2017
1 parent a8cee52 commit c65dc66
Show file tree
Hide file tree
Showing 14 changed files with 109 additions and 96 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/vendor/
/build/
composer.lock
Retort
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ php:
before_script:
- composer install --dev
script:
- make heat
- vendor/bin/phpunit --coverage-clover=build/log/clover.xml
- vendor/bin/phpstan analyse -l 7 -c phpstan.neon src
after_success:
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@ test:
@vendor/bin/phpunit
stan:
@vendor/bin/phpstan analyse -l 7 -c phpstan.neon src
seal:
@vendor/bin/rtrt seal
heat:
@vendor/bin/rtrt heat

.PHONY: test stan
.PHONY: test stan seal heat
73 changes: 73 additions & 0 deletions schema/gamelog_payment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
comment: 課金情報DBテーブル
column:
id:
type: int(11)
comment: ID
attribute:
- auto_increment
- unsigned
osuser_id:
type: varchar(255)
comment: ユーザーID
language_locale:
type: varchar(20)
comment: ユーザーの言語-地域情報
attribute:
- nullable
point_code:
type: text
comment: 決済管理ID
status:
type: int(11)
comment: 決済状況
attribute:
- unsigned
item_id:
type: int(11)
comment: アイテムID
attribute:
- unsigned
item_name:
type: varchar(255)
comment: アイテム名
point:
type: int(11)
comment: 単価
attribute:
- unsigned
quantity:
type: int(11)
comment: 数量
attribute:
- unsigned
send_data:
type: varchar(255)
comment: 送信電文
device:
type: int(11)
comment: デバイス種別
attribute:
- unsigned
created_at:
type: datetime
comment: 作成日時
paid_at:
type: datetime
comment: 確定日時
primary_key:
- id
index:
point_code:
is_unique: true
column:
- point_code(90)
osuser_id:
is_unique: false
column:
- osuser_id
created_at:
is_unique: false
column:
- created_at
default_charset: utf8
collate: utf8_general_ci
16 changes: 0 additions & 16 deletions schema/tbl_country2.json

This file was deleted.

10 changes: 10 additions & 0 deletions schema/tbl_country2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
comment: 'Country table'
column:
country_id:
type: int(11)
comment: 'Country id'
country_name:
type: varchar(255)
comment: 'Country Name'
primary_key:
- country_id
6 changes: 4 additions & 2 deletions schema/tbl_user.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ column:
name:
type: varchar(255)
comment: 'User name'
attribute: [nullable]
attribute:
- nullable
age:
type: int(11)
comment: 'User age'
attribute: [nullable]
attribute:
- nullable
primary_key:
- user_id
36 changes: 2 additions & 34 deletions schema/view_user.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,2 @@
type: view
algorithm: merge
alias:
tbl_user: tu
tbl_user_address: tua
tbl_country: tc
column:
user_id: tu.user_id
user_name: tu.name
address_line: tua.address_line
zip_code: tua.zip_code
country_name: tc.country_name
from:
reference: tu
joins:
- join:
factor: tua
on: tu.user_id = tua.user_id
- left_join:
factor: tc
on: tua.country_id = tc.country_id

# CREATE VIEW `view_user`
# AS SELECT
# `tu`.`user_id` AS `user_id`,
# `tu`.`name` AS `user_name`,
# `tua`.`address_line` AS `address_line`,
# `tua`.`zip_code` AS `zip_code`,
# `tc`.`country_name` AS `country_name`
# FROM (
# (
# `tbl_user` `tu` join `tbl_user_address` `tua` on((`tu`.`user_id` = `tua`.`user_id`))
# ) join `tbl_country` `tc` on((`tua`.`country_id` = `tc`.`country_id`))
# )
type: view_raw
query: 'CREATE ALGORITHM=MERGE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `view_user` AS select `tu`.`user_id` AS `user_id`,`tu`.`name` AS `user_name`,`tua`.`address_line` AS `address_line`,`tua`.`zip_code` AS `zip_code`,`tc`.`country_name` AS `country_name` from ((`tbl_user` `tu` join `tbl_user_address` `tua` on((`tu`.`user_id` = `tua`.`user_id`))) left join `tbl_country` `tc` on((`tua`.`country_id` = `tc`.`country_id`)));'
2 changes: 1 addition & 1 deletion tests/Conv/DatabaseStructureFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class DatabaseStructureFactoryTest extends \PHPUnit\Framework\TestCase
{
public function testFromYaml()
{
$actual = DatabaseStructureFactory::fromDir('tests/schema/');
$actual = DatabaseStructureFactory::fromDir('tests/Retort/');
// TODO
$this->assertInstanceOf(DatabaseStructure::class, $actual);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Conv/Factory/TableStructureFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class TableStructureFactoryTest extends \PHPUnit\Framework\TestCase
{
public function testFromSpec()
{
$spec = Evi::parse('tests/schema/tbl_user.yml', Config::option('eval'));
$spec = Evi::parse('tests/Retort/tbl_user.yml', Config::option('eval'));
$actual = TableStructureFactory::fromSpec('tbl_user', $spec);
// TODO
$this->assertInstanceOf(TableStructure::class, $actual);
Expand Down
18 changes: 9 additions & 9 deletions tests/Conv/MigrationGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function generateWhenNoQuestionProvider()
{
return [
[
DatabaseStructureFactory::fromDir('tests/schema/'),
DatabaseStructureFactory::fromDir('tests/Retort/'),
new DatabaseStructure([]),
[
TableDropMigration::class,
Expand All @@ -53,7 +53,7 @@ public function generateWhenNoQuestionProvider()
],
[
new DatabaseStructure([]),
DatabaseStructureFactory::fromDir('tests/schema/'),
DatabaseStructureFactory::fromDir('tests/Retort/'),
[
TableCreateMigration::class,
TableCreateMigration::class,
Expand All @@ -67,17 +67,17 @@ public function testGenerateWhenNotModify()
$before = new DatabaseStructure([
'tbl_user' => TableStructureFactory::fromSpec(
'tbl_user',
Evi::parse('tests/schema/tbl_user.yml', Config::option('eval'))
Evi::parse('tests/Retort/tbl_user.yml', Config::option('eval'))
),
'tbl_music' => TableStructureFactory::fromSpec(
'tbl_music',
Evi::parse('tests/schema/tbl_music.yml', Config::option('eval'))
Evi::parse('tests/Retort/tbl_music.yml', Config::option('eval'))
),
]);
$after = new DatabaseStructure([
TableStructureFactory::fromSpec(
'tbl_user',
Evi::parse('tests/schema/tbl_user.yml', Config::option('eval'))
Evi::parse('tests/Retort/tbl_user.yml', Config::option('eval'))
),
]);
$operator = $this->prophet->prophesize(Operator::class);
Expand All @@ -90,13 +90,13 @@ public function testGenerateWhenDropAndCreate()
$before = new DatabaseStructure([
'tbl_user' => TableStructureFactory::fromSpec(
'tbl_user',
Evi::parse('tests/schema/tbl_user.yml', Config::option('eval'))
Evi::parse('tests/Retort/tbl_user.yml', Config::option('eval'))
),
]);
$after = new DatabaseStructure([
'tbl_music' => TableStructureFactory::fromSpec(
'tbl_music',
Evi::parse('tests/schema/tbl_music.yml', Config::option('eval'))
Evi::parse('tests/Retort/tbl_music.yml', Config::option('eval'))
),
]);
$operator = $this->prophet->prophesize(Operator::class);
Expand All @@ -115,13 +115,13 @@ public function testGenerateWhenRename()
$before = new DatabaseStructure([
'tbl_user' => TableStructureFactory::fromSpec(
'tbl_user',
Evi::parse('tests/schema/tbl_user.yml', Config::option('eval'))
Evi::parse('tests/Retort/tbl_user.yml', Config::option('eval'))
),
]);
$after = new DatabaseStructure([
'tbl_music' => TableStructureFactory::fromSpec(
'tbl_music',
Evi::parse('tests/schema/tbl_music.yml', Config::option('eval'))
Evi::parse('tests/Retort/tbl_music.yml', Config::option('eval'))
),
]);
$operator = $this->prophet->prophesize(Operator::class);
Expand Down
2 changes: 2 additions & 0 deletions tests/Retort.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tbl_music.yml: "comment: 'Music management table'\ncolumn:\n music_id:\n type: int(10)\n comment: 'Unique music ID'\n name:\n type: varchar(255)\n comment: 'Music name'\n released_at:\n type: datetime\n comment: 'Music released date'\nprimary_key:\n - music_id\n"
tbl_user.yml: "comment: 'User management table'\ncolumn:\n user_id:\n type: int(11)\n comment: 'User ID'\n name:\n type: int(11)\n comment: 'User name'\n attribute: [nullable]\n age:\n type: int(11)\n comment: 'User age'\n attribute: [nullable]\nprimary_key:\n - user_id\nindex:\n name:\n is_unique: true\n column: [name]\n"
13 changes: 0 additions & 13 deletions tests/schema/tbl_music.yml

This file was deleted.

19 changes: 0 additions & 19 deletions tests/schema/tbl_user.yml

This file was deleted.

0 comments on commit c65dc66

Please sign in to comment.