Skip to content

Commit

Permalink
Merge pull request #544 from exodus4d/develop
Browse files Browse the repository at this point in the history
v1.3.0
  • Loading branch information
exodus4d authored Nov 5, 2017
2 parents 489e7d8 + 605beeb commit 357e7b8
Show file tree
Hide file tree
Showing 223 changed files with 9,605 additions and 3,093 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,4 @@ Temporary Items
/node_modules/
/public/js/vX.X.X/
/vendor/
/history/
52 changes: 27 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Mapping tool for [*EVE ONLINE*](https://www.eveonline.com)
- Database will be cleared from time to time
- Installation guide:
- [wiki](https://github.com/exodus4d/pathfinder/wiki)
- Developer chat [Slack](https://slack.com) :
- Developer [Slack](https://slack.com) chat:
- https://pathfinder-eve-online.slack.com
- Please send me a mail for invite: [email protected]

Expand All @@ -28,44 +28,46 @@ Issues should be reported in the [Issue](https://github.com/exodus4d/pathfinder/
### Project structure

```
|-- (0755) app --> backend [*.php]
|-- app --> "Fat Free Framework" extensions
|-- lib --> "Fat Free Framework"
|-- main --> "PATHFINDER" root
|-- [0755] app/ --> backend [*.php]
|-- app/ --> "Fat Free Framework" extensions
|-- lib/ --> "Fat Free Framework"
|-- main/ --> "PATHFINDER" root
|-- config.ini --> config "f3" framework
|-- cron.ini --> config - cronjobs
|-- environment.ini --> config - system environment
|-- pathfinder.ini --> config - pathfinder
|-- requirements.ini --> config - system requirements
|-- routes.ini --> config - routes
|-- (0755) export --> DB export data
|-- sql --> static DB data for import (pathfinder.sql)
|-- (0755) favicon --> Favicons
|-- (0755) js --> JS source files (raw)
|-- app --> "PASTHFINDER" core files (not used for production)
|-- lib --> 3rd partie extension/library (not used for production)
|-- [0755] export/ --> static data
|-- csv/ --> *.csv used by /setup page
|-- json/ --> *.json used by /setup page
|-- sql/ --> DB dump for import (pathfinder.sql)
|-- [0755] favicon/ --> Favicons
|-- [0777] history/ --> log files (map history logs) [optional]
|-- [0755] js/ --> JS source files (raw)
|-- app/ --> "PASTHFINDER" core files (not used for production)
|-- lib/ --> 3rd partie extension/library (not used for production)
|-- app.js --> require.js config (!required for production!)
|-- (0777) logs --> log files
|-- [0777] logs/ --> log files
|-- ...
| -- node_modules --> node.js modules (not used for production)
| -- node_modules/ --> node.js modules (not used for production)
|-- ...
|-- (0755) public --> frontend source
|-- css --> CSS dist/build folder (minified)
|-- fonts --> (icon)-Fonts
|-- img --> images
|-- js --> JS dist/build folder and source maps (minified, uglified)
|-- templates --> templates
|-- sass --> SCSS source (not used for production)
|-- ...
|-- (0777) tmp --> cache folder
|-- ...
|-- (0755) .htaccess --> reroute/caching rules ("Apache" only!)
|-- (0755) index.php
|-- [0755] public/ --> frontend source
|-- css/ --> CSS dist/build folder (minified)
|-- fonts/ --> (icon)-Fonts
|-- img/ --> images
|-- js/ --> JS dist/build folder and source maps (minified, uglified)
|-- templates/ --> templates
|-- sass/ --> SCSS source (not used for production)
|-- [0777] tmp/ --> cache folder
|-- [0755] .htaccess --> reroute/caching rules ("Apache" only!)
|-- [0755] index.php
--------------------------
CI/CD config files:
--------------------------
|-- .jshintrc --> "JSHint" config (not used for production)
|-- composer.json --> Composer package definition
|-- config.rb --> "Compass" config (not used for production)
|-- gulpfile.js --> "Gulp" task config (not used for production )
|-- package.json --> "Node.js" dependency config (not used for production)
Expand Down
174 changes: 149 additions & 25 deletions app/app/schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,23 @@ function get()
$this->f3->set('CACHE', false);

$dbs = array(
/*'mysql' => new \DB\SQL(
'mysql' => new \DB\SQL(
'mysql:host=localhost;port=3306;dbname=fatfree', 'fatfree', ''
),*/
),
'sqlite' => new \DB\SQL(
'sqlite::memory:'
// 'sqlite:db/sqlite.db'
// 'sqlite:db/sqlite.db'
),
/*'pgsql' => new \DB\SQL(
'pgsql' => new \DB\SQL(
'pgsql:host=localhost;dbname=fatfree', 'fatfree', 'fatfree'
),*/
/*'sqlsrv2012' => new \DB\SQL(
'sqlsrv:SERVER=LOCALHOST\SQLEXPRESS2012;Database=fatfree','fatfree', 'fatfree'
),*/
/*'sqlsrv2008' => new \DB\SQL(
'sqlsrv:SERVER=LOCALHOST\SQLEXPRESS2008;Database=fatfree','fatfree', 'fatfree'
)*/
);
),
// 'sqlsrv2012' => new \DB\SQL(
// 'sqlsrv:SERVER=LOCALHOST\SQLEXPRESS2012;Database=fatfree','fatfree', 'fatfree'
// ),
// 'sqlsrv2008' => new \DB\SQL(
// 'sqlsrv:SERVER=LOCALHOST\SQLEXPRESS2008;Database=fatfree','fatfree', 'fatfree'
// )
);

$this->roundTime = microtime(TRUE) - \Base::instance()->get('timer');
$this->tname = 'test_table';
Expand Down Expand Up @@ -117,10 +117,27 @@ private function runTestSuite($db)
$this->getTestDesc('adding column ['.$field.'], nullable')
);
}

$r1 = $table->getCols(true);
foreach (array_keys($schema->dataTypes) as $index => $field) {
if (isset($r1['column_'.$index])) {
$datType=$schema->findQuery($schema->dataTypes[$field]);
$compatible = $schema->isCompatible($field,$r1['column_'.$index]['type']);
$this->test->expect(
$compatible,
$this->getTestDesc('reverse lookup compatible: '.
($compatible?'YES':'NO').
', '.$field.': ['.$datType.' > '.$r1['column_'.$index]['type'].']')
);
}
}
unset($r1);


// adding some testing data
$mapper = new \DB\SQL\Mapper($db, $this->tname);
$mapper->column_5 = 123.456;
$mapper->column_6 = 123456.789012;
$mapper->column_7 = 'hello world';
$mapper->save();
$mapper->reset();
Expand All @@ -130,11 +147,33 @@ private function runTestSuite($db)
$result['column_7'] == 'hello world',
$this->getTestDesc('mapping dummy data')
);
$this->test->expect(
$result['column_5'] == 123.456,
$this->getTestDesc('testing float value: '.$result['column_5'])
);
$this->test->expect(
$result['column_6'] == 123456.789012,
$this->getTestDesc('testing decimal value: '.$result['column_6'])
);


$mapper = new \DB\SQL\Mapper($db, $this->tname);
$mapper->load();
$num = $this->current_engine == 'sqlite' ? '123456789.012345' : '123456789012.345678';
$mapper->column_6 = $num;
$mapper->save();
$mapper->reset();
$result = $mapper->findone(array('column_7 = ?', 'hello world'))->cast();
$this->test->expect(
$result['column_6'] == $num,
$this->getTestDesc('testing max decimal precision: '.$result['column_6'])
);
unset($mapper);

// default value text, not nullable
$table->addColumn('text_default_not_null')
->type($schema::DT_VARCHAR128)
->nullable(false)->defaults('foo bar');
->type($schema::DT_VARCHAR128)
->nullable(false)->defaults('foo bar');
$table->build();
$r1 = $table->getCols(true);
$this->test->expect(
Expand All @@ -160,7 +199,7 @@ private function runTestSuite($db)

// default value numeric, not nullable
$table->addColumn('int_default_not_null')
->type($schema::DT_INT4)->nullable(false)->defaults(123);
->type($schema::DT_INT4)->nullable(false)->defaults(123);
$table->build();
$r1 = $table->getCols(true);
$this->test->expect(
Expand All @@ -187,8 +226,8 @@ private function runTestSuite($db)

// default value text, nullable
$table->addColumn('text_default_nullable')
->type($schema::DT_VARCHAR128)
->defaults('foo bar');
->type($schema::DT_VARCHAR128)
->defaults('foo bar');
$table->build();
$r1 = $table->getCols(true);
$this->test->expect(
Expand Down Expand Up @@ -253,9 +292,9 @@ private function runTestSuite($db)

// current timestamp
$table->addColumn('stamp')
->type($schema::DT_TIMESTAMP)
->nullable(false)
->defaults($schema::DF_CURRENT_TIMESTAMP);
->type($schema::DT_TIMESTAMP)
->nullable(false)
->defaults($schema::DF_CURRENT_TIMESTAMP);
$table->build();
$r1 = $table->getCols(true);
$this->test->expect(
Expand Down Expand Up @@ -321,7 +360,7 @@ private function runTestSuite($db)
$table->renameColumn('title123', 'text_default_not_null');
$table->build();
unset($result,$mapper);

// remove column
$table->dropColumn('column_1');
$table->build();
Expand Down Expand Up @@ -380,7 +419,7 @@ private function runTestSuite($db)
// adding composite primary keys
$table = $schema->createTable($this->tname);
$table->addColumn('version')->type($schema::DT_INT4)
->defaults(1)->nullable(false);
->defaults(1)->nullable(false);
$table->primary(array('id', 'version'));
$table = $table->build();
$r1 = $table->getCols(true);
Expand All @@ -399,7 +438,7 @@ private function runTestSuite($db)
$table->addColumn('title')->type($schema::DT_VARCHAR256);
$table->addColumn('title2')->type($schema::DT_TEXT);
$table->addColumn('title_notnull')
->type($schema::DT_VARCHAR128)->nullable(false)->defaults("foo");
->type($schema::DT_VARCHAR128)->nullable(false)->defaults("foo");
$table->build();
$r1 = $table->getCols(true);
$this->test->expect(
Expand Down Expand Up @@ -461,6 +500,18 @@ private function runTestSuite($db)
$this->getTestDesc('adding items with composite primary-keys')
);

$mapper = new \DB\SQL\Mapper($db, $this->tname);
$mapper->load();
$rec_count_cur = $mapper->loaded();
$schema->truncateTable($this->tname);
$mapper->reset();
$mapper->load();
$rec_count_new = $mapper->loaded();
$this->test->expect(
$rec_count_cur==3 && $rec_count_new == 0,
$this->getTestDesc('truncate table')
);

$schema->dropTable($this->tname);

// indexes
Expand Down Expand Up @@ -520,11 +571,54 @@ private function runTestSuite($db)
$table->updateColumn('bar',$schema::DT_TEXT);
$table->build();
$r1 = $table->getCols(true);
$text = preg_match('/sybase|dblib|odbc|sqlsrv/',$this->current_engine)
? 'nvarchar' : 'text';
$this->test->expect(
array_key_exists('bar', $r1) && $r1['bar']['type'] == 'text',
array_key_exists('bar', $r1) && $r1['bar']['type'] == $text,
$this->getTestDesc('update column')
);

// update column
$cols = $table->getCols(true);
$bar = $cols['bar'];
$col = new \DB\SQL\Column('bar',$table);
$col->copyfrom($bar);
$col->type_varchar(60);
$col->defaults('great');
$table->updateColumn('bar',$col);
$table->build();
$r1 = $table->getCols(true);
$this->test->expect(
array_key_exists('bar', $r1)
&& $r1['bar']['default'] == 'great',
$this->getTestDesc('update column and default')
);

// update column default only
$cols = $table->getCols(true);
$bar = $cols['bar'];
$col = new \DB\SQL\Column('bar',$table);
$col->copyfrom($bar);
$col->passThrough();
$col->defaults('');
$table->updateColumn('bar',$col);
$table->build();
$r1 = $table->getCols(true);
$this->test->expect(
array_key_exists('bar', $r1) && $r1['bar']['default'] == '',
$this->getTestDesc('update default value')
);

$col->nullable(false);
$table->updateColumn('bar',$col);
$table->build();
$r1 = $table->getCols(true);
$this->test->expect(
array_key_exists('bar', $r1) && $r1['bar']['nullable'] == false,
$this->getTestDesc('update nullable flag')
);


// create table with text not nullable column
$table2 = $schema->createTable($this->tname.'_notnulltext');
$table2->addColumn('desc')->type($schema::DT_TEXT)->nullable(false);
Expand All @@ -538,7 +632,37 @@ private function runTestSuite($db)
);
$table2->drop();


// boolean fields are actually bit/tinyint
$schema->dropTable($this->tname.'_notnullbool');
$table2 = $schema->createTable($this->tname.'_notnullbool');
$table2->addColumn('active')->type($schema::DT_BOOL)->nullable(false);
$table2 = $table2->build();
$r1 = $schema->getTables();
$r2 = $table2->getCols(true);
$this->test->expect(
in_array($this->tname.'_notnullbool', $r1) && array_key_exists('active', $r2)
&& $r2['active']['nullable']==false,
$this->getTestDesc('create new table with not nullable boolean column')
);

$table2->addColumn('active2')->type($schema::DT_BOOL)->nullable(false)->defaults(0);
$table2->addColumn('active3')->type($schema::DT_BOOL)->nullable(false)->defaults(1);
$table2->build();
$r1 = $schema->getTables();
$r2 = $table2->getCols(true);
$this->test->expect(
in_array($this->tname.'_notnullbool', $r1)
&& array_key_exists('active2', $r2) && $r2['active2']['nullable']==false &&
((int)$r2['active2']['default']==0||$r2['active2']['default']=='false')
&& array_key_exists('active3', $r2) && $r2['active3']['nullable']==false &&
((int)$r2['active3']['default']==1||$r2['active3']['default']=='true'),
$this->getTestDesc('add not nullable boolean columns with default to existing table')
);


$table2->drop();


}

}
7 changes: 7 additions & 0 deletions app/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ TZ = UTC
CACHE = folder=tmp/cache/
;CACHE = redis=localhost:6379

; Cache backend used by Session handler.
; default
; -If CACHE is enabled (see above), the same location is used for Session data (e.g. fileCache, RedisDB)
; mysql
; - Session data get stored in your 'PathfinderDB' table 'sessions' (faster)
SESSION_CACHE = mysql

; Callback functions ==============================================================================
ONERROR = Controller\Controller->showError
UNLOAD = Controller\Controller->unload
Expand Down
Loading

0 comments on commit 357e7b8

Please sign in to comment.