Merge branch 'master' of gitlab.com:CIEFWorldwideSdnBhd/exchange into fix/notification

# Conflicts:
#	composer.lock
This commit is contained in:
Jack Goh
2018-08-07 14:48:03 +08:00
45 changed files with 324 additions and 5445 deletions
+18
View File
@@ -0,0 +1,18 @@
APP_ENV=phpunit
APP_DEBUG=true
APP_KEY=w7VQXeA7U31DCdh1U39lpRz0iD7i0oCI
APP_URL=http://localhost
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=default
DB_USERNAME=default
DB_PASSWORD=secret
CACHE_DRIVER=array
SESSION_DRIVER=array
QUEUE_DRIVER=sync
MAIL_DRIVER=log
JWT_SECRET=FwYx3SPFxjpEDxAwcaSIV6eExQiMtGWx
+2 -1
View File
@@ -19,4 +19,5 @@ yarn-error.log
.env.prod
vendor/composer/autoload_static.php
vendor/composer/autoload_classmap.php
package-lock.json
package-lock.json
composer.lock
+35
View File
@@ -0,0 +1,35 @@
#!/bin/bash
# Install dependencies only for Docker.
[[ ! -e /.dockerenv ]] && exit 0
set -xe
# Update packages and install composer and PHP dependencies.
apt-get update -yqq
apt-get install git libgd-dev libcurl4-gnutls-dev libicu-dev libmcrypt-dev libvpx-dev libjpeg-dev libpng-dev libxpm-dev zlib1g-dev libfreetype6-dev libxml2-dev libexpat1-dev libbz2-dev libgmp3-dev libldap2-dev unixodbc-dev libpq-dev libsqlite3-dev libaspell-dev libsnmp-dev libpcre3-dev libtidy-dev -yqq
# Compile PHP, include these extensions.
docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/
docker-php-ext-install mbstring pdo_mysql curl json intl gd xml zip bz2 opcache
# Install Composer and project dependencies.
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
composer install
# Copy over testing configuration.
cp .env.testing .env
# Install xdebug
#pecl install xdebug && docker-php-ext-enable xdebug
# Generate an application key. Re-cache.
php artisan key:generate
php artisan jwt:secret
php artisan config:cache
php artisan config:clear
# php artisan optimize // remove after laravel 5.6
# Run database migrations with seeder
php artisan migrate:refresh --seed
+34
View File
@@ -0,0 +1,34 @@
before_script:
- bash .gitlab-ci.sh
stages:
- testing
- staging
variables:
MYSQL_DATABASE: default
MYSQL_USER: default
MYSQL_PASSWORD: secret
MYSQL_ROOT_PASSWORD: root
unitTesting:
stage: testing
image: php:7.2.6
services:
- mysql:5.7
script:
- vendor/bin/phpunit --coverage-text --colors=never
staging:
stage: staging
before_script:
- mkdir -p ~/.ssh
- echo -e "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
- chmod 400 ~/.ssh/id_rsa
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
script:
- ssh izyim@40.76.84.105 "cd exchange && git pull origin master && sudo docker-compose -f docker-prod.yml up -d"
environment:
name: staging
url: https://exchange-staging.izyim.com/
when: manual
+12 -9
View File
@@ -1,21 +1,24 @@
# Changelog
## 4.1.0 - 2018-03-14
## 1.0.0-alpha - 2018-08-02
- Release 1.0.0
## 4.1.0-dev - 2018-03-14
- Upgrade to Laravel 5.6
- Update npm dependencies
- Enabled Mix [esModule](https://github.com/JeffreyWay/laravel-mix/pull/1526#issuecomment-373044182) by default
- Lint with eslint-plugin-vue and eslint-config-standard
## 4.0.0 - 2018-01-23
## 4.0.0-dev - 2018-01-23
- Brought back the `layout` property in pages that was removed in 3.0. By default it's set to `default` (`~/layouts/default.vue`).
## 3.0.1 - 2018-01-22
## 3.0.1-dev - 2018-01-22
- Removed middleware from routes, since they don't work when you press the back button. Now you have to use the `middleware` property in pages.
## 3.0.0 - 2018-01-22
## 3.0.0-dev - 2018-01-22
- Removed `layout` property from pages in favor of explicit layout components
- Improved middleware system, you can either define it on a route or directly on a component
@@ -23,23 +26,23 @@
- Change jwt token ttl to one day
- Fixed hot module replacement
## 2.2.1 - 2018-01-19
## 2.2.1-dev - 2018-01-19
- Upgrade to Bootstrap 4
## 2.2.0 - 2018-01-16
## 2.2.0-dev - 2018-01-16
- Added dynamic import for pages
- Added locale with dynamic import
- Import shakable fontawesome module
## 2.1.0 - 2018-01-10
## 2.1.0-dev - 2018-01-10
- Simplifyd password reset
- Upgrade to Bootstrap 4 beta3
- Added oauth with popup window
## 2.0.0 - 2017-12-19
## 2.0.0-dev - 2017-12-19
- Added support for Socialite
- Added dropdown to select the locale
@@ -52,7 +55,7 @@
- Namespaced store modules
- Published project to Packagist
## 1.0.0 - 2017-09-02
## 1.0.0-dev - 2017-09-02
- Upgrade to Laravel 5.5.
- Upgrade to Bootstrap 4 beta1.
+8
View File
@@ -1,3 +1,11 @@
# Build frontend assets
FROM node as frontend
WORKDIR /app
ADD . /app
RUN npm install
RUN npm run production
# Build backend
FROM php:7.1.3
RUN apt-get update -y && apt-get install -y openssl zip unzip git zlib1g-dev netcat mysql-client libgd-dev libfreetype6-dev libjpeg62-turbo-dev libpng12-dev
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
@@ -8,6 +8,8 @@ use App\Http\Controllers\Controller;
use App\Exceptions\EmailTakenException;
use Laravel\Socialite\Facades\Socialite;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Tymon\JWTAuth\Facades\JWTAuth;
use Tymon\JWTAuth\Exceptions\JWTException;
class OAuthController extends Controller
{
+1 -1
View File
@@ -76,7 +76,7 @@ class BookingController extends Controller
}
return $bookings;
}
}
public function adminIndex(){
$user = Auth::user();
+1
View File
@@ -61,6 +61,7 @@ class Kernel extends HttpKernel
'ability' => 'App\Http\Middleware\TokenEntrustAbility',
'role' => \Zizaco\Entrust\Middleware\EntrustRole::class,
'permission' => \Zizaco\Entrust\Middleware\EntrustPermission::class,
'jwt' => \App\Http\Middleware\RefreshToken::class,
'ability' => 'App\Http\Middleware\TokenEntrustAbility'
];
}
+1 -1
View File
@@ -5,7 +5,7 @@ namespace App\Http\Middleware;
use Closure;
use Tymon\JWTAuth\Exceptions\JWTException;
use Tymon\JWTAuth\Exceptions\TokenExpiredException;
use Tymon\JWTAuth\Middleware\BaseMiddleware;
use Tymon\JWTAuth\Http\Middleware\BaseMiddleware;
class TokenEntrustAbility extends BaseMiddleware
{
Generated
-5227
View File
File diff suppressed because it is too large Load Diff
+4
View File
@@ -169,6 +169,7 @@ return [
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
Tymon\JWTAuth\Providers\LaravelServiceProvider::class
],
/*
@@ -219,6 +220,9 @@ return [
'View' => Illuminate\Support\Facades\View::class,
'Html' => Collective\Html\HtmlFacade::class,
'Entrust' => Zizaco\Entrust\EntrustFacade::class,
'JWTAuth' => Tymon\JWTAuth\Facades\JWTAuth::class,
'JWTFactory' => Tymon\JWTAuth\Facades\JWTFactory::class,
],
];
+4 -4
View File
@@ -50,7 +50,7 @@ return [
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => false,
'strict' => true,
'engine' => null,
],
@@ -58,9 +58,9 @@ return [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '3306'),
'database' => 'forunittest',
'username' => 'root',
'password' => '',
'database' => 'phpunit',
'username' => 'default',
'password' => 'secret',
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
+2 -2
View File
@@ -21,6 +21,6 @@ $factory->define(App\User::class, function (Faker $faker) {
'email' => $faker->unique()->safeEmail,
'password' => $password ?: $password = bcrypt('secret'),
'remember_token' => str_random(10),
'marking' => $faker->name,
'marking' => $faker->name,
];
});
});
@@ -17,7 +17,7 @@ class CreateSettingSuppliersTable extends Migration
$table->increments('id');
$table->string('company_name');
$table->string('gst_no');
$table->string('supplier_reg_no');
$table->string('supplier_reg_no')->nullable();
$table->string('bank_name');
$table->string('acc_no');
$table->timestamps();
@@ -21,7 +21,7 @@ class CreateChinaBankSlipsTable extends Migration
$table->string('bank_address');
$table->string('swift');
$table->string('cnap');
$table->string('bank _branch');
$table->string('bank_branch');
$table->string('order_id');
$table->double('transfer_amount_needed');
$table->double('actual_transfer_amount');
@@ -17,7 +17,7 @@ class CreatePurchaseOrdersTable extends Migration
$table->increments('id');
$table->string('image_url');
$table->double('amount');
$table->integer('book_id')->unsigned();
$table->integer('book_id')->unsigned()->nullable;
$table->foreign('book_id')->references('id')->on('bookings');
$table->timestamps();
});
@@ -14,7 +14,7 @@ class AddTimeLimitSettingCreditTable extends Migration
public function up()
{
Schema::table('setting_credits', function (Blueprint $table) {
$table->integer('time_limit');
$table->integer('time_limit')->nullable();
});
}
@@ -26,7 +26,7 @@ class AddTimeLimitSettingCreditTable extends Migration
public function down()
{
Schema::table('setting_credits', function (Blueprint $table) {
// $table->dropColumn('time_limit');
$table->dropColumn('time_limit');
});
}
}
@@ -14,7 +14,7 @@ class AddEtaUserBankSlipTable extends Migration
public function up()
{
Schema::table('user_bank_slips', function (Blueprint $table) {
$table->integer('estimated_arrival_time');
$table->integer('estimated_arrival_time')->nullable();
});
}
@@ -27,7 +27,7 @@ class AddEtaUserBankSlipTable extends Migration
{
if (Schema::hasColumn('user_bank_slips', 'estimated_arrival_time')) {
Schema::table('user_bank_slips', function (Blueprint $table) {
// $table->dropColumn('estimated_arrival_time');
$table->dropColumn('estimated_arrival_time');
});
}
}
@@ -15,7 +15,7 @@ class AddBookingidForeignkeyToChinabankslipTable extends Migration
{
Schema::table('china_bank_slips', function($table)
{
$table->integer('booking_id')->unsigned();
$table->integer('booking_id')->unsigned()->nullable();
$table->foreign('booking_id')->references('id')->on('bookings');
});
}
@@ -17,7 +17,7 @@ class RenameBookingForeignkeyInPoTable extends Migration
{
$table->dropForeign(['book_id']);
$table->dropColumn('book_id');
$table->integer('booking_id')->unsigned();
$table->integer('booking_id')->unsigned()->nullable();
$table->foreign('booking_id')->references('id')->on('bookings');
});
}
@@ -17,7 +17,7 @@ class RenameBookingForeignkeyFromSupplierbookingTable extends Migration
{
$table->dropForeign(['book_id']);
$table->dropColumn('book_id');
$table->integer('booking_id')->unsigned();
$table->integer('booking_id')->unsigned()->nullable();
$table->foreign('booking_id')->references('id')->on('bookings');
});
}
@@ -15,7 +15,7 @@ class AddBillingFieldToSupplierbookingTable extends Migration
{
Schema::table('supplier_bookings', function($table)
{
$table->double('billing_amount');
$table->double('billing_amount')->nullable();
});
}
@@ -26,6 +26,8 @@ class AddBillingFieldToSupplierbookingTable extends Migration
*/
public function down()
{
//
Schema::table('supplier_bookings', function (Blueprint $table) {
$table->dropColumn('billing_amount');
});
}
}
@@ -15,7 +15,7 @@ class AddSalestaxFieldToSupplierbookingTable extends Migration
{
Schema::table('supplier_bookings', function($table)
{
$table->double('salestax_amount');
$table->double('salestax_amount')->nullable();
});
}
@@ -26,6 +26,8 @@ class AddSalestaxFieldToSupplierbookingTable extends Migration
*/
public function down()
{
//
Schema::table('supplier_bookings', function (Blueprint $table) {
$table->dropColumn('salestax_amount');
});
}
}
@@ -15,7 +15,7 @@ class AddNameInUsersTable extends Migration
{
Schema::table('users', function($table)
{
$table->string('name');
$table->string('name')->nullable();
});
}
@@ -15,7 +15,7 @@ class AddMarkingToUserTable extends Migration
{
Schema::table('users', function($table)
{
$table->string('marking');
$table->string('marking')->nullable();
});
}
@@ -25,7 +25,10 @@ class AddMarkingToUserTable extends Migration
* @return void
*/
public function down()
{
//
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('marking');
});
}
}
@@ -17,7 +17,7 @@ class CreateSettingActiveBankTable extends Migration
$table->increments('id');
$table->string('x1_bank_id')->unique();
$table->string('x2_bank_id')->unique();
$table->string('beneficiary_id')->unique();
$table->string('beneficiary_id')->nullable();
$table->foreign('x1_bank_id')
->references('acc_no')->on('setting_malaysia_banks')
->onDelete('cascade');
@@ -1,51 +0,0 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class UpdateAccnoToIdSettingActiveTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('setting_active_banks', function(Blueprint $table)
{
$table->dropForeign('setting_active_banks_x1_bank_id_foreign');
$table->dropForeign('setting_active_banks_x2_bank_id_foreign');
$table->dropForeign('setting_active_banks_beneficiary_id_foreign');
$table->dropColumn('x1_bank_id');
$table->dropColumn('x2_bank_id');
$table->dropColumn('beneficiary_id');
});
Schema::table('setting_active_banks', function(Blueprint $table)
{
$table->unsignedInteger('x1_bank_id')->unique();
$table->foreign('x1_bank_id')
->references('id')->on('setting_malaysia_banks');
$table->unsignedInteger('x2_bank_id')->unique();
$table->foreign('x2_bank_id')
->references('id')->on('setting_malaysia_banks');
$table->unsignedInteger('beneficiary_id')->unique();
$table->foreign('beneficiary_id')
->references('id')->on('setting_beneficiaries');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}
@@ -1,33 +0,0 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class MakeChinaBeneficiaryAccNulabbleInBeneficiarysettingTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('setting_active_banks', function (Blueprint $table) {
$table->dropForeign('setting_active_banks_beneficiary_id_foreign');
$table->integer('beneficiary_id')->nullable()->unsigned()->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('beneficiarysetting', function (Blueprint $table) {
//
});
}
}
@@ -15,7 +15,7 @@ class AddOrdernoNPaymentforFieldToBookingsTable extends Migration
{
Schema::table('bookings', function (Blueprint $table) {
$table->string('order_no')->nullable();
$table->string('payment_for');
$table->string('payment_for')->nullable();
});
}
@@ -0,0 +1,43 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class MakeNullableInChinaBankSlipsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('china_bank_slips', function (Blueprint $table) {
$table->string('company_name')->nullable()->change();
$table->string('bank_name')->nullable()->change();
$table->string('acc_no')->nullable()->change();
$table->string('bank_address')->nullable()->change();
$table->string('swift')->nullable()->change();
$table->string('cnap')->nullable()->change();
$table->string('bank_branch')->nullable()->change();
$table->string('order_id')->nullable()->change();
$table->decimal('transfer_amount_needed')->nullable()->change();
$table->decimal('actual_transfer_amount')->nullable()->change();
$table->string('date')->nullable()->change();
$table->string('details')->nullable()->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('china_bank_slips', function (Blueprint $table) {
//
});
}
}
+14 -14
View File
@@ -132,21 +132,21 @@ class RolesAndPermissionsSeeder extends Seeder {
}
$this->command->info($commandBullet."Attached $pcount permissions to $role[name] role");
// Update old records
if ($originalRole)
{
$userCount = 0;
$RoleUsers = DB::table(Config::get('entrust.role_user_table'))->where('role_id',$originalRole->id)->get();
foreach ($RoleUsers as $user) {
$u = User::where('id',$user->user_id)->first();
$u->attachRole($newRole);
$userCount++;
}
$this->command->info($commandBullet."Updated role attachment for $userCount users");
// Update old records : Temporary disabled
// if ($originalRole)
// {
// $userCount = 0;
// $RoleUsers = DB::table(Config::get('entrust.role_user_table'))->where('role_id',$originalRole->id)->get();
// foreach ($RoleUsers as $user) {
// $u = User::where('id',$user->user_id)->first();
// $u->attachRole($newRole);
// $userCount++;
// }
// $this->command->info($commandBullet."Updated role attachment for $userCount users");
Role::where('id',$originalRole->id)->delete(); // will also remove old role_user records
$this->command->info($commandBullet."Removed the original $role[name] role");
}
// Role::where('id',$originalRole->id)->delete(); // will also remove old role_user records
// $this->command->info($commandBullet."Removed the original $role[name] role");
// }
}
+2 -2
View File
@@ -15,13 +15,13 @@ class SettingActiveBankSeeder extends Seeder
{
$bankx1 = SettingMalaysiaBank::find(1);
$bankx2 = SettingMalaysiaBank::find(2);
$chinabank = SettingBeneficiary::where('acc_no', "=" ,'123456789')->first();
$beneficiary = SettingBeneficiary::find(2);
DB::table('setting_active_banks')->truncate();
DB::table('setting_active_banks')->insert([
'x1_bank_id' => $bankx1->id,
'x2_bank_id' => $bankx2->id,
'beneficiary_id' => $chinabank->id
'beneficiary_id' => $beneficiary->id
]);
}
}
+1 -1
View File
@@ -23,7 +23,7 @@ class SettingBeneficiarySeeder extends Seeder
'bank_branch' => 'Putra'
]);
DB::table('setting_beneficiaries')->insert([
'company_name' => 'Bota',
'company_name' => 'CIEF1',
'bank_name' => 'CIMB',
'acc_no' => '123456789',
'bank_address' => 'Jalan cyberjaya',
+3 -3
View File
@@ -13,9 +13,9 @@ class SettingCreditSeeder extends Seeder
public function run()
{
DB::table('setting_credits')->insert([
'rmb_credit_limit' => '4000',
'usd_credit_limit' => '5000',
'time_limit' => '6000'
'rmb_credit_limit' => '100000',
'usd_credit_limit' => '100000',
'time_limit' => '60000'
]);
}
}
+1 -1
View File
@@ -12,7 +12,7 @@ class SettingTaxRateSeeder extends Seeder
public function run()
{
DB::table('setting_tax_rates')->insert([
'tax_rate' => '1.1',
'tax_rate' => '1.0',
]);
}
}
+5 -3
View File
@@ -30,10 +30,12 @@
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>
<env name="DB_CONNECTION" value="testing"/>
<!-- <env name="DB_CONNECTION" value="testing"/> -->
<env name="MAIL_DRIVER" value="array"/>
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>
<env name="DB_CONNECTION" value="mysql"/>
<env name="DB_DATABASE" value="default"/>
<!-- <env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/> -->
<ini name="display_errors" value="true"/>
</php>
</phpunit>
+7
View File
@@ -47,6 +47,13 @@ npm run hot
npm run production
```
#### Todo
- [ ] Unit test on supplier booking
- [ ] Continous delivery with npm build
- [ ] Add comments in controller functions
- [ ] Store files to AWS S3
- [ ] Real time rate update
## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
+27 -35
View File
@@ -27,9 +27,12 @@ class BookingTest extends TestCase
protected $setting_credit;
public function setUp()
{
{
parent::setUp();
\DB::statement('SET FOREIGN_KEY_CHECKS=0');
Artisan::call('db:seed');
\DB::statement('SET FOREIGN_KEY_CHECKS=1');
$this->user = factory(User::class)->create();
$this->setting_credit = factory(SettingCredit::class)->create();
@@ -39,10 +42,9 @@ class BookingTest extends TestCase
$this->userBankSlip = factory(UserBankSlip::class)->create([
'booking_id' => $this->booking->id
]);
$this->user->attachRole(Role::Where('name','member')->first());
}
public function testPost()
public function testCreate()
{
$response =
$this->actingAs($this->user)
@@ -54,23 +56,13 @@ class BookingTest extends TestCase
'company_name' => 'besaras',
'company_address' => 'californina',
'bank_address' => 'cyber',
'swift_code' => '123wert',
'cnap' => '2131rew',
'term' => 'x2_cash',
'amount' => '14000',
'amount' => '30000',
'rmb_book_amount' => '2131',
'rmb_book_pay_method' => '2131rea',
'rmb_book_account_name' => '2131rew',
'rmb_book_acc_no' => '2131',
'rmb_book_bank_branch' => '2131rew',
'usd_book_amount' => '2131',
'usd_book_pay_method' => '2131rew',
'usd_book_company_name' => '2131rew',
'usd_book_company_address' => '2131rew',
'usd_book_swift_code' => '2131rew',
'usd_book_cnap' => '2131rew',
'usd_book_bank_branch' => '2131rew',
'verification_status' => '1'
'rmb_book_bank_branch' => '2131rew'
]);
if(14000 > $this->setting_credit->rmb_credit_limit){
@@ -81,7 +73,7 @@ class BookingTest extends TestCase
}
}
public function testuploadbankslip()
public function testUploadUserSlip()
{
Storage::fake('file');
$size_in_kb = 3072; // 3072KB = 3MB
@@ -157,26 +149,26 @@ class BookingTest extends TestCase
}
// Only this is Admin permision required
public function testUploadInvoice(){
$this->user->roles()->sync([]);
$this->user->attachRole(Role::Where('name','admin')->first());
// public function testUploadInvoice(){
// $this->user->roles()->sync([]);
// $this->user->attachRole(Role::Where('name','admin')->first());
$size_in_kb = 3072;
Storage::fake('invoice_path');
$invoice_path = UploadedFile::fake()->create('document.pdf',$size_in_kb);
// $size_in_kb = 3072;
// Storage::fake('invoice_path');
// $invoice_path = UploadedFile::fake()->create('invoice.pdf',$size_in_kb);
$response =
$this->actingAs($this->user)
->json('POST', '/api/booking/' . $this->booking->id . '/upload-invoice', [
'invoice_path' => $invoice_path,
'amount' => '12345'
]);
// $response =
// $this->actingAs($this->user)
// ->json('POST', '/api/booking/' . $this->booking->id . '/upload-invoice', [
// 'invoice_path' => $invoice_path,
// 'amount' => '12345'
// ]);
if(!file_exists($invoice_path) || $size_in_kb > 3072){
$response->assertStatus(400);
}
else{
$response->assertSuccessful();
}
}
// if(!file_exists($invoice_path) || $size_in_kb > 3072){
// $response->assertStatus(400);
// }
// else{
// $response->assertSuccessful();
// }
// }
}
+33 -6
View File
@@ -8,27 +8,54 @@ use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Storage;
use Illuminate\Http\UploadedFile;
use Artisan;
use App\User;
use App\SettingCredit;
use App\Booking;
use App\UserBankSlip;
use App\Role;
class ChinaBankSlipTest extends TestCase
{
protected $user;
protected $booking;
protected $userBankSlip;
protected $setting_credit;
public function setUp()
{
parent::setUp();
\DB::statement('SET FOREIGN_KEY_CHECKS=0');
Artisan::call('db:seed');
\DB::statement('SET FOREIGN_KEY_CHECKS=1');
$this->user = factory(User::class)->create();
$this->setting_credit = factory(SettingCredit::class)->create();
$this->booking = factory(Booking::class)->create([
'user_id' => $this->user->id
]);
$this->userBankSlip = factory(UserBankSlip::class)->create([
'booking_id' => $this->booking->id
]);
}
/**
* A basic test example.
*
* @return void
*/
public function testStore(){
public function testCreate(){
$this->user->attachRole(Role::Where('name','admin')->first());
Storage::fake('file');
$size_in_kb = 3072; // 3072KB = 3MB
$china_bank_slips_path = UploadedFile::fake()->image('comp.jpg')->size($size_in_kb);
$response =
$this->postJson('api/upload-china-bankslip',[
'china_bank_slips' => $china_bank_slips_path,
$response =
$this->actingAs($this->user)->
postJson('/api/booking/'. $this->booking->id .'/upload-china-bankslip',[
'file' => $china_bank_slips_path,
'actual_transfer_amount' => '12',
'details' => "123123",
'date' => "123123"
]);
if(!file_exists($china_bank_slips_path) || $size_in_kb > 3072){
$response->assertStatus(400);
}
+24 -22
View File
@@ -4,6 +4,7 @@ namespace Tests\Feature;
use App\User;
use Tests\TestCase;
use App\Role;
class LoginTest extends TestCase
{
@@ -18,38 +19,39 @@ class LoginTest extends TestCase
}
/** @test */
public function authenticate()
{
$this->postJson('/api/login', [
'email' => $this->user->email,
'password' => 'secret',
])
->assertSuccessful()
->assertJsonStructure(['token', 'expires_in'])
->assertJson(['token_type' => 'bearer']);
}
// public function authenticate()
// {
// $this->postJson('/api/login', [
// 'email' => $this->user->email,
// 'password' => 'secret',
// ])
// ->assertSuccessful()
// ->assertJsonStructure(['token', 'expires_in'])
// ->assertJson(['token_type' => 'bearer']);
// }
/** @test */
public function fetch_the_current_user()
{
$this->actingAs($this->user)
$this->user->attachRole(Role::Where('name','member')->first());
$response = $this->actingAs($this->user)
->getJson('/api/user')
->assertSuccessful()
->assertJsonStructure(['id', 'name', 'email', 'marking']);
}
/** @test */
public function log_out()
{
$token = $this->postJson('/api/login', [
'email' => $this->user->email,
'password' => 'secret',
])->json()['token'];
// public function log_out()
// {
// $token = $this->postJson('/api/login', [
// 'email' => $this->user->email,
// 'password' => 'secret',
// ])->json()['token'];
$this->postJson("/api/logout?token=$token")
->assertSuccessful();
// $this->postJson("/api/logout?token=$token")
// ->assertSuccessful();
$this->getJson("/api/user?token=$token")
->assertStatus(401);
}
// $this->getJson("/api/user?token=$token")
// ->assertStatus(401);
// }
}
+7 -4
View File
@@ -16,19 +16,22 @@ class MarkingTest extends TestCase
public function setUp()
{
parent::setUp();
Artisan::call('db:seed');
\DB::statement('SET FOREIGN_KEY_CHECKS=0');
Artisan::call('db:seed');
\DB::statement('SET FOREIGN_KEY_CHECKS=1');
$this->user = factory(User::class)->create();
$this->user->attachRole(Role::Where('name','admin')->first());
}
public function testStore(){
public function testCreate(){
$response =
$this->actingAs($this->user)
->postJson('/api/marking/',[
->postJson('/api/setting-marking/',[
'email' => 'user@example.com',
'marking' => 'markingcode123'
])
->assertStatus(201);
->assertStatus(201);
}
}
+2 -2
View File
@@ -26,12 +26,12 @@ class SettingCreditTest extends TestCase
public function testStore(){
$this->actingAs($this->user)
->postJson('/api/setting-credit/', [
->putJson('/api/setting-credit/', [
'rmb_credit_limit' => '5000',
'usd_credit_limit' => '2000',
'time_limit' => '500'
])
->assertStatus(201);
->assertStatus(200);
}
}
+2 -1
View File
@@ -17,12 +17,13 @@ class SettingsTest extends TestCase
parent::setUp();
$this->user = factory(User::class)->create();
$this->user->attachRole(Role::Where('name','member')->first());
}
/** @test */
public function update_profile_info()
{
$this->actingAs($this->user)
$response = $this->actingAs($this->user)
->patchJson('/api/settings/profile', [
'name' => 'Test User',
'email' => 'test@test.app',
+2 -2
View File
@@ -8,6 +8,6 @@ use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
use RefreshDatabase;
use CreatesApplication;
use RefreshDatabase;
use CreatesApplication;
}