/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     // Add to customer table
     DB::table('customer')->insert([['name' => 'dasdsadasdsad', 'contactNumber' => '+639053343746', 'isSuspended' => false, 'created_at' => time(), 'updated_at' => time()], ['name' => 'asfdvds', 'contactNumber' => '+639053343746', 'isSuspended' => false, 'created_at' => time(), 'updated_at' => time()], ['name' => 'erqr', 'contactNumber' => '+639053343746', 'isSuspended' => false, 'created_at' => time(), 'updated_at' => time()], ['name' => 'xcvcxv', 'contactNumber' => '+639053343746', 'isSuspended' => false, 'created_at' => time(), 'updated_at' => time()], ['name' => 'yutu', 'contactNumber' => '+639053343746', 'isSuspended' => false, 'created_at' => time(), 'updated_at' => time()], ['name' => 'hjhgk', 'contactNumber' => '+639053343746', 'isSuspended' => false, 'created_at' => time(), 'updated_at' => time()], ['name' => 'xczcxzc', 'contactNumber' => '+639053343746', 'isSuspended' => false, 'created_at' => time(), 'updated_at' => time()], ['name' => 'wqeqweqwe', 'contactNumber' => '+639053343746', 'isSuspended' => false, 'created_at' => time(), 'updated_at' => time()], ['name' => 'adsdadadppp', 'contactNumber' => '+639053343746', 'isSuspended' => false, 'created_at' => time(), 'updated_at' => time()], ['name' => 'hgfdjfsndadsf', 'contactNumber' => '+639053343746', 'isSuspended' => false, 'created_at' => time(), 'updated_at' => time()]]);
     Model::reguard();
 }
Example #2
0
 public function testDeferredBinding()
 {
     $sessionKey = uniqid('session_key', true);
     Model::unguard();
     $author = Author::create(['name' => 'Stevie']);
     $post = Post::create(['title' => "First post", 'description' => "Yay!!"]);
     Model::reguard();
     $postId = $post->id;
     // Deferred add
     $author->posts()->add($post, $sessionKey);
     $this->assertNull($post->author_id);
     $this->assertEmpty($author->posts);
     $this->assertEquals(0, $author->posts()->count());
     $this->assertEquals(1, $author->posts()->withDeferred($sessionKey)->count());
     // Commit deferred
     $author->save(null, $sessionKey);
     $post = Post::find($postId);
     $this->assertEquals(1, $author->posts()->count());
     $this->assertEquals($author->id, $post->author_id);
     $this->assertEquals(['First post'], $author->posts->lists('title'));
     // New session
     $sessionKey = uniqid('session_key', true);
     // Deferred remove
     $author->posts()->remove($post, $sessionKey);
     $this->assertEquals(1, $author->posts()->count());
     $this->assertEquals(0, $author->posts()->withDeferred($sessionKey)->count());
     $this->assertEquals($author->id, $post->author_id);
     $this->assertEquals(['First post'], $author->posts->lists('title'));
     // Commit deferred
     $author->save(null, $sessionKey);
     $post = Post::find($postId);
     $this->assertEquals(0, $author->posts()->count());
     $this->assertNull($post->author_id);
     $this->assertEmpty($author->posts);
 }
 public function testDeferredBinding()
 {
     $sessionKey = uniqid('session_key', true);
     Model::unguard();
     $author = Author::create(['name' => 'Stevie']);
     $event = EventLog::create(['action' => "user-created"]);
     Model::reguard();
     $eventId = $event->id;
     // Deferred add
     $author->event_log()->add($event, $sessionKey);
     $this->assertNull($event->related_id);
     $this->assertEmpty($author->event_log);
     $this->assertEquals(0, $author->event_log()->count());
     $this->assertEquals(1, $author->event_log()->withDeferred($sessionKey)->count());
     // Commit deferred
     $author->save(null, $sessionKey);
     $event = EventLog::find($eventId);
     $this->assertEquals(1, $author->event_log()->count());
     $this->assertEquals($author->id, $event->related_id);
     $this->assertEquals(['user-created'], $author->event_log->lists('action'));
     // New session
     $sessionKey = uniqid('session_key', true);
     // Deferred remove
     $author->event_log()->remove($event, $sessionKey);
     $this->assertEquals(1, $author->event_log()->count());
     $this->assertEquals(0, $author->event_log()->withDeferred($sessionKey)->count());
     $this->assertEquals($author->id, $event->related_id);
     $this->assertEquals(['user-created'], $author->event_log->lists('action'));
     // Commit deferred (model is deleted as per definition)
     $author->save(null, $sessionKey);
     $event = EventLog::find($eventId);
     $this->assertEquals(0, $author->event_log()->count());
     $this->assertNull($event);
     $this->assertEmpty($author->event_log);
 }
