public function test_non_admin_cannot_remove_comment() { \Auth::shouldReceive('user')->once()->andReturn(DummyUser::where(['is_admin' => 0])->first()); $comment = Comment::where(['body' => 'My Comment 1'])->first(); $this->assertEquals($comment->body, 'My Comment 1'); $result = \Mural::remove($comment->id); $comment = Comment::where(['body' => 'My Comment 1'])->first(); $this->assertEquals($comment->body, 'My Comment 1'); $this->assertEquals($result, false); }
public function test_render_if_showing() { $post = DummyPost::find(1); $html = \Mural::render($post, 'test-room'); $crawler = new Crawler($html); $this->assertEquals($crawler->filter('div[data-type = "Laravolt\\Mural\\Test\\DummyPost"]')->count(), 1); $this->assertEquals($crawler->filter('div[data-room = "test-room"]')->count(), 1); $this->assertContains($crawler->filter('.author')->text(), 'Heru'); $this->assertContains('ago', $crawler->filter('.date')->text()); $this->assertContains('My Comment 2', $crawler->filter('.media-body p')->eq(0)->text()); $this->assertContains('My Comment 1', $crawler->filter('.media-body p')->eq(1)->text()); }
/** * Run the database seeds. * * @return void */ public function run() { Model::unguard(); // root role $root = \Laravolt\Acl\Models\Role::create(['name' => 'root']); $admin = \Laravolt\Acl\Models\Role::create(['name' => 'admin']); $adminUjiPublik = \Laravolt\Acl\Models\Role::create(['name' => 'admin-uji-publik']); // root user $user = factory(\App\Entities\User::class)->create(['email' => '*****@*****.**', 'status' => \App\Enum\UserStatus::ACTIVE()]); $user->assignRole($root); auth()->login($user); factory(\App\Entities\User::class, 50)->create(); $this->command->info('Start Seed Satker, ProgramKerja, and Fase'); factory(\App\Entities\Satker::class, 10)->create()->each(function ($satker) { $proker = factory(\App\Entities\ProgramKerja::class, 10)->create(['satker_id' => $satker->id]); $proker->each(function ($proker) { $fase = factory(\App\Entities\Fase::class)->create(['type' => \App\Enum\FaseType::PERENCANAAN, 'proker_id' => $proker->id, 'satker_id' => $proker->satker_id]); $fase->addDocument(base_path('resources/assets/files/sample.doc')); $fase->addDocument(base_path('resources/assets/files/sample.pdf')); foreach (range(1, rand(1, 10)) as $id) { Mural::addComment($fase, Faker\Factory::create()->paragraph, 'default'); Votee::voteUp($fase, \App\Entities\User::find($id)); Votee::voteDown($fase, \App\Entities\User::find($id + 10)); } $fase = factory(\App\Entities\Fase::class, 'berjalan')->create(['type' => \App\Enum\FaseType::PELAKSANAAN, 'proker_id' => $proker->id, 'satker_id' => $proker->satker_id]); $fase->addDocument(base_path('resources/assets/files/sample.doc')); $fase->addDocument(base_path('resources/assets/files/sample.pdf')); foreach (range(1, rand(1, 10)) as $id) { Mural::addComment($fase, Faker\Factory::create()->paragraph, 'default'); Votee::voteUp($fase, \App\Entities\User::find($id)); Votee::voteDown($fase, \App\Entities\User::find($id + 10)); } $fase = factory(\App\Entities\Fase::class)->create(['type' => \App\Enum\FaseType::PENGAWASAN, 'proker_id' => $proker->id, 'satker_id' => $proker->satker_id]); $fase->addDocument(base_path('resources/assets/files/sample.doc')); $fase->addDocument(base_path('resources/assets/files/sample.pdf')); foreach (range(1, rand(1, 10)) as $id) { Mural::addComment($fase, Faker\Factory::create()->paragraph, 'default'); Votee::voteUp($fase, \App\Entities\User::find($id)); Votee::voteDown($fase, \App\Entities\User::find($id + 10)); } $proker->current_fase_id = $fase->id; $proker->save(); }); }); $this->command->info('Finish Seed Satker, ProgramKerja, and Fase'); $this->command->info('Start Seed ProgramKerjaUsulan'); factory(\App\Entities\ProgramKerjaUsulan::class, 50)->create()->each(function ($model) { $model->addDocument(base_path('resources/assets/files/sample.doc')); $model->addDocument(base_path('resources/assets/files/sample.pdf')); foreach (range(1, rand(1, 10)) as $id) { Mural::addComment($model, Faker\Factory::create()->paragraph, 'default'); Votee::voteUp($model, \App\Entities\User::find($id)); Votee::voteDown($model, \App\Entities\User::find($id + 10)); } }); $this->command->info('Finish Seed ProgramKerjaUsulan'); $this->command->info('Start Seed UjiPublik'); factory(\App\Entities\UjiPublik::class, 50)->create()->each(function ($model) { $model->addDocument(base_path('resources/assets/files/sample.doc')); $model->addDocument(base_path('resources/assets/files/sample.pdf')); foreach (range(1, rand(1, 10)) as $id) { Mural::addComment($model, Faker\Factory::create()->paragraph, 'default'); Votee::voteUp($model, \App\Entities\User::find($id)); Votee::voteDown($model, \App\Entities\User::find($id + 10)); } }); $this->command->info('Finish Seed UjiPublik'); auth()->logout(); Model::reguard(); }
<?php require_once '../configs/sm.php'; include_once '../model/Mural.php'; include_once '../model/Usuario.php'; session_start(); if ($_SESSION['login'] == "true") { $usuario = Usuario::listaUsuario($_SESSION['usuario']); $mural = Mural::listaMural(1); $sm->assign("usuario", $usuario); $sm->assign("mural", $mural); $sm->display('../view/home.html'); } else { header("location:../index.php?&erro=\"Login\""); }
public function delete($id) { return \Mural::remove($id); }
<?php /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ include_once '../model/Mural.php'; session_start(); if ($_SESSION['login'] == "true") { $mural = addslashes(trim($_POST['mural'])); $muralNovo = new Mural(1, $mural); $muralAntigo = Mural::listaMural(1); Mural::deletaMural(1); Mural::insereMural($muralNovo); header("location:../controller/controllerHome.php"); } else { header("location:../index.php?&erro=\"Login\""); }