Skip to content

Commit

Permalink
Merge pull request #152 from WebFiori/dev
Browse files Browse the repository at this point in the history
Quality Improvements + Added Support for New Command
  • Loading branch information
usernane authored Aug 22, 2022
2 parents 5fe206c + e14d23e commit 1e21209
Show file tree
Hide file tree
Showing 56 changed files with 2,565 additions and 514 deletions.
8 changes: 8 additions & 0 deletions app/AppConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,14 @@ public function getWebsiteName(string $langCode) {
public function getWebsiteNames() : array {
return $this->webSiteNames;
}
/**
* Removes all stored database connections.
*
*
*/
public function removeDBConnections() {
$this->dbConnections = [];
}
/**
* @since 1.0
*/
Expand Down
1 change: 1 addition & 0 deletions app/apis/super/temp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions app/database/empl/temp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions app/database/super/temp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions app/entity/super/temp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
"require": {
"php": ">=7.0",
"webfiori/err":"v1.0.3",
"webfiori/cli":"v1.0.5",
"webfiori/cli":"v1.0.6",
"webfiori/file":"v1.2.1",
"webfiori/collections":"v1.1.1",
"webfiori/ui":"v2.3.4",
"webfiori/jsonx":"v3.1.4",
"webfiori/database":"v0.4.5",
"webfiori/http":"v3.2.14",
"webfiori/database":"v0.4.9",
"webfiori/http":"v3.2.16",
"webfiori/mailer":"v1.0.2"
},
"require-dev": {
Expand Down
31 changes: 10 additions & 21 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@
<file>./webfiori/framework/cli/commands/UpdateSettingsCommand.php</file>
<file>./webfiori/framework/cli/commands/UpdateTableCommand.php</file>
<file>./webfiori/framework/cli/commands/VersionCommand.php</file>
<file>./webfiori/framework/cli/writers/ClassWriter.php</file>
<file>./webfiori/framework/cli/writers/CronJobClassWriter.php</file>
<file>./webfiori/framework/cli/writers/LangClassWriter.php</file>
<file>./webfiori/framework/cli/writers/MiddlewareClassWriter.php</file>
<file>./webfiori/framework/cli/writers/TableClassWriter.php</file>
<file>./webfiori/framework/cli/writers/ThemeClassWriter.php</file>
<file>./webfiori/framework/cli/writers/WebServiceWriter.php</file>
<file>./webfiori/framework/writers/ClassWriter.php</file>
<file>./webfiori/framework/writers/CronJobClassWriter.php</file>
<file>./webfiori/framework/writers/LangClassWriter.php</file>
<file>./webfiori/framework/writers/MiddlewareClassWriter.php</file>
<file>./webfiori/framework/writers/TableClassWriter.php</file>
<file>./webfiori/framework/writers/ThemeClassWriter.php</file>
<file>./webfiori/framework/writers/WebServiceWriter.php</file>
<file>./webfiori/framework/writers/DBClassWriter.php</file>
<file>./webfiori/framework/cli/helpers/ClassInfoReader.php</file>
<file>./webfiori/framework/cli/helpers/CreateCLIClassHelper.php</file>
<file>./webfiori/framework/cli/helpers/CreateClassHelper.php</file>
Expand All @@ -58,20 +59,8 @@
<log type="coverage-clover" target="clover.xml"/>
</logging>
<testsuites>
<testsuite name="Language Tests">
<directory>./tests/webfiori/framework/test/langs/</directory>
</testsuite>
<testsuite name="Core Tests">
<directory>./tests/webfiori/framework/test/</directory>
</testsuite>
<testsuite name="Router Tests">
<directory>./tests/webfiori/framework/test/router/</directory>
</testsuite>
<testsuite name="Session Management Tests">
<directory>./tests/webfiori/framework/test/session/</directory>
</testsuite>
<testsuite name="CLI Tests">
<directory>./tests/webfiori/framework/test/cli/</directory>
<testsuite name="Tests">
<directory>./tests</directory>
</testsuite>
</testsuites>
</phpunit>
42 changes: 42 additions & 0 deletions tests/tables/EmployeeInfoTable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace tables;

use webfiori\database\mysql\MySQLTable;

/**
* Description of UserInfoTable
*
*/
class EmployeeInfoTable extends MySQLTable {

public function __construct() {
parent::__construct('users');
$this->addColumns([
'id' => [
'type' => 'int',
],
'email' => [
'type' => 'varchar',
'size' => 128
],
'first-name' => [
'type' => 'varchar',
'size' => 128
],
'last-name' => [
'type' => 'varchar',
'size' => 128,
'is-null' => true
],
'joining-date' => [
'type' => 'datetime',
],
'created-on' => [
'type' => 'timestamp',
'default' => 'now()'
]
]);
}

}
46 changes: 46 additions & 0 deletions tests/tables/PositionInfoTable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace tables;

use webfiori\database\mysql\MySQLTable;

/**
* Description of UserInfoTable
*
*/
class PositionInfoTable extends MySQLTable {

public function __construct() {
parent::__construct('users');
$this->addColumns([
'id' => [
'type' => 'int',
'unique' => true
],
'name' => [
'type' => 'varchar',
'size' => 128,
'unique' => true
],
'company' => [
'type' => 'varchar',
'size' => 128
],
'salary' => [
'type' => 'decimal',
'size' => 10,
'scale' => 2,
'default' => 0
],
'created-on' => [
'type' => 'timestamp',
'default' => 'now()'
],
'last-updated' => [
'type' => 'datetime',
'is-null' => true
]
]);
}

}
77 changes: 41 additions & 36 deletions tests/webfiori/framework/test/cli/AddCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
namespace webfiori\framework\test\cli;

use PHPUnit\Framework\TestCase;
use webfiori\framework\cli\commands\AddCommand;
use webfiori\cli\Runner;
use webfiori\file\File;
use webfiori\framework\cli\commands\AddCommand;
use webfiori\framework\ConfigController;
use webfiori\cli\Runner;
use webfiori\framework\WebFioriApp;

/**
* Description of TestAddCommand
Expand Down Expand Up @@ -34,40 +35,44 @@ public function test00() {
/**
* @test
*/
// public function testAddDBConnection00() {
// $runner = new CommandRunner([
// '0',
// '0',
// '127.0.0.1',
// '',
// 'root',
// '123456',
// 'testing_db',
// ''
// ]);
// $runner->runCommand(new AddCommand());
// $this->assertEquals(0, $runner->getExitStatus());
// $connName = 'db-connection-'.count(WebFioriApp::getAppConfig()->getDBConnections());
// $this->assertTrue($runner->isOutputEquals([
// "What would you like to add?\n",
// "0: New database connection.\n",
// "1: New SMTP connection.\n",
// "2: New website language.\n",
// "3: Quit. <--\n",
// "Select database type:\n",
// "0: mysql\n",
// "1: mssql\n",
// "Database host: Enter = \"127.0.0.1\"\n",
// "Port number: Enter = \"3306\"\n",
// "Username:\n",
// "Password:\n",
// "Database name:\n",
// "Give your connection a friendly name: Enter = \"$connName\"\n",
// "Trying to connect to the database...\n",
// "Success: Connected. Adding the connection...\n",
// 'Success: Connection information was stored in the class "'.APP_DIR_NAME.'\\AppConfig".'."\n"
// ], $this));
// }
public function testAddDBConnection00() {
$runner = WebFioriApp::getRunner();
$runner->setInput([
'0',
'0',
'127.0.0.1',
'',
'root',
'123456',
'testing_db',
''
]);
$runner->setArgsVector([
'webfiori',
'add'
]);
$this->assertEquals(0, $runner->start());
$connName = 'db-connection-'.count(WebFioriApp::getAppConfig()->getDBConnections());
$this->assertEquals([
"What would you like to add?\n",
"0: New database connection.\n",
"1: New SMTP connection.\n",
"2: New website language.\n",
"3: Quit. <--\n",
"Select database type:\n",
"0: mysql\n",
"1: mssql\n",
"Database host: Enter = '127.0.0.1'\n",
"Port number: Enter = '3306'\n",
"Username:\n",
"Password:\n",
"Database name:\n",
"Give your connection a friendly name: Enter = '$connName'\n",
"Trying to connect to the database...\n",
"Success: Connected. Adding the connection...\n",
'Success: Connection information was stored in the class "'.APP_DIR_NAME.'\\AppConfig".'."\n"
], $runner->getOutput());
}
/**
* @test
*/
Expand Down
Loading

0 comments on commit 1e21209

Please sign in to comment.