Example #4
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     $this->call(UserTableSeeder::class);
     $this->call(IssueTableSeeder::class);
     Model::reguard();
 }
 public function testDeferredBinding()
 {
     $sessionKey = uniqid('session_key', true);
     Model::unguard();
     $author = Author::create(['name' => 'Stevie']);
     $phone = Phone::create(['number' => '0404040404']);
     Model::reguard();
     $phoneId = $phone->id;
     // Deferred add
     $author->phone()->add($phone, $sessionKey);
     $this->assertNull($phone->author_id);
     $this->assertNull($author->phone);
     $this->assertEquals(0, $author->phone()->count());
     $this->assertEquals(1, $author->phone()->withDeferred($sessionKey)->count());
     // Commit deferred
     $author->save(null, $sessionKey);
     $phone = Phone::find($phoneId);
     $this->assertEquals(1, $author->phone()->count());
     $this->assertEquals($author->id, $phone->author_id);
     $this->assertEquals('0404040404', $author->phone->number);
     // New session
     $sessionKey = uniqid('session_key', true);
     // Deferred remove
     $author->phone()->remove($phone, $sessionKey);
     $this->assertEquals(1, $author->phone()->count());
     $this->assertEquals(0, $author->phone()->withDeferred($sessionKey)->count());
     $this->assertEquals($author->id, $phone->author_id);
     $this->assertEquals('0404040404', $author->phone->number);
     // Commit deferred
     $author->save(null, $sessionKey);
     $phone = Phone::find($phoneId);
     $this->assertEquals(0, $author->phone()->count());
     $this->assertNull($phone->author_id);
     $this->assertNull($author->phone);
 }
 public function testDeferredBinding()
 {
     $sessionKey = uniqid('session_key', true);
     Model::unguard();
     $post = Post::make(['title' => "First post"]);
     $author = Author::create(['name' => 'Stevie']);
     Model::reguard();
     // Deferred add
     $post->author()->add($author, $sessionKey);
     $this->assertNull($post->author_id);
     $this->assertNull($post->author);
     $this->assertEquals(0, $post->author()->count());
     $this->assertEquals(1, $post->author()->withDeferred($sessionKey)->count());
     // Commit deferred
     $post->save(null, $sessionKey);
     $this->assertEquals(1, $post->author()->count());
     $this->assertEquals($author->id, $post->author_id);
     $this->assertEquals('Stevie', $post->author->name);
     // New session
     $sessionKey = uniqid('session_key', true);
     // Deferred remove
     $post->author()->remove($author, $sessionKey);
     $this->assertEquals(1, $post->author()->count());
     $this->assertEquals(0, $post->author()->withDeferred($sessionKey)->count());
     $this->assertEquals($author->id, $post->author_id);
     $this->assertEquals('Stevie', $post->author->name);
     // Commit deferred
     $post->save(null, $sessionKey);
     $this->assertEquals(0, $post->author()->count());
     $this->assertNull($post->author_id);
     $this->assertNull($post->author);
 }
Example #7
0
 public function testDeferredBinding()
 {
     $sessionKey = uniqid('session_key', true);
     Model::unguard();
     $author = Author::create(['name' => 'Stevie']);
     $meta = Meta::create(['meta_title' => 'Comment', 'meta_description' => 'Social', 'meta_keywords' => 'startup', 'canonical_url' => 'http://facebook.com/search/users', 'redirect_url' => 'http://facebook.com', 'robot_index' => 'index', 'robot_follow' => 'follow']);
     Model::reguard();
     $metaId = $meta->id;
     // Deferred add
     $author->meta()->add($meta, $sessionKey);
     $this->assertNull($meta->taggable_id);
     $this->assertNull($author->meta);
     $this->assertEquals(0, $author->meta()->count());
     $this->assertEquals(1, $author->meta()->withDeferred($sessionKey)->count());
     // Commit deferred
     $author->save(null, $sessionKey);
     $meta = Meta::find($metaId);
     $this->assertEquals(1, $author->meta()->count());
     $this->assertEquals($author->id, $meta->taggable_id);
     $this->assertEquals('Comment', $author->meta->meta_title);
     // New session
     $sessionKey = uniqid('session_key', true);
     // Deferred remove
     $author->meta()->remove($meta, $sessionKey);
     $this->assertEquals(1, $author->meta()->count());
     $this->assertEquals(0, $author->meta()->withDeferred($sessionKey)->count());
     $this->assertEquals($author->id, $meta->taggable_id);
     $this->assertEquals('Comment', $author->meta->meta_title);
     // Commit deferred
     $author->save(null, $sessionKey);
     $meta = Meta::find($metaId);
     $this->assertEquals(0, $author->meta()->count());
     $this->assertNull($meta->taggable_id);
     $this->assertNull($author->meta);
 }
 public function testSetRelationValueBelongsTo()
 {
     Model::unguard();
     $post = Post::create(['title' => "First post", 'description' => "Yay!!"]);
     $author1 = Author::create(['name' => 'Stevie', 'email' => '*****@*****.**']);
     $author2 = Author::create(['name' => 'Louie', 'email' => '*****@*****.**']);
     $author3 = Author::make(['name' => 'Charlie', 'email' => '*****@*****.**']);
     Model::reguard();
     // Set by Model object
     $post->author = $author1;
     $this->assertEquals($author1->id, $post->author_id);
     $this->assertEquals('Stevie', $post->author->name);
     // Set by primary key
     $post->author = $author2->id;
     $this->assertEquals($author2->id, $post->author_id);
     $this->assertEquals('Louie', $post->author->name);
     // Nullify
     $post->author = null;
     $this->assertNull($post->author_id);
     $this->assertNull($post->author);
     // Deferred
     $post->author = $author3;
     $this->assertEquals('Charlie', $post->author->name);
     $this->assertNull($post->author_id);
     $author3->save();
     $this->assertEquals($author3->id, $post->author_id);
 }
