Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ajout de test unitaire #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
19 changes: 0 additions & 19 deletions .env.example

This file was deleted.

Empty file modified app/Http/Controllers/PagesController.php
100644 → 100755
Empty file.
34 changes: 18 additions & 16 deletions app/Http/Controllers/TasksController.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@

class TasksController extends Controller
{

/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$tasks = Task::latest('updated_at')->get();
$data['tasks'] = Task::latest('updated_at')->get();

return view('tasks.index', compact('tasks'));
return view('tasks.index', $data);
}

/**
Expand Down Expand Up @@ -55,7 +56,7 @@ public function store(Request $request)

return redirect()->route('tasks.index');
}

/**
* Display the specified resource.
*
Expand All @@ -64,34 +65,34 @@ public function store(Request $request)
*/
public function show($id)
{
$task = Task::findOrFail($id);
$data['tasks'] = Task::findOrFail($id);

return view('tasks.show', compact('task'));
return view('tasks.show', $data);
}

/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
*/
public function edit($id)
{
$task = Task::findOrFail($id);
$data['tasks'] = Task::findOrFail($id);

return view('tasks.edit', compact('task'));
return view('tasks.edit', $data);
}

/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
*/
public function update(Request $request, $id)
{
$task = Task::findOrFail($id);
$data['tasks'] = Task::findOrFail($id);

$this->validate($request, [
'title' => 'required',
Expand All @@ -100,27 +101,28 @@ public function update(Request $request, $id)

$input = $request->all();

$task->fill($input)->save();
$data['tasks']->fill($input)->save();

Session::flash('flash_message', 'Task successfully modified!');

return redirect()->route('tasks.index');
}

/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
*/
public function destroy($id)
{
$task = Task::findOrFail($id);
$data['tasks'] = Task::findOrFail($id);

$task->delete();
$data['tasks']->delete();

Session::flash('flash_message', 'Task successfully deleted!');

return redirect()->route('tasks.index');
}

}
Empty file modified app/Task.php
100644 → 100755
Empty file.
Empty file modified build.xml
100644 → 100755
Empty file.
Empty file modified cache.properties
100644 → 100755
Empty file.
Empty file modified composer.lock
100644 → 100755
Empty file.
Empty file modified database/migrations/2015_10_09_143137_create_tasks_table.php
100644 → 100755
Empty file.
Empty file modified database/seeds/TaskTableSeeder.php
100644 → 100755
Empty file.
Empty file modified resources/views/layouts/master.blade.php
100644 → 100755
Empty file.
Empty file modified resources/views/pages/home.blade.php
100644 → 100755
Empty file.
Empty file modified resources/views/tasks/create.blade.php
100644 → 100755
Empty file.
Empty file modified resources/views/tasks/edit.blade.php
100644 → 100755
Empty file.
Empty file modified resources/views/tasks/index.blade.php
100644 → 100755
Empty file.
Empty file modified resources/views/tasks/show.blade.php
100644 → 100755
Empty file.
Empty file modified sonar-project.properties
100644 → 100755
Empty file.
Empty file modified storage/debugbar/.gitignore
100644 → 100755
Empty file.
39 changes: 38 additions & 1 deletion tests/Http/Controllers/TasksControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,41 @@ public function testIndex()
$response = $this->action('GET', 'TasksController@index');
$this->assertResponseOk();
}
}
public function testStore()
{
$this->visit('tasks/create')
->type('newTitle', 'title')
->type('newDescription', 'description')
->press('Create New Task')
->seePageIs('/tasks');
$this->assertRedirectedToRoute('tasks.index');

}
public function testShow()
{
$response = $this->action('GET', 'TasksController@show', ['tasks' => 1]);
$this->assertResponseOk();
}
public function testEdit()
{
$response = $this->action('GET', 'TasksController@edit', ['tasks' => 1]);
$this->assertResponseOk();
}
public function testUpdate()
{
$this->visit('tasks/1/edit')
->type('newTitle', 'title')
->type('newDescription', 'description')
->press('Update Task')
->seePageIs('/tasks');
$this->assertRedirectedToRoute('tasks.index');
}
public function testDestroy()
{
$this->visit('tasks')
->press('Delete this task?')
->seePageIs('/tasks');
$this->assertRedirectedToRoute('tasks.index');
}

}
19 changes: 19 additions & 0 deletions tests/Http/Controllers/TasksControllerTest.php~
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;

class TasksControllerTest extends TestCase
{
/**
* Display a listing of the resource.
*
* @return void
*/
public function testIndex()
{
$response = $this->action('GET', 'TasksController@index');
$this->assertResponseOk();
}
}
Empty file modified tests/Selenium/HomeTest.html
100644 → 100755
Empty file.
Empty file modified tests/Selenium/TasksListTest.html
100644 → 100755
Empty file.
Empty file modified tests/Selenium/TasksTestSuite.html
100644 → 100755
Empty file.