diff --git a/.env.testing b/.env.testing
new file mode 100644
index 0000000..e854750
--- /dev/null
+++ b/.env.testing
@@ -0,0 +1,51 @@
+APP_NAME=testing
+APP_ENV=mountain_test
+APP_KEY=base64:dW8mf76HLLHs+FgYrVLSp3aW7VyTWZhw8gP2vKXJXo8=
+APP_DEBUG=true
+APP_URL=http://localhost
+
+LOG_CHANNEL=stack
+LOG_DEPRECATIONS_CHANNEL=null
+LOG_LEVEL=debug
+
+DB_CONNECTION=mysql
+DB_HOST=127.0.0.1
+DB_PORT=3306
+DB_DATABASE=mountain_test
+DB_USERNAME=root
+DB_PASSWORD=root
+
+BROADCAST_DRIVER=log
+CACHE_DRIVER=file
+FILESYSTEM_DRIVER=local
+QUEUE_CONNECTION=sync
+SESSION_DRIVER=file
+SESSION_LIFETIME=120
+
+MEMCACHED_HOST=127.0.0.1
+
+REDIS_HOST=127.0.0.1
+REDIS_PASSWORD=null
+REDIS_PORT=6379
+
+MAIL_DRIVER=smtp
+MAIL_HOST=smtp.gmail.com
+MAIL_PORT=465
+MAIL_USERNAME=msts.oo0131@gmail.com
+MAIL_PASSWORD=qvzbziunlagondly
+MAIL_ENCRYPTION=ssl
+MAIL_FROM_NAME=Newsletter
+
+AWS_ACCESS_KEY_ID=
+AWS_SECRET_ACCESS_KEY=
+AWS_DEFAULT_REGION=us-east-1
+AWS_BUCKET=
+AWS_USE_PATH_STYLE_ENDPOINT=false
+
+PUSHER_APP_ID=
+PUSHER_APP_KEY=
+PUSHER_APP_SECRET=
+PUSHER_APP_CLUSTER=mt1
+
+MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
+MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
diff --git a/.gitignore b/.gitignore
index eb003b0..5a39615 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,6 +4,7 @@
/storage/*.key
/vendor
.env
+.env.testing
.env.backup
.phpunit.result.cache
docker-compose.override.yml
diff --git a/config/database.php b/config/database.php
index b42d9b3..aafb25d 100644
--- a/config/database.php
+++ b/config/database.php
@@ -77,6 +77,25 @@
'schema' => 'public',
'sslmode' => 'prefer',
],
+ 'mountain_test' => [
+ 'driver' => 'mysql',
+ 'url' => env('DATABASE_URL'),
+ 'host' => env('DB_HOST', '127.0.0.1'),
+ 'port' => env('DB_PORT', '3306'),
+ 'database' => env('DB_DATABASE', 'forge'),
+ 'username' => env('DB_USERNAME', 'forge'),
+ 'password' => env('DB_PASSWORD', ''),
+ 'unix_socket' => env('DB_SOCKET', ''),
+ 'charset' => 'utf8mb4',
+ 'collation' => 'utf8mb4_unicode_ci',
+ 'prefix' => '',
+ 'prefix_indexes' => true,
+ 'strict' => true,
+ 'engine' => null,
+ 'options' => extension_loaded('pdo_mysql') ? array_filter([
+ PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
+ ]) : []
+ ],
'sqlsrv' => [
'driver' => 'sqlsrv',
diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php
index a3eb239..2acf810 100644
--- a/database/factories/UserFactory.php
+++ b/database/factories/UserFactory.php
@@ -4,6 +4,8 @@
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
+use Illuminate\Support\Facades\Hash;
+use Illuminate\Testing\Fluent\Concerns\Has;
class UserFactory extends Factory
{
@@ -17,8 +19,7 @@ public function definition()
return [
'name' => $this->faker->name(),
'email' => $this->faker->unique()->safeEmail(),
- 'email_verified_at' => now(),
- 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
+ 'password' => Hash::make('test1234'), // password
'remember_token' => Str::random(10),
];
}
diff --git a/phpunit.xml b/phpunit.xml
index 4ae4d97..1336036 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -21,11 +21,10 @@
-
-
+
diff --git a/tests/Feature/Api/AdminTest.php b/tests/Feature/Api/AdminTest.php
new file mode 100644
index 0000000..4cb7201
--- /dev/null
+++ b/tests/Feature/Api/AdminTest.php
@@ -0,0 +1,52 @@
+ 'test1234',
+ 'address'=>'test1234@com',
+ 'password' => bcrypt('secret123$'),
+ 'age' => '30',
+ 'sex' => '1'
+ ]);
+
+ $data = [
+ 'email' => '',
+ 'password' => 'secret123$',
+ ];
+
+ //attempt login
+ $response = $this->json('POST', redirect('http://127.0.0.1:8000/api/login'), $data);
+ //Assert it was successful and a token was received
+ $response->assertStatus(404);
+ }
+
+// public function testLoginSuccess()
+// {
+// // When the Parameter is null, response this errorMessages.
+// $response = $this->postJson('/api/login', ['email' => ''], ['password' => Hash::make('test1234')]);
+// $response
+// ->assertStatus(401)
+// ->assertJson([
+// 'created' => false,
+// ]);
+// }
+}
diff --git a/tests/Feature/ExampleTest.php b/tests/Feature/Api/NewsTest.php
similarity index 63%
rename from tests/Feature/ExampleTest.php
rename to tests/Feature/Api/NewsTest.php
index 4ae02bc..8df6028 100644
--- a/tests/Feature/ExampleTest.php
+++ b/tests/Feature/Api/NewsTest.php
@@ -1,14 +1,15 @@
json('POST', 'api/RegisterUser')
- ->assertStatus(401)
- ->assertJson([
- "message" => "Bad Request...",
- "errors" => [
- 'address' => ["The email field is required."],
- 'password' => ["The password field is required."],
- 'age' => ["The age filed is required."],
- 'sex' => ["The sex filed is required."],
- ]
- ]);
-
- // Success registerUser at here.
- $this->json('POST', 'api/RegisterUser')
- ->assertStatus(201)
- ->assertJson([
- "message" => "User was created successfully",
- ]);
-
- }
-}
diff --git a/tests/Feature/Feature/Api/AdminTest.php b/tests/Feature/Feature/Api/AdminTest.php
new file mode 100644
index 0000000..92fcccb
--- /dev/null
+++ b/tests/Feature/Feature/Api/AdminTest.php
@@ -0,0 +1,22 @@
+get('/');
+
+ $response->assertStatus(200);
+ }
+}