Example #9
0
 public function testGetRelationValue()
 {
     Model::unguard();
     $author = Author::create(['name' => 'Stevie']);
     $event = EventLog::make(['action' => "user-created", 'related_id' => $author->id, 'related_type' => get_class($author)]);
     Model::reguard();
     $this->assertEquals([$author->id, get_class($author)], $event->getRelationValue('related'));
 }
Example #10
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     DB::table('users')->delete();
     $users = array(['name' => 'Yuvraj Singh', 'email' => '*****@*****.**', 'password' => Hash::make('secret')], ['name' => 'Subhankar Pramanik', 'email' => '*****@*****.**', 'password' => Hash::make('secret')], ['name' => 'Soham Banik', 'email' => '*****@*****.**', 'password' => Hash::make('secret')], ['name' => 'Prasenjit Ghosh', 'email' => '*****@*****.**', 'password' => Hash::make('secret')]);
     // Loop through each user above and create the record for them in the database
     foreach ($users as $user) {
         User::create($user);
     }
     Model::reguard();
 }
Example #11
0
 public function testDeleteFlagSoftDeleteModel()
 {
     Model::unguard();
     $user = SoftDeleteUser::create(['name' => 'Stevie', 'email' => '*****@*****.**']);
     Model::reguard();
     $user->avatar()->create(['data' => base_path() . '/tests/fixtures/plugins/database/tester/assets/images/avatar.png']);
     $this->assertNotNull($user->avatar);
     $avatarId = $user->avatar->id;
     $user->delete();
     $this->assertNotNull(FileModel::find($avatarId));
 }
