diff --git a/.travis.yml b/.travis.yml
index 43d2e5ccce..9aa4ab5f4b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -44,13 +44,13 @@ before_script:
- php artisan key:generate --no-interaction
- sed -i '$a NINJA_DEV=true' .env
# create the database and user
- - mysql -u root -e "create database IF NOT EXISTS ninja1;"
- - mysql -u root -e "create database IF NOT EXISTS ninja2;"
- - mysql -u root -e "GRANT ALL PRIVILEGES ON ninja1.* To 'ninja'@'localhost' IDENTIFIED BY 'ninja'; FLUSH PRIVILEGES;"
- - mysql -u root -e "GRANT ALL PRIVILEGES ON ninja2.* To 'ninja'@'localhost' IDENTIFIED BY 'ninja'; FLUSH PRIVILEGES;"
+ - mysql -u root -e "create database IF NOT EXISTS ninja01;"
+ - mysql -u root -e "create database IF NOT EXISTS ninja02;"
+ - mysql -u root -e "GRANT ALL PRIVILEGES ON ninja01.* To 'ninja'@'localhost' IDENTIFIED BY 'ninja'; FLUSH PRIVILEGES;"
+ - mysql -u root -e "GRANT ALL PRIVILEGES ON ninja02.* To 'ninja'@'localhost' IDENTIFIED BY 'ninja'; FLUSH PRIVILEGES;"
# migrate and seed the database
- - php artisan migrate --database=db-ninja-1 --seed --no-interaction
- - php artisan migrate --database=db-ninja-2 --seed --no-interaction
+ - php artisan migrate --database=db-ninja-01 --seed --no-interaction
+ - php artisan migrate --database=db-ninja-02 --seed --no-interaction
- php artisan optimize
# migrate and seed the database
diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php
index caa5ae30ea..40320675f1 100644
--- a/app/Http/Controllers/AccountController.php
+++ b/app/Http/Controllers/AccountController.php
@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
use App\Http\Requests\Account\CreateAccountRequest;
use App\Jobs\Account\CreateAccount;
+use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Http\Request;
class AccountController extends Controller
diff --git a/app/Http/Controllers/Traits/VerifiesUserEmail.php b/app/Http/Controllers/Traits/VerifiesUserEmail.php
new file mode 100644
index 0000000000..67192c3ccb
--- /dev/null
+++ b/app/Http/Controllers/Traits/VerifiesUserEmail.php
@@ -0,0 +1,27 @@
+first();
+
+ if ($user) {
+
+ $user->email_verified_at = now();
+ $user->confirmation_code = null;
+ $user->save();
+
+ redirect()->route('user.dashboard')->with('message', trans('texts.security_confirmation'));
+
+ }
+
+ redirect()->route('login')->with('message', trans('texts.wrong_confirmation'));
+
+ }
+}
\ No newline at end of file
diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php
index c00bb1157d..ca911bf224 100644
--- a/app/Http/Controllers/UserController.php
+++ b/app/Http/Controllers/UserController.php
@@ -2,29 +2,12 @@
namespace App\Http\Controllers;
-use App\Models\User;
+use App\Http\Controllers\Traits\VerifiesUserEmail;
use Illuminate\Http\Request;
class UserController extends Controller
{
+ use VerifiesUserEmail;
-
- public function confirm($code)
- {
- $user = User::where('confirmation_code', '=', $code)->get()->first();
-
- if ($user) {
-
- $user->email_verified_at = now();
- $user->confirmation_code = null;
- $user->save();
-
- redirect('user.dashboard')->with('message', trans('texts.security_confirmation'));
-
- } else {
-
- return Redirect::to('/login')->with('error', trans('texts.wrong_confirmation'));
- }
- }
}
diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php
index 01ef867504..26c5407bd8 100644
--- a/app/Http/Kernel.php
+++ b/app/Http/Kernel.php
@@ -44,6 +44,9 @@ class Kernel extends HttpKernel
'db' => [
\App\Http\Middleware\SetDb::class,
],
+ 'url-db' => [
+ \App\Http\Middleware\UrlSetDb::class,
+ ]
];
/**
diff --git a/app/Http/Middleware/UrlSetDb.php b/app/Http/Middleware/UrlSetDb.php
new file mode 100644
index 0000000000..324535c53a
--- /dev/null
+++ b/app/Http/Middleware/UrlSetDb.php
@@ -0,0 +1,36 @@
+decode($segments[0]);
+
+ MultiDB::setDB(MultiDB::DB_PREFIX . $hashed_db[0]);
+ }
+
+ return $next($request);
+ }
+}
diff --git a/app/Http/Middleware/setDb.php b/app/Http/Middleware/setDb.php
index 306a310ede..769909a9f0 100644
--- a/app/Http/Middleware/setDb.php
+++ b/app/Http/Middleware/setDb.php
@@ -18,9 +18,7 @@ class SetDb
{
if (config('ninja.db.multi_db_enabled'))
{
-
MultiDB::setDB(auth()->user()->db);
-
}
return $next($request);
diff --git a/app/Jobs/Account/CreateAccount.php b/app/Jobs/Account/CreateAccount.php
index 9172c3fd62..96c6e109cc 100644
--- a/app/Jobs/Account/CreateAccount.php
+++ b/app/Jobs/Account/CreateAccount.php
@@ -41,23 +41,13 @@ class CreateAccount
$account = Account::create($this->request->toArray());
- $user = CreateUser::dispatchNow($this->request, $account);
-
$company = CreateCompany::dispatchNow($this->request, $account);
- UserCompany::create([
- 'user_id' => $user->id,
- 'account_id' => $account->id,
- 'company_id' => $company->id,
- 'is_admin' => true,
- 'is_owner' => true,
- 'permissions' => '',
-
- ]);
+ $user = CreateUser::dispatchNow($this->request, $account, $company);
Auth::loginUsingId($user->id, true);
- event(new AccountCreated());
+ event(new AccountCreated($user));
return $user;
}
diff --git a/app/Jobs/User/CreateUser.php b/app/Jobs/User/CreateUser.php
index 9044e0dfd3..749fc8568b 100644
--- a/app/Jobs/User/CreateUser.php
+++ b/app/Jobs/User/CreateUser.php
@@ -2,6 +2,8 @@
namespace App\Jobs\User;
+use App\Models\User;
+use App\Models\UserCompany;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Http\Request;
use App\Models\Account;
@@ -15,16 +17,20 @@ class CreateUser
protected $request;
protected $account;
+
+ protected $company;
+
/**
* Create a new job instance.
*
* @return void
*/
- public function __construct(Request $request, $account)
+ public function __construct(Request $request, $account, $company)
{
$this->request = $request;
$this->account = $account;
+ $this->company = $company;
}
/**
@@ -37,7 +43,7 @@ class CreateUser
$user = new User();
$user->account_id = $this->account->id;
- $user->password = Hash::make($this->request->input('password'));
+ $user->password = bcrypt($this->request->input('password'));
$user->accepted_terms_version = config('ninja.terms_version');
$user->confirmation_code = strtolower(str_random(RANDOM_KEY_LENGTH));
$user->db = config('database.default');
@@ -45,6 +51,16 @@ class CreateUser
$user->save();
+ UserCompany::create([
+ 'user_id' => $user->id,
+ 'account_id' => $this->account->id,
+ 'company_id' => $this->company->id,
+ 'is_admin' => true,
+ 'is_owner' => true,
+ 'permissions' => '',
+
+ ]);
+
return $user;
}
}
diff --git a/app/Libraries/MultiDB.php b/app/Libraries/MultiDB.php
index a541bec4d0..7a5a39e818 100644
--- a/app/Libraries/MultiDB.php
+++ b/app/Libraries/MultiDB.php
@@ -10,11 +10,9 @@ use App\Models\User;
*/
class MultiDB
{
+ const DB_PREFIX = 'db-ninja-';
- const DB_NINJA_1 = 1;
- const DB_NINJA_2 = 2;
-
- public static $dbs = ['db-ninja-1', 'db-ninja-2'];
+ public static $dbs = ['db-ninja-01', 'db-ninja-02'];
/**
* @param $email
diff --git a/app/Models/Contact.php b/app/Models/ClientContact.php
similarity index 93%
rename from app/Models/Contact.php
rename to app/Models/ClientContact.php
index 2a27c85189..5a2274f4c9 100644
--- a/app/Models/Contact.php
+++ b/app/Models/ClientContact.php
@@ -7,7 +7,7 @@ use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
-class Contact extends Authenticatable
+class ClientContact extends Authenticatable
{
use Notifiable;
diff --git a/bootstrap/cache/.gitignore b/bootstrap/cache/.gitignore
old mode 100644
new mode 100755
diff --git a/composer.json b/composer.json
index 72b6a2fcf4..0e02324cbc 100644
--- a/composer.json
+++ b/composer.json
@@ -22,6 +22,7 @@
"asgrim/ofxparser": "^1.2",
"davejamesmiller/laravel-breadcrumbs": "5.x",
"fideloper/proxy": "^4.0",
+ "hashids/hashids": "^3.0",
"laracasts/presenter": "^0.2.1",
"laravel/framework": "5.7.*",
"laravel/socialite": "^3.1",
@@ -37,6 +38,7 @@
"beyondcode/laravel-dump-server": "^1.0",
"filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4",
+ "laravel/dusk": "^4.0",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^2.0",
"phpunit/phpunit": "^7.0"
diff --git a/composer.lock b/composer.lock
index 23f184fdda..5529d1505a 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "3cec8c5c70a52bc9011baabe117ac56c",
+ "content-hash": "8f50fadc77133971d60134045427a805",
"packages": [
{
"name": "asgrim/ofxparser",
@@ -662,6 +662,72 @@
],
"time": "2017-03-20T17:10:46+00:00"
},
+ {
+ "name": "hashids/hashids",
+ "version": "3.0.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/ivanakimov/hashids.php.git",
+ "reference": "b6c61142bfe36d43740a5419d11c351dddac0458"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/ivanakimov/hashids.php/zipball/b6c61142bfe36d43740a5419d11c351dddac0458",
+ "reference": "b6c61142bfe36d43740a5419d11c351dddac0458",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.1.3"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^7.0"
+ },
+ "suggest": {
+ "ext-bcmath": "Required to use BC Math arbitrary precision mathematics (*).",
+ "ext-gmp": "Required to use GNU multiple precision mathematics (*)."
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.0-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Hashids\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Ivan Akimov",
+ "email": "ivan@barreleye.com",
+ "homepage": "https://twitter.com/IvanAkimov"
+ },
+ {
+ "name": "Vincent Klaiber",
+ "email": "hello@vinkla.com",
+ "homepage": "https://vinkla.com"
+ }
+ ],
+ "description": "Generate short, unique, non-sequential ids (like YouTube and Bitly) from numbers",
+ "homepage": "http://hashids.org/php",
+ "keywords": [
+ "bitly",
+ "decode",
+ "encode",
+ "hash",
+ "hashid",
+ "hashids",
+ "ids",
+ "obfuscate",
+ "youtube"
+ ],
+ "time": "2018-03-12T16:30:09+00:00"
+ },
{
"name": "jakub-onderka/php-console-color",
"version": "v0.2",
@@ -3376,6 +3442,66 @@
],
"time": "2017-07-22T11:58:36+00:00"
},
+ {
+ "name": "facebook/webdriver",
+ "version": "1.6.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/facebook/php-webdriver.git",
+ "reference": "bd8c740097eb9f2fc3735250fc1912bc811a954e"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/facebook/php-webdriver/zipball/bd8c740097eb9f2fc3735250fc1912bc811a954e",
+ "reference": "bd8c740097eb9f2fc3735250fc1912bc811a954e",
+ "shasum": ""
+ },
+ "require": {
+ "ext-curl": "*",
+ "ext-json": "*",
+ "ext-mbstring": "*",
+ "ext-zip": "*",
+ "php": "^5.6 || ~7.0",
+ "symfony/process": "^2.8 || ^3.1 || ^4.0"
+ },
+ "require-dev": {
+ "friendsofphp/php-cs-fixer": "^2.0",
+ "jakub-onderka/php-parallel-lint": "^0.9.2",
+ "php-coveralls/php-coveralls": "^2.0",
+ "php-mock/php-mock-phpunit": "^1.1",
+ "phpunit/phpunit": "^5.7",
+ "sebastian/environment": "^1.3.4 || ^2.0 || ^3.0",
+ "squizlabs/php_codesniffer": "^2.6",
+ "symfony/var-dumper": "^3.3 || ^4.0"
+ },
+ "suggest": {
+ "ext-SimpleXML": "For Firefox profile creation"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-community": "1.5-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Facebook\\WebDriver\\": "lib/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "Apache-2.0"
+ ],
+ "description": "A PHP client for Selenium WebDriver",
+ "homepage": "https://github.com/facebook/php-webdriver",
+ "keywords": [
+ "facebook",
+ "php",
+ "selenium",
+ "webdriver"
+ ],
+ "time": "2018-05-16T17:37:13+00:00"
+ },
{
"name": "filp/whoops",
"version": "2.3.1",
@@ -3535,6 +3661,67 @@
],
"time": "2016-01-20T08:20:44+00:00"
},
+ {
+ "name": "laravel/dusk",
+ "version": "v4.0.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/laravel/dusk.git",
+ "reference": "9810f8609c8b53d9a3bac7d38c56530e0d77a6bb"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/laravel/dusk/zipball/9810f8609c8b53d9a3bac7d38c56530e0d77a6bb",
+ "reference": "9810f8609c8b53d9a3bac7d38c56530e0d77a6bb",
+ "shasum": ""
+ },
+ "require": {
+ "facebook/webdriver": "~1.3",
+ "illuminate/console": "~5.6",
+ "illuminate/support": "~5.6",
+ "nesbot/carbon": "~1.20",
+ "php": ">=7.1.0",
+ "symfony/console": "~4.0",
+ "symfony/process": "~4.0"
+ },
+ "require-dev": {
+ "mockery/mockery": "~1.0",
+ "phpunit/phpunit": "~7.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "4.0-dev"
+ },
+ "laravel": {
+ "providers": [
+ "Laravel\\Dusk\\DuskServiceProvider"
+ ]
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Laravel\\Dusk\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Taylor Otwell",
+ "email": "taylor@laravel.com"
+ }
+ ],
+ "description": "Laravel Dusk provides simple end-to-end testing and browser automation.",
+ "keywords": [
+ "laravel",
+ "testing",
+ "webdriver"
+ ],
+ "time": "2018-10-03T15:37:05+00:00"
+ },
{
"name": "mockery/mockery",
"version": "1.2.0",
diff --git a/config/cache.php b/config/cache.php
index 6c4629d2c5..ff4ff996e1 100644
--- a/config/cache.php
+++ b/config/cache.php
@@ -15,7 +15,7 @@ return [
|
*/
- 'default' => env('CACHE_DRIVER', 'file'),
+ 'default' => env('CACHE_DRIVER', 'redis'),
/*
|--------------------------------------------------------------------------
diff --git a/config/database.php b/config/database.php
index f1c1467cce..e307f79d4e 100644
--- a/config/database.php
+++ b/config/database.php
@@ -81,7 +81,7 @@ return [
'prefix_indexes' => true,
],
- 'db-ninja-1' => [
+ 'db-ninja-01' => [
'driver' => 'mysql',
'host' => env('DB_HOST1', env('DB_HOST', 'localhost')),
'database' => env('DB_DATABASE1', env('DB_DATABASE', 'forge')),
@@ -96,7 +96,7 @@ return [
'engine' => 'InnoDB',
],
- 'db-ninja-2' => [
+ 'db-ninja-02' => [
'driver' => 'mysql',
'host' => env('DB_HOST2', env('DB_HOST', 'localhost')),
'database' => env('DB_DATABASE2', env('DB_DATABASE', 'forge')),
diff --git a/config/telescope.php b/config/telescope.php
index 14546f9987..e7a618dda5 100644
--- a/config/telescope.php
+++ b/config/telescope.php
@@ -39,7 +39,7 @@ return [
|
*/
- 'limit' => env('TELESCOPE_LIMIT', 100),
+ 'limit' => env('TELESCOPE_LIMIT', null),
/*
|--------------------------------------------------------------------------
diff --git a/database/factories/CompanyFactory.php b/database/factories/CompanyFactory.php
index 13dbe0d86e..c8392a97b6 100644
--- a/database/factories/CompanyFactory.php
+++ b/database/factories/CompanyFactory.php
@@ -6,6 +6,7 @@ $factory->define(App\Models\Company::class, function (Faker $faker) {
return [
'name' => $faker->name,
'company_key' => strtolower(str_random(RANDOM_KEY_LENGTH)),
- 'ip' => $faker->ipv4
+ 'ip' => $faker->ipv4,
+ 'db' => config('database.default'),
];
});
diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php
index 2e0c4dc3f5..c5356a5184 100644
--- a/database/factories/UserFactory.php
+++ b/database/factories/UserFactory.php
@@ -18,9 +18,9 @@ $factory->define(App\Models\User::class, function (Faker $faker) {
'first_name' => $faker->name,
'last_name' => $faker->name,
'phone' => $faker->phoneNumber,
- 'email' => $faker->unique()->safeEmail,
+ 'email' => config('ninja.testvars.username'),
'email_verified_at' => now(),
- 'password' => '$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm', // secret
+ 'password' => bcrypt(config('ninja.testvars.password')), // secret
'remember_token' => str_random(10),
'db' => config('database.default')
];
diff --git a/database/migrations/2014_10_13_000000_create_users_table.php b/database/migrations/2014_10_13_000000_create_users_table.php
index 15198e3ad0..585ce128ad 100644
--- a/database/migrations/2014_10_13_000000_create_users_table.php
+++ b/database/migrations/2014_10_13_000000_create_users_table.php
@@ -138,6 +138,7 @@ class CreateUsersTable extends Migration
$table->unsignedInteger('industry_id')->nullable();
$table->unsignedInteger('size_id')->nullable();
$table->string('subdomain')->nullable();
+ $table->string('db')->nullable();
$table->timestamps();
$table->softDeletes();
diff --git a/database/seeds/UsersTableSeeder.php b/database/seeds/UsersTableSeeder.php
index da8ebe014c..3fa7467eda 100644
--- a/database/seeds/UsersTableSeeder.php
+++ b/database/seeds/UsersTableSeeder.php
@@ -2,7 +2,7 @@
use App\Models\Account;
use App\Models\Client;
-use App\Models\Contact;
+use App\Models\ClientContact;
use App\Models\User;
use App\Models\UserAccount;
use Illuminate\Database\Seeder;
@@ -25,41 +25,45 @@ class UsersTableSeeder extends Seeder
$faker = Faker\Factory::create();
- $account = Account::create([
- 'name' => $faker->name(),
- 'account_key' => strtolower(str_random(RANDOM_KEY_LENGTH)),
+ $account = factory(\App\Models\Account::class)->create();
+ $company = factory(\App\Models\Company::class)->create([
+ 'account_id' => $account->id,
]);
+ $account->default_company_id = $company->id;
+ $account->save();
+
$user = User::create([
+ 'account_id' => $account->id,
'first_name' => $faker->firstName,
'last_name' => $faker->lastName,
- 'email' => TEST_USERNAME,
- 'password' => Hash::make(TEST_PASSWORD),
+ 'email' => config('ninja.testvars.username'),
+ 'password' => Hash::make(config('ninja.testvars.password')),
'email_verified_at' => now(),
]);
$client = Client::create([
'name' => $faker->name,
- 'account_id' => $account->id,
+ 'company_id' => $company->id,
]);
- Contact::create([
+ ClientContact::create([
'first_name' => $faker->firstName,
'last_name' => $faker->lastName,
- 'email' => TEST_CLIENTNAME,
- 'account_id' => $account->id,
- 'password' => Hash::make(TEST_PASSWORD),
+ 'email' => config('ninja.testvars.clientname'),
+ 'company_id' => $company->id,
+ 'password' => Hash::make(config('ninja.testvars.password')),
'email_verified_at' => now(),
'client_id' =>$client->id,
]);
- UserAccount::create([
+ \App\Models\UserCompany::create([
'account_id' => $account->id,
+ 'company_id' => $company->id,
'user_id' => $user->id,
'is_owner' => 1,
'is_admin' => 1,
'is_locked' => 0,
- 'is_default' => 1,
]);
}
}
diff --git a/phpunit.xml b/phpunit.xml
index b1a670b098..7aa7959997 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -16,6 +16,10 @@
./tests/Integration
+
+
+ ./tests/Feature
+
diff --git a/routes/web.php b/routes/web.php
index 4e62ec8fc3..b564a32e77 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -38,9 +38,6 @@ Route::get('auth/{provider}/callback', 'Auth\LoginController@handleProviderCallb
* Authenticated User Routes
*/
-Auth::routes(['verify' => true]);
-
-
Route::group(['middleware' => ['auth:user', 'db']], function () {
Route::get('dashboard', 'HomeController@user')->name('user.dashboard');
@@ -53,8 +50,11 @@ Route::group(['middleware' => ['auth:user', 'db']], function () {
/*
* Inbound routes requiring DB Lookup
*/
-Route::get('/user/confirm/{confirmation_code}', 'UserController@confirm');
+Route::group(['middleware' => ['auth:user', 'db']], function () {
+ Route::get('/user/confirm/{confirmation_code}', 'UserController@confirm');
+
+});
/*
Authenticated Contact Routes
*/
diff --git a/tests/Browser/CreateAccountTest.php b/tests/Browser/CreateAccountTest.php
new file mode 100644
index 0000000000..7905f7cdb6
--- /dev/null
+++ b/tests/Browser/CreateAccountTest.php
@@ -0,0 +1,56 @@
+get('/signup');
+ $response->assertStatus(200);
+ }
+ /**
+ * A valid user can be logged in.
+ *
+ * @return void
+ */
+ public function testCreateAValidUser()
+ {
+ /*
+ $response = $this->post('/signup', [
+ 'first_name' => $this->faker->firstName(),
+ 'last_name' => $this->faker->lastName(),
+ 'terms_of_service' => 1,
+ 'privacy_policy' => 1,
+ 'email' => config('ninja.testvars.username'),
+ 'password' => config('ninja.testvars.password')
+ ]);
+
+
+ $response->assertSuccessful();
+ */
+
+ $this->visit('/signup')
+ ->type($this->faker->firstName(), 'first_name')
+ ->type($this->faker->lastName(), 'last_name')
+ ->type($this->faker->email(), 'email')
+ ->type($this->faker->password(7), 'password')
+ ->check('terms_of_service')
+ ->check('terms_of_service')
+ ->press(trans('texts.create_account'))
+ ->seePageIs('/dashboard');
+
+ }
+
+}
diff --git a/tests/Browser/ExampleTest.php b/tests/Browser/ExampleTest.php
new file mode 100644
index 0000000000..3827756b4a
--- /dev/null
+++ b/tests/Browser/ExampleTest.php
@@ -0,0 +1,23 @@
+browse(function (Browser $browser) {
+ $browser->visit('/')
+ ->assertSee('Laravel');
+ });
+ }
+}
diff --git a/tests/Browser/Pages/HomePage.php b/tests/Browser/Pages/HomePage.php
new file mode 100644
index 0000000000..4f5a87f4cb
--- /dev/null
+++ b/tests/Browser/Pages/HomePage.php
@@ -0,0 +1,41 @@
+ '#selector',
+ ];
+ }
+}
diff --git a/tests/Browser/Pages/Page.php b/tests/Browser/Pages/Page.php
new file mode 100644
index 0000000000..f8d76222c0
--- /dev/null
+++ b/tests/Browser/Pages/Page.php
@@ -0,0 +1,20 @@
+ '#selector',
+ ];
+ }
+}
diff --git a/tests/Browser/console/.gitignore b/tests/Browser/console/.gitignore
new file mode 100644
index 0000000000..d6b7ef32c8
--- /dev/null
+++ b/tests/Browser/console/.gitignore
@@ -0,0 +1,2 @@
+*
+!.gitignore
diff --git a/tests/Browser/screenshots/.gitignore b/tests/Browser/screenshots/.gitignore
new file mode 100644
index 0000000000..d6b7ef32c8
--- /dev/null
+++ b/tests/Browser/screenshots/.gitignore
@@ -0,0 +1,2 @@
+*
+!.gitignore
diff --git a/tests/DuskTestCase.php b/tests/DuskTestCase.php
new file mode 100644
index 0000000000..1261c7a6d7
--- /dev/null
+++ b/tests/DuskTestCase.php
@@ -0,0 +1,43 @@
+addArguments([
+ '--disable-gpu',
+ '--headless'
+ ]);
+
+ return RemoteWebDriver::create(
+ 'http://localhost:9515', DesiredCapabilities::chrome()->setCapability(
+ ChromeOptions::CAPABILITY, $options
+ )
+ );
+ }
+}
diff --git a/tests/Feature/LoginTest.php b/tests/Feature/LoginTest.php
new file mode 100644
index 0000000000..4b0cd61e61
--- /dev/null
+++ b/tests/Feature/LoginTest.php
@@ -0,0 +1,79 @@
+get('/login');
+ $response->assertStatus(200);
+ }
+ /**
+ * A valid user can be logged in.
+ *
+ * @return void
+ */
+ public function testLoginAValidUser()
+ {
+ $account = factory(Account::class)->create();
+ $user = factory(User::class)->create([
+ 'account_id' => $account->id,
+ ]);
+
+ $response = $this->post('/login', [
+ 'email' => config('ninja.testvars.username'),
+ 'password' => config('ninja.testvars.password')
+ ]);
+
+ $response->assertStatus(302);
+ $this->assertAuthenticatedAs($user);
+ }
+
+ /**
+ * An invalid user cannot be logged in.
+ *
+ * @return void
+ */
+ public function testDoesNotLoginAnInvalidUser()
+ {
+ $account = factory(Account::class)->create();
+ $user = factory(User::class)->create([
+ 'account_id' => $account->id,
+ ]);
+
+ $response = $this->post('/login', [
+ 'email' => config('ninja.testvars.username'),
+ 'password' => 'invalid'
+ ]);
+
+ $response->assertSessionHasErrors();
+ $this->assertGuest();
+ }
+ /**
+ * A logged in user can be logged out.
+ *
+ * @return void
+ */
+ public function testLogoutAnAuthenticatedUser()
+ {
+ $account = factory(Account::class)->create();
+ $user = factory(User::class)->create([
+ 'account_id' => $account->id,
+ ]);
+
+ $response = $this->actingAs($user)->post('/logout');
+ $response->assertStatus(302);
+ $this->assertGuest();
+ }
+}
diff --git a/tests/Integration/MultiDBUserTest.php b/tests/Integration/MultiDBUserTest.php
index a60742061b..f9ce55c907 100644
--- a/tests/Integration/MultiDBUserTest.php
+++ b/tests/Integration/MultiDBUserTest.php
@@ -35,8 +35,8 @@ class MultiDBUserTest extends TestCase
$ac = factory(\App\Models\Account::class)->make();
- $account = Account::on('db-ninja-1')->create($ac->toArray());
- $account2 = Account::on('db-ninja-2')->create($ac->toArray());
+ $account = Account::on('db-ninja-01')->create($ac->toArray());
+ $account2 = Account::on('db-ninja-02')->create($ac->toArray());
$company = factory(\App\Models\Company::class)->make([
'account_id' => $account->id,
@@ -46,8 +46,8 @@ class MultiDBUserTest extends TestCase
'account_id' => $account2->id,
]);
- Company::on('db-ninja-1')->create($company->toArray());
- Company::on('db-ninja-2')->create($company2->toArray());
+ Company::on('db-ninja-01')->create($company->toArray());
+ Company::on('db-ninja-02')->create($company2->toArray());
$user = [
'first_name' => 'user_db_1',
@@ -77,8 +77,8 @@ class MultiDBUserTest extends TestCase
];
- User::on('db-ninja-1')->create($user);
- User::on('db-ninja-2')->create($user2);
+ User::on('db-ninja-01')->create($user);
+ User::on('db-ninja-02')->create($user2);
}
public function test_oauth_user_db2_exists()
@@ -113,12 +113,12 @@ class MultiDBUserTest extends TestCase
public function test_set_db_invokes()
{
- $this->expectNotToPerformAssertions(MultiDB::setDB('db-ninja-1'));
+ $this->expectNotToPerformAssertions(MultiDB::setDB('db-ninja-01'));
}
public function tearDown()
{
- DB::connection('db-ninja-1')->table('users')->delete();
- DB::connection('db-ninja-2')->table('users')->delete();
+ DB::connection('db-ninja-01')->table('users')->delete();
+ DB::connection('db-ninja-02')->table('users')->delete();
}
}
diff --git a/tests/Integration/UniqueEmailTest.php b/tests/Integration/UniqueEmailTest.php
index ddeec35dae..8fc6019320 100644
--- a/tests/Integration/UniqueEmailTest.php
+++ b/tests/Integration/UniqueEmailTest.php
@@ -29,15 +29,15 @@ class UniqueEmailTest extends TestCase
if (! config('ninja.db.multi_db_enabled'))
$this->markTestSkipped('Multi DB not enabled - skipping');
- DB::connection('db-ninja-1')->table('users')->delete();
- DB::connection('db-ninja-2')->table('users')->delete();
+ DB::connection('db-ninja-01')->table('users')->delete();
+ DB::connection('db-ninja-02')->table('users')->delete();
$this->rule = new UniqueUserRule();
$ac = factory(\App\Models\Account::class)->make();
- $account = Account::on('db-ninja-1')->create($ac->toArray());
- $account2 = Account::on('db-ninja-2')->create($ac->toArray());
+ $account = Account::on('db-ninja-01')->create($ac->toArray());
+ $account2 = Account::on('db-ninja-02')->create($ac->toArray());
$company = factory(\App\Models\Company::class)->make([
'account_id' => $account->id,
@@ -47,8 +47,8 @@ class UniqueEmailTest extends TestCase
'account_id' => $account2->id,
]);
- Company::on('db-ninja-1')->create($company->toArray());
- Company::on('db-ninja-2')->create($company2->toArray());
+ Company::on('db-ninja-01')->create($company->toArray());
+ Company::on('db-ninja-02')->create($company2->toArray());
$user = [
@@ -67,8 +67,8 @@ class UniqueEmailTest extends TestCase
'account_id' => $account2->id,
];
- User::on('db-ninja-1')->create($user);
- User::on('db-ninja-2')->create($user2);
+ User::on('db-ninja-01')->create($user);
+ User::on('db-ninja-02')->create($user2);
}
@@ -88,8 +88,8 @@ class UniqueEmailTest extends TestCase
public function tearDown()
{
- DB::connection('db-ninja-1')->table('users')->delete();
- DB::connection('db-ninja-2')->table('users')->delete();
+ DB::connection('db-ninja-01')->table('users')->delete();
+ DB::connection('db-ninja-02')->table('users')->delete();
}
}
\ No newline at end of file