Skip to content

Commit

Permalink
feat(line): add line account eloquent
Browse files Browse the repository at this point in the history
  • Loading branch information
GimmyHchs committed Jun 19, 2018
1 parent 2ea7752 commit e14ebc9
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 2 deletions.
15 changes: 15 additions & 0 deletions app/Eloquents/Line/LineAccount.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace App\Eloquents\Line;

use App\Eloquents\Eloquent;

class LineAccount extends Eloquent
{
protected $table = 'line_accounts';

protected $fillable = [
'type',
'line_id',
];
}
8 changes: 8 additions & 0 deletions database/factories/LineFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use App\Eloquents\Line\FollowEvent;
use App\Eloquents\Line\JoinEvent;
use App\Eloquents\Line\LeaveEvent;
use App\Eloquents\Line\LineAccount;
use App\Eloquents\Line\MessageEvent;
use App\Eloquents\Line\Messages\LineSticker;
use App\Eloquents\Line\Messages\LineText;
Expand Down Expand Up @@ -106,3 +107,10 @@
'event_id' => $event->id,
];
});

$factory->define(LineAccount::class, function (Faker $faker) {
return [
'type' => 'group',
'line_id' => (string)$faker->numberBetween(100000, 999999),
];
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateLineAccountsTable extends Migration
{
/**
* Run the migrations.
*/
public function up()
{
Schema::create('line_accounts', function (Blueprint $table) {
$table->increments('id');
$table->string('type', 15);
$table->string('line_id', 50)->index('line_accounts_line_id');
$table->timestamps();
});
}

/**
* Reverse the migrations.
*/
public function down()
{
Schema::dropIfExists('line_accounts');
}
}
3 changes: 1 addition & 2 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use Mockery;
use Mockery\MockInterface;
use Tests\Traits\MessagePrintable;

abstract class TestCase extends BaseTestCase
{
use CreatesApplication, MessagePrintable;
use CreatesApplication;

/**
* @param string $class
Expand Down
19 changes: 19 additions & 0 deletions tests/Unit/Eloquents/Line/LineAccountTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Tests\Unit\Eloquents\Line;

use App\Eloquents\Line\LineAccount;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

class LineAccountTest extends TestCase
{
use RefreshDatabase;

public function testFactory()
{
$events = factory(LineAccount::class, 5)->create();

$this->assertEquals($events->count(), 5);
}
}

0 comments on commit e14ebc9

Please sign in to comment.