Example #12
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     // $this->call(UserTableSeeder::class);
     DB::table('users')->insert(['first_name' => 'Администратор', 'email' => '*****@*****.**', 'password' => bcrypt('adminadmin')]);
     DB::table('post_statuses')->insert([['name' => 'Неопубликован'], ['name' => 'На модерации'], ['name' => 'Опубликован']]);
     DB::table('menuitem_types')->insert([['name' => 'Внутренняя ссылка'], ['name' => 'Внешняя ссылка'], ['name' => 'Маркер'], ['name' => 'Группа маркеров']]);
     DB::table('administrators')->insert(['username' => 'admin', 'password' => bcrypt('adminadmin'), 'name' => 'Администратор']);
     DB::table('marker_groups')->insert([['name' => 'Кухня'], ['name' => 'Блюдо'], ['name' => 'Дневной рацион']]);
     Model::reguard();
 }
 public function testCommitBinding()
 {
     $sessionKey = uniqid('session_key', true);
     DeferredBinding::truncate();
     Model::unguard();
     $author = Author::make(['name' => 'Stevie']);
     $post = Post::create(['title' => "First post"]);
     Model::reguard();
     $author->posts()->add($post, $sessionKey);
     $this->assertEquals(1, DeferredBinding::count());
     $author->commitDeferred($sessionKey);
     $this->assertEquals(0, DeferredBinding::count());
 }
 public function seedSampleTree()
 {
     Model::unguard();
     $orange = CategoryNested::create(['name' => 'Category Orange', 'description' => 'A root level test category']);
     $autumn = $orange->children()->create(['name' => 'Autumn Leaves', 'description' => 'Disccusion about the season of falling leaves.']);
     $autumn->children()->create(['name' => 'September', 'description' => 'The start of the fall season.']);
     $october = $autumn->children()->create(['name' => 'October', 'description' => 'The middle of the fall season.']);
     $autumn->children()->create(['name' => 'November', 'description' => 'The end of the fall season.']);
     $orange->children()->create(['name' => 'Summer Breeze', 'description' => 'Disccusion about the wind at the ocean.']);
     $green = CategoryNested::create(['name' => 'Category Green', 'description' => 'A root level test category']);
     $green->children()->create(['name' => 'Winter Snow', 'description' => 'Disccusion about the frosty snow flakes.']);
     $green->children()->create(['name' => 'Spring Trees', 'description' => 'Disccusion about the blooming gardens.']);
     Model::reguard();
 }
 public function testDeleteFlagDeleteModel()
 {
     Model::unguard();
     $user = User::create(['name' => 'Stevie', 'email' => '*****@*****.**']);
     Model::reguard();
     $this->assertEmpty($user->photos);
     $user->photos()->create(['data' => base_path() . '/tests/fixtures/plugins/database/tester/assets/images/avatar.png']);
     $user->reloadRelations();
     $this->assertNotEmpty($user->photos);
     $photo = $user->photos->first();
     $this->assertNotNull($photo);
     $photoId = $photo->id;
     $user->delete();
     $this->assertNull(FileModel::find($photoId));
 }
 public function testRestoreSoftDeleteRelation()
 {
     Model::unguard();
     $user = UserWithSoftAuthorAndSoftDelete::create(['name' => 'Stevie', 'email' => '*****@*****.**']);
     $author = SoftDeleteAuthor::create(['name' => 'Louie', 'email' => '*****@*****.**', 'user_id' => $user->id]);
     Model::reguard();
     $authorId = $author->id;
     $user->delete();
     // Soft
     $this->assertNull(SoftDeleteAuthor::find($authorId));
     $this->assertNotNull(SoftDeleteAuthor::withTrashed()->find($authorId));
     $userId = $user->id;
     $user = UserWithSoftAuthorAndSoftDelete::withTrashed()->find($userId);
     $user->restore();
     $this->assertNotNull(SoftDeleteAuthor::find($authorId));
 }
 public function seedSampleTree()
 {
     Model::unguard();
     $webdev = CategorySimple::create(['name' => 'Web development']);
     $webdev->children()->create(['name' => 'HTML5']);
     $webdev->children()->create(['name' => 'CSS3']);
     $webdev->children()->create(['name' => 'jQuery']);
     $webdev->children()->create(['name' => 'Bootstrap']);
     $webdev->children()->create(['name' => 'Laravel']);
     $october = $webdev->children()->create(['name' => 'OctoberCMS']);
     $october->children()->create(['name' => 'September']);
     $october->children()->create(['name' => 'October']);
     $october->children()->create(['name' => 'November']);
     $mobdev = CategorySimple::create(['name' => 'Mobile development']);
     $mobdev->children()->create(['name' => 'iOS']);
     $mobdev->children()->create(['name' => 'iPhone']);
     $mobdev->children()->create(['name' => 'iPad']);
     $mobdev->children()->create(['name' => 'Android']);
     $design = CategorySimple::create(['name' => 'Graphic design']);
     $design->children()->create(['name' => 'Photoshop']);
     $design->children()->create(['name' => 'Illustrator']);
     $design->children()->create(['name' => 'Fireworks']);
     Model::reguard();
 }
 public function testConditionsWithPivotAttributes()
 {
     Model::unguard();
     $author = Author::create(['name' => 'Stevie', 'email' => '*****@*****.**']);
     $role1 = Role::create(['name' => "Designer", 'description' => "Quality"]);
     $role2 = Role::create(['name' => "Programmer", 'description' => "Speed"]);
     $role3 = Role::create(['name' => "Manager", 'description' => "Budget"]);
     Model::reguard();
     $author->roles()->add($role1, null, ['is_executive' => 1]);
     $author->roles()->add($role2, null, ['is_executive' => 1]);
     $author->roles()->add($role3, null, ['is_executive' => 0]);
     $this->assertEquals([1, 2], $author->executive_authors->lists('id'));
 }
 public function testDetachAfterDelete()
 {
     // Needed for other "delete" events
     include_once base_path() . '/tests/fixtures/plugins/database/tester/models/User.php';
     include_once base_path() . '/tests/fixtures/plugins/database/tester/models/EventLog.php';
     Model::unguard();
     $author = Author::create(['name' => 'Stevie', 'email' => '*****@*****.**']);
     $role1 = Role::create(['name' => "Designer", 'description' => "Quality"]);
     $role2 = Role::create(['name' => "Programmer", 'description' => "Speed"]);
     $role3 = Role::create(['name' => "Manager", 'description' => "Budget"]);
     Model::reguard();
     $author->roles()->add($role1);
     $author->roles()->add($role2);
     $author->roles()->add($role3);
     $this->assertEquals(3, Db::table('database_tester_authors_roles')->where('author_id', $author->id)->count());
     $author->delete();
     $this->assertEquals(0, Db::table('database_tester_authors_roles')->where('author_id', $author->id)->count());
 }