Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .env.testing
Original file line number Diff line number Diff line change
@@ -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
[email protected]
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}"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/storage/*.key
/vendor
.env
.env.testing
.env.backup
.phpunit.result.cache
docker-compose.override.yml
Expand Down
19 changes: 19 additions & 0 deletions config/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
5 changes: 3 additions & 2 deletions database/factories/UserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

g

'password' => Hash::make('test1234'), // password
'remember_token' => Str::random(10),
];
}
Expand Down
3 changes: 1 addition & 2 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@
<server name="APP_ENV" value="testing"/>
<server name="BCRYPT_ROUNDS" value="4"/>
<server name="CACHE_DRIVER" value="array"/>
<!-- <server name="DB_CONNECTION" value="sqlite"/> -->
<!-- <server name="DB_DATABASE" value=":memory:"/> -->
<server name="MAIL_MAILER" value="array"/>
<server name="QUEUE_CONNECTION" value="sync"/>
<server name="SESSION_DRIVER" value="array"/>
<server name="TELESCOPE_ENABLED" value="false"/>
<server name="DB_CONNECTION" value="mountain_test"/>
</php>
</phpunit>
52 changes: 52 additions & 0 deletions tests/Feature/Api/AdminTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

namespace Tests\Feature\Api;

use App\Models\Api\Admin;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Support\Facades\Hash;
use Tests\TestCase;
use Illuminate\Testing\Fluent\AssertableJson;

class AdminTest extends TestCase
{
/**
* A basic feature test example.
*
* @return void
*/


public function testFailedLogin ()
{
Admin::create([
'nick_name' => '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,
// ]);
// }
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<?php

namespace Tests\Feature;
namespace Tests\Feature\Api;

use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;

class ExampleTest extends TestCase
class NewsTest extends TestCase
{
/**
* A basic test example.
* A basic feature test example.
*
* @return void
*/
Expand Down
39 changes: 0 additions & 39 deletions tests/Feature/Api/RegisterUserTest.php.php

This file was deleted.

22 changes: 22 additions & 0 deletions tests/Feature/Feature/Api/AdminTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace Tests\Feature\Feature\Api;

use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;

class AdminTest extends TestCase
{
/**
* A basic feature test example.
*
* @return void
*/
public function test_example()
{
$response = $this->get('/');

$response->assertStatus(200);
}
}