Created regular tests
This commit is contained in:
parent
2871865e82
commit
70fe3a814c
28
app/Http/Controllers/HomeController.php
Normal file
28
app/Http/Controllers/HomeController.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application dashboard.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('home');
|
||||
}
|
||||
}
|
12
codeception.yml
Normal file
12
codeception.yml
Normal file
@ -0,0 +1,12 @@
|
||||
paths:
|
||||
tests: tests
|
||||
output: tests/_output
|
||||
data: tests/_data
|
||||
support: tests/_support
|
||||
envs: tests/_envs
|
||||
actor_suffix: Tester
|
||||
extensions:
|
||||
enabled:
|
||||
- Codeception\Extension\RunFailed
|
||||
settings:
|
||||
bootstrap: _bootstrap.php
|
@ -20,6 +20,7 @@
|
||||
"codeception/codeception": "^2.4",
|
||||
"filp/whoops": "~2.0",
|
||||
"fzaninotto/faker": "~1.4",
|
||||
"guzzlehttp/guzzle": "^6.3",
|
||||
"mockery/mockery": "~1.0",
|
||||
"phpunit/phpunit": "~6.0",
|
||||
"symfony/thanks": "^1.0"
|
||||
|
2
composer.lock
generated
2
composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "0cbfd32cc57280040ed24ff2f9add7a6",
|
||||
"content-hash": "cddd88b2bc6fcfeb60c6125a7227f26e",
|
||||
"packages": [
|
||||
{
|
||||
"name": "barryvdh/laravel-snappy",
|
||||
|
@ -11,6 +11,6 @@ class DatabaseSeeder extends Seeder
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// $this->call(UsersTableSeeder::class);
|
||||
$this->call(UsersTableSeeder::class);
|
||||
}
|
||||
}
|
||||
|
18
database/seeds/UsersTableSeeder.php
Normal file
18
database/seeds/UsersTableSeeder.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class UsersTableSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
factory(App\User::class)->create([
|
||||
'email' => 'admin@laraland.test'
|
||||
]);
|
||||
}
|
||||
}
|
69
resources/views/auth/login.blade.php
Normal file
69
resources/views/auth/login.blade.php
Normal file
@ -0,0 +1,69 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-8 col-md-offset-2">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Login</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<form class="form-horizontal" method="POST" action="{{ route('login') }}">
|
||||
{{ csrf_field() }}
|
||||
|
||||
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
|
||||
<label for="email" class="col-md-4 control-label">E-Mail Address</label>
|
||||
|
||||
<div class="col-md-6">
|
||||
<input id="email" type="email" class="form-control" name="email" value="{{ old('email') }}" required autofocus>
|
||||
|
||||
@if ($errors->has('email'))
|
||||
<span class="help-block">
|
||||
<strong>{{ $errors->first('email') }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
|
||||
<label for="password" class="col-md-4 control-label">Password</label>
|
||||
|
||||
<div class="col-md-6">
|
||||
<input id="password" type="password" class="form-control" name="password" required>
|
||||
|
||||
@if ($errors->has('password'))
|
||||
<span class="help-block">
|
||||
<strong>{{ $errors->first('password') }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-md-6 col-md-offset-4">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" name="remember" {{ old('remember') ? 'checked' : '' }}> Remember Me
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-md-8 col-md-offset-4">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
Login
|
||||
</button>
|
||||
|
||||
<a class="btn btn-link" href="{{ route('password.request') }}">
|
||||
Forgot Your Password?
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
47
resources/views/auth/passwords/email.blade.php
Normal file
47
resources/views/auth/passwords/email.blade.php
Normal file
@ -0,0 +1,47 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-8 col-md-offset-2">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Reset Password</div>
|
||||
|
||||
<div class="panel-body">
|
||||
@if (session('status'))
|
||||
<div class="alert alert-success">
|
||||
{{ session('status') }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<form class="form-horizontal" method="POST" action="{{ route('password.email') }}">
|
||||
{{ csrf_field() }}
|
||||
|
||||
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
|
||||
<label for="email" class="col-md-4 control-label">E-Mail Address</label>
|
||||
|
||||
<div class="col-md-6">
|
||||
<input id="email" type="email" class="form-control" name="email" value="{{ old('email') }}" required>
|
||||
|
||||
@if ($errors->has('email'))
|
||||
<span class="help-block">
|
||||
<strong>{{ $errors->first('email') }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-md-6 col-md-offset-4">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
Send Password Reset Link
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
70
resources/views/auth/passwords/reset.blade.php
Normal file
70
resources/views/auth/passwords/reset.blade.php
Normal file
@ -0,0 +1,70 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-8 col-md-offset-2">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Reset Password</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<form class="form-horizontal" method="POST" action="{{ route('password.request') }}">
|
||||
{{ csrf_field() }}
|
||||
|
||||
<input type="hidden" name="token" value="{{ $token }}">
|
||||
|
||||
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
|
||||
<label for="email" class="col-md-4 control-label">E-Mail Address</label>
|
||||
|
||||
<div class="col-md-6">
|
||||
<input id="email" type="email" class="form-control" name="email" value="{{ $email or old('email') }}" required autofocus>
|
||||
|
||||
@if ($errors->has('email'))
|
||||
<span class="help-block">
|
||||
<strong>{{ $errors->first('email') }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
|
||||
<label for="password" class="col-md-4 control-label">Password</label>
|
||||
|
||||
<div class="col-md-6">
|
||||
<input id="password" type="password" class="form-control" name="password" required>
|
||||
|
||||
@if ($errors->has('password'))
|
||||
<span class="help-block">
|
||||
<strong>{{ $errors->first('password') }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group{{ $errors->has('password_confirmation') ? ' has-error' : '' }}">
|
||||
<label for="password-confirm" class="col-md-4 control-label">Confirm Password</label>
|
||||
<div class="col-md-6">
|
||||
<input id="password-confirm" type="password" class="form-control" name="password_confirmation" required>
|
||||
|
||||
@if ($errors->has('password_confirmation'))
|
||||
<span class="help-block">
|
||||
<strong>{{ $errors->first('password_confirmation') }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-md-6 col-md-offset-4">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
Reset Password
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
77
resources/views/auth/register.blade.php
Normal file
77
resources/views/auth/register.blade.php
Normal file
@ -0,0 +1,77 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-8 col-md-offset-2">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Register</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<form class="form-horizontal" method="POST" action="{{ route('register') }}">
|
||||
{{ csrf_field() }}
|
||||
|
||||
<div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
|
||||
<label for="name" class="col-md-4 control-label">Name</label>
|
||||
|
||||
<div class="col-md-6">
|
||||
<input id="name" type="text" class="form-control" name="name" value="{{ old('name') }}" required autofocus>
|
||||
|
||||
@if ($errors->has('name'))
|
||||
<span class="help-block">
|
||||
<strong>{{ $errors->first('name') }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
|
||||
<label for="email" class="col-md-4 control-label">E-Mail Address</label>
|
||||
|
||||
<div class="col-md-6">
|
||||
<input id="email" type="email" class="form-control" name="email" value="{{ old('email') }}" required>
|
||||
|
||||
@if ($errors->has('email'))
|
||||
<span class="help-block">
|
||||
<strong>{{ $errors->first('email') }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
|
||||
<label for="password" class="col-md-4 control-label">Password</label>
|
||||
|
||||
<div class="col-md-6">
|
||||
<input id="password" type="password" class="form-control" name="password" required>
|
||||
|
||||
@if ($errors->has('password'))
|
||||
<span class="help-block">
|
||||
<strong>{{ $errors->first('password') }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="password-confirm" class="col-md-4 control-label">Confirm Password</label>
|
||||
|
||||
<div class="col-md-6">
|
||||
<input id="password-confirm" type="password" class="form-control" name="password_confirmation" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-md-6 col-md-offset-4">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
Register
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
23
resources/views/home.blade.php
Normal file
23
resources/views/home.blade.php
Normal file
@ -0,0 +1,23 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-8 col-md-offset-2">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Dashboard</div>
|
||||
|
||||
<div class="panel-body">
|
||||
@if (session('status'))
|
||||
<div class="alert alert-success">
|
||||
{{ session('status') }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
You are logged in!
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
80
resources/views/layouts/app.blade.php
Normal file
80
resources/views/layouts/app.blade.php
Normal file
@ -0,0 +1,80 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="{{ app()->getLocale() }}">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<!-- CSRF Token -->
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
|
||||
<title>{{ config('app.name', 'Laravel') }}</title>
|
||||
|
||||
<!-- Styles -->
|
||||
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">
|
||||
<nav class="navbar navbar-default navbar-static-top">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
|
||||
<!-- Collapsed Hamburger -->
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#app-navbar-collapse" aria-expanded="false">
|
||||
<span class="sr-only">Toggle Navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
|
||||
<!-- Branding Image -->
|
||||
<a class="navbar-brand" href="{{ url('/') }}">
|
||||
{{ config('app.name', 'Laravel') }}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="collapse navbar-collapse" id="app-navbar-collapse">
|
||||
<!-- Left Side Of Navbar -->
|
||||
<ul class="nav navbar-nav">
|
||||
|
||||
</ul>
|
||||
|
||||
<!-- Right Side Of Navbar -->
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<!-- Authentication Links -->
|
||||
@guest
|
||||
<li><a href="{{ route('login') }}">Login</a></li>
|
||||
<li><a href="{{ route('register') }}">Register</a></li>
|
||||
@else
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false" aria-haspopup="true" v-pre>
|
||||
{{ Auth::user()->name }} <span class="caret"></span>
|
||||
</a>
|
||||
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a href="{{ route('logout') }}"
|
||||
onclick="event.preventDefault();
|
||||
document.getElementById('logout-form').submit();">
|
||||
Logout
|
||||
</a>
|
||||
|
||||
<form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
|
||||
{{ csrf_field() }}
|
||||
</form>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
@endguest
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
@yield('content')
|
||||
</div>
|
||||
|
||||
<!-- Scripts -->
|
||||
<script src="{{ asset('js/app.js') }}"></script>
|
||||
</body>
|
||||
</html>
|
@ -5,7 +5,7 @@
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<title>Laravel</title>
|
||||
<title>{{config('app.name', 'Laravel')}}</title>
|
||||
|
||||
<!-- Fonts -->
|
||||
<link href="https://fonts.googleapis.com/css?family=Raleway:100,600" rel="stylesheet" type="text/css">
|
||||
@ -79,7 +79,7 @@
|
||||
|
||||
<div class="content">
|
||||
<div class="title m-b-md">
|
||||
Laravel
|
||||
{{config('app.name', 'Laravel')}}
|
||||
</div>
|
||||
|
||||
<div class="links">
|
||||
|
@ -14,3 +14,7 @@
|
||||
Route::get('/', function () {
|
||||
return view('welcome');
|
||||
});
|
||||
|
||||
Auth::routes();
|
||||
|
||||
Route::get('/home', 'HomeController@index')->name('home');
|
||||
|
0
tests/_data/.gitkeep
Normal file
0
tests/_data/.gitkeep
Normal file
47
tests/_data/db_laraland.sql
Normal file
47
tests/_data/db_laraland.sql
Normal file
@ -0,0 +1,47 @@
|
||||
-- Adminer 4.3.0 MySQL dump
|
||||
|
||||
SET NAMES utf8;
|
||||
SET time_zone = '+00:00';
|
||||
SET foreign_key_checks = 0;
|
||||
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
DROP TABLE IF EXISTS `migrations`;
|
||||
CREATE TABLE `migrations` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`migration` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`batch` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES
|
||||
(59, '2014_10_12_000000_create_users_table', 1),
|
||||
(60, '2014_10_12_100000_create_password_resets_table', 1);
|
||||
|
||||
DROP TABLE IF EXISTS `password_resets`;
|
||||
CREATE TABLE `password_resets` (
|
||||
`email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`token` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
KEY `password_resets_email_index` (`email`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `users`;
|
||||
CREATE TABLE `users` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`password` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`remember_token` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `users_email_unique` (`email`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
INSERT INTO `users` (`id`, `name`, `email`, `password`, `remember_token`, `created_at`, `updated_at`) VALUES
|
||||
(1, 'Dr. Ena Steuber III', 'admin@laraland.test', '$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm', 'x4Jo6Fc40Y', '2018-07-19 05:02:22', '2018-07-19 05:02:22');
|
||||
|
||||
-- 2018-07-19 05:02:32
|
2
tests/_output/.gitignore
vendored
Normal file
2
tests/_output/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
151
tests/_support/AcceptanceTester.php
Normal file
151
tests/_support/AcceptanceTester.php
Normal file
@ -0,0 +1,151 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* Inherited Methods
|
||||
* @method void wantToTest($text)
|
||||
* @method void wantTo($text)
|
||||
* @method void execute($callable)
|
||||
* @method void expectTo($prediction)
|
||||
* @method void expect($prediction)
|
||||
* @method void amGoingTo($argumentation)
|
||||
* @method void am($role)
|
||||
* @method void lookForwardTo($achieveValue)
|
||||
* @method void comment($description)
|
||||
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
|
||||
*
|
||||
* @SuppressWarnings(PHPMD)
|
||||
*/
|
||||
class AcceptanceTester extends \Codeception\Actor
|
||||
{
|
||||
use _generated\AcceptanceTesterActions;
|
||||
|
||||
private $mailcathcher,
|
||||
$mail;
|
||||
|
||||
/**
|
||||
* @Given Saya mempunyai hak akses di database
|
||||
*/
|
||||
public function sayaMempunyaiHakAksesDiDatabase()
|
||||
{
|
||||
$I = $this;
|
||||
|
||||
$I->seeInDatabase('users', ['email' => 'admin@laraland.test']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When Saya mengirim form berisi email saya
|
||||
*/
|
||||
public function sayaMengirimFormBerisiEmailSaya()
|
||||
{
|
||||
$I = $this;
|
||||
|
||||
$I->amOnPage('/password/reset');
|
||||
$I->fillField('email', 'admin@laraland.test');
|
||||
$I->click('button[type=submit]');
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then Saya melihat bahwa sebuah email telah dikirim dari sistem
|
||||
*/
|
||||
public function sayaMelihatBahwaSebuahEmailTelahDikirimDariSistem()
|
||||
{
|
||||
$I = $this;
|
||||
|
||||
$I->see('We have e-mailed your password reset link!');
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given Saya membuka link pada email dari sistem
|
||||
*/
|
||||
public function sayaMembukaLinkPadaEmailDariSistem()
|
||||
{
|
||||
$I = $this;
|
||||
|
||||
$I->requestEmailResetPasswordLink($I);
|
||||
|
||||
$this->mailcatcher = new GuzzleHttp\Client([
|
||||
'base_uri' => 'http://localhost:8025/api/v1/'
|
||||
]);
|
||||
|
||||
$this->mail = $this->getLastMessage($this->mailcatcher);
|
||||
|
||||
$pattern = '/\/password\/reset\/[\w=\s]+[^\W]+/';
|
||||
|
||||
foreach($this->mail as $key => $val) {
|
||||
if ($key == 'Content') {
|
||||
foreach($val as $head => $body) {
|
||||
if ($head == 'Body') {
|
||||
preg_match($pattern, $body, $matches);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$url = preg_replace('/=\s+/', '', $matches[0]);
|
||||
$url = preg_replace('/\s+[\w\W]+/', '', $url);
|
||||
|
||||
$I->amOnPage($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When Saya mengirim form berisi password baru
|
||||
*/
|
||||
public function sayaMengirimFormBerisiPasswordBaru()
|
||||
{
|
||||
$I = $this;
|
||||
|
||||
$I->fillField('email', 'admin@laraland.test');
|
||||
$I->fillField('password', 'newsecret');
|
||||
$I->fillField('password_confirmation', 'newsecret');
|
||||
$I->click('button[type=submit]');
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then Saya berhasil signin dengan password baru
|
||||
*/
|
||||
public function sayaBerhasilSigninDenganPasswordBaru()
|
||||
{
|
||||
$I = $this;
|
||||
|
||||
$I->seeCurrentUrlEquals('/home');
|
||||
$I->see('Your password has been reset!');
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @Given Saya berada di halaman registrasi
|
||||
*/
|
||||
public function sayaBeradaDiHalamanRegistrasi()
|
||||
{
|
||||
$I = $this;
|
||||
|
||||
$I->amOnPage('/register');
|
||||
}
|
||||
|
||||
/**
|
||||
* @When Saya mengirim form registrasi
|
||||
*/
|
||||
public function sayaMengirimFormRegistrasi()
|
||||
{
|
||||
$I = $this;
|
||||
|
||||
$I->fillField('name', \Faker\Factory::create()->name);
|
||||
$I->fillField('email', 'admin2@laraland.test');
|
||||
$I->fillField('password', 'sosecret');
|
||||
$I->fillField('password_confirmation', 'sosecret');
|
||||
$I->click('button[type=submit]');
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then Saya akan dialihkan ke halaman dashboard
|
||||
*/
|
||||
public function sayaAkanDialihkanKeHalamanDashboard()
|
||||
{
|
||||
$I = $this;
|
||||
|
||||
$I->seeCurrentUrlEquals('/home');
|
||||
$I->see('Dashboard');
|
||||
}
|
||||
}
|
26
tests/_support/FunctionalTester.php
Normal file
26
tests/_support/FunctionalTester.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* Inherited Methods
|
||||
* @method void wantToTest($text)
|
||||
* @method void wantTo($text)
|
||||
* @method void execute($callable)
|
||||
* @method void expectTo($prediction)
|
||||
* @method void expect($prediction)
|
||||
* @method void amGoingTo($argumentation)
|
||||
* @method void am($role)
|
||||
* @method void lookForwardTo($achieveValue)
|
||||
* @method void comment($description)
|
||||
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
|
||||
*
|
||||
* @SuppressWarnings(PHPMD)
|
||||
*/
|
||||
class FunctionalTester extends \Codeception\Actor
|
||||
{
|
||||
use _generated\FunctionalTesterActions;
|
||||
|
||||
/**
|
||||
* Define custom actions here
|
||||
*/
|
||||
}
|
35
tests/_support/Helper/Acceptance.php
Normal file
35
tests/_support/Helper/Acceptance.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
namespace Helper;
|
||||
|
||||
// here you can define custom actions
|
||||
// all public methods declared in helper class will be available in $I
|
||||
|
||||
class Acceptance extends \Codeception\Module
|
||||
{
|
||||
public function cleanMessages(\GuzzleHttp\Client $mailcatcher)
|
||||
{
|
||||
$mailcatcher->delete('messages');
|
||||
}
|
||||
|
||||
public function getLastMessage(\GuzzleHttp\Client $mailcatcher)
|
||||
{
|
||||
$messages = $this->getMessages($mailcatcher);
|
||||
if (empty($messages)) $this->fail('No messages received');
|
||||
|
||||
return reset($messages);
|
||||
}
|
||||
|
||||
public function getMessages(\GuzzleHttp\Client $mailcatcher)
|
||||
{
|
||||
$jsonResponse = $mailcatcher->get('messages');
|
||||
|
||||
return json_decode($jsonResponse->getBody());
|
||||
}
|
||||
|
||||
public function requestEmailResetPasswordLink(\AcceptanceTester $I)
|
||||
{
|
||||
$I->amOnPage('/password/reset');
|
||||
$I->fillField('email', 'admin@laraland.test');
|
||||
$I->click('button[type=submit]');
|
||||
}
|
||||
}
|
10
tests/_support/Helper/Functional.php
Normal file
10
tests/_support/Helper/Functional.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
namespace Helper;
|
||||
|
||||
// here you can define custom actions
|
||||
// all public methods declared in helper class will be available in $I
|
||||
|
||||
class Functional extends \Codeception\Module
|
||||
{
|
||||
|
||||
}
|
10
tests/_support/Helper/Unit.php
Normal file
10
tests/_support/Helper/Unit.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
namespace Helper;
|
||||
|
||||
// here you can define custom actions
|
||||
// all public methods declared in helper class will be available in $I
|
||||
|
||||
class Unit extends \Codeception\Module
|
||||
{
|
||||
|
||||
}
|
26
tests/_support/UnitTester.php
Normal file
26
tests/_support/UnitTester.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* Inherited Methods
|
||||
* @method void wantToTest($text)
|
||||
* @method void wantTo($text)
|
||||
* @method void execute($callable)
|
||||
* @method void expectTo($prediction)
|
||||
* @method void expect($prediction)
|
||||
* @method void amGoingTo($argumentation)
|
||||
* @method void am($role)
|
||||
* @method void lookForwardTo($achieveValue)
|
||||
* @method void comment($description)
|
||||
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
|
||||
*
|
||||
* @SuppressWarnings(PHPMD)
|
||||
*/
|
||||
class UnitTester extends \Codeception\Actor
|
||||
{
|
||||
use _generated\UnitTesterActions;
|
||||
|
||||
/**
|
||||
* Define custom actions here
|
||||
*/
|
||||
}
|
2
tests/_support/_generated/.gitignore
vendored
Normal file
2
tests/_support/_generated/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
22
tests/acceptance.suite.yml
Normal file
22
tests/acceptance.suite.yml
Normal file
@ -0,0 +1,22 @@
|
||||
# Codeception Test Suite Configuration
|
||||
#
|
||||
# Suite for acceptance tests.
|
||||
# Perform tests in browser using the WebDriver or PhpBrowser.
|
||||
# If you need both WebDriver and PHPBrowser tests - create a separate suite.
|
||||
|
||||
actor: AcceptanceTester
|
||||
modules:
|
||||
enabled:
|
||||
- PhpBrowser:
|
||||
# - WebDriver:
|
||||
# browser: chrome
|
||||
url: http://laraland.test
|
||||
- \Helper\Acceptance
|
||||
- Db:
|
||||
dsn: 'mysql:host=mariadb;port=3306;dbname=laraland'
|
||||
user: 'root'
|
||||
password: 'root'
|
||||
cleanup: true
|
||||
dump: 'tests/_data/db_laraland.sql'
|
||||
populate: true
|
||||
populator: 'mysql -u$user -p$password -h$host $dbname < $dump'
|
28
tests/acceptance/ResetPasswordCest.php
Normal file
28
tests/acceptance/ResetPasswordCest.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
|
||||
class ResetPasswordCest
|
||||
{
|
||||
public function _before(AcceptanceTester $I)
|
||||
{
|
||||
// Artisan::call('migrate');
|
||||
|
||||
// factory(App\User::class)->create(['email' => 'admin@laraland.test']);
|
||||
}
|
||||
|
||||
public function _after(AcceptanceTester $I)
|
||||
{
|
||||
// Artisan::call('migrate:rollback');
|
||||
}
|
||||
|
||||
// tests
|
||||
public function memintaLinkResetPassword(AcceptanceTester $I)
|
||||
{
|
||||
$I->wantTo('get emailed by system with reset password link inside it');
|
||||
|
||||
$I->amOnPage('/password/reset');
|
||||
$I->fillField('email', 'admin@laraland.test');
|
||||
$I->click('button[type=submit]');
|
||||
$I->see('We have e-mailed your password reset link!');
|
||||
}
|
||||
}
|
44
tests/acceptance/SigninCest.php
Normal file
44
tests/acceptance/SigninCest.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
|
||||
class SigninCest
|
||||
{
|
||||
public function _before(AcceptanceTester $I)
|
||||
{
|
||||
// Artisan::call('migrate');
|
||||
|
||||
// factory(App\User::class)->create(['email' => 'admin@laraland.test']);
|
||||
}
|
||||
|
||||
public function _after(AcceptanceTester $I)
|
||||
{
|
||||
// Artisan::call('migrate:rollback');
|
||||
}
|
||||
|
||||
// tests
|
||||
public function signinSuccessful(AcceptanceTester $I)
|
||||
{
|
||||
$I->wantTo('signin with correct credential and should go to dashboard page');
|
||||
|
||||
$I->amOnPage('/login');
|
||||
$I->fillField('email', 'admin@laraland.test');
|
||||
$I->fillField('password', 'secret');
|
||||
$I->click('button[type=submit]');
|
||||
|
||||
$I->see('Dashboard');
|
||||
$I->seeCurrentUrlEquals('/home');
|
||||
}
|
||||
|
||||
public function signinUnsuccessful(AcceptanceTester $I)
|
||||
{
|
||||
$I->wantTo('signin with incorrect credential and should go back to login page');
|
||||
|
||||
$I->amOnPage('/login');
|
||||
$I->fillField('email', 'admin@laraland.test');
|
||||
$I->fillField('password', 'notsecret');
|
||||
$I->click('button[type=submit]');
|
||||
|
||||
$I->see('Login');
|
||||
$I->seeCurrentUrlEquals('/login');
|
||||
}
|
||||
}
|
1
tests/acceptance/_bootstrap.php
Normal file
1
tests/acceptance/_bootstrap.php
Normal file
@ -0,0 +1 @@
|
||||
<?php
|
12
tests/acceptance/register.feature
Normal file
12
tests/acceptance/register.feature
Normal file
@ -0,0 +1,12 @@
|
||||
#language: id
|
||||
Fitur: registrasi user baru
|
||||
|
||||
Sistem dapat mendaftarkan user(admin) baru
|
||||
dengan mengisi form registrasi yang ada di halaman depan aplikasi
|
||||
|
||||
|
||||
Skenario: registrasi dan masuk ke halaman dashboard
|
||||
|
||||
Dengan Saya berada di halaman registrasi
|
||||
Ketika Saya mengirim form registrasi
|
||||
Maka Saya akan dialihkan ke halaman dashboard
|
21
tests/acceptance/reset_password.feature
Normal file
21
tests/acceptance/reset_password.feature
Normal file
@ -0,0 +1,21 @@
|
||||
#language: id
|
||||
Fitur: reset password
|
||||
|
||||
Pengguna dapat mengganti password
|
||||
dengan memasukkan email pada halaman reset password
|
||||
lalu link reset password akan dikirimkan ke email tersebut
|
||||
dan pengguna dapat membuat password baru melalui link tersebut
|
||||
|
||||
|
||||
Skenario: meminta link reset password
|
||||
|
||||
Dengan Saya mempunyai hak akses di database
|
||||
Ketika Saya mengirim form berisi email saya
|
||||
Maka Saya melihat bahwa sebuah email telah dikirim dari sistem
|
||||
|
||||
|
||||
Skenario: mengganti password
|
||||
|
||||
Dengan Saya membuka link pada email dari sistem
|
||||
Ketika Saya mengirim form berisi password baru
|
||||
Maka Saya berhasil signin dengan password baru
|
12
tests/functional.suite.yml
Normal file
12
tests/functional.suite.yml
Normal file
@ -0,0 +1,12 @@
|
||||
# Codeception Test Suite Configuration
|
||||
#
|
||||
# Suite for functional tests
|
||||
# Emulate web requests and make application process them
|
||||
# Include one of framework modules (Symfony2, Yii2, Laravel5) to use it
|
||||
# Remove this suite if you don't use frameworks
|
||||
|
||||
actor: FunctionalTester
|
||||
modules:
|
||||
enabled:
|
||||
# add a framework module here
|
||||
- \Helper\Functional
|
9
tests/unit.suite.yml
Normal file
9
tests/unit.suite.yml
Normal file
@ -0,0 +1,9 @@
|
||||
# Codeception Test Suite Configuration
|
||||
#
|
||||
# Suite for unit or integration tests.
|
||||
|
||||
actor: UnitTester
|
||||
modules:
|
||||
enabled:
|
||||
- Asserts
|
||||
- \Helper\Unit
|
Loading…
Reference in New Issue
Block a user