├── public
├── favicon.ico
├── packages
│ └── .gitkeep
├── robots.txt
├── .htaccess
└── index.php
├── app
├── commands
│ ├── .gitkeep
│ └── GenerateRepository.php
├── config
│ ├── packages
│ │ └── .gitkeep
│ ├── testing
│ │ ├── database.php
│ │ ├── cache.php
│ │ └── session.php
│ ├── compile.php
│ ├── workbench.php
│ ├── view.php
│ ├── queue.php
│ ├── remote.php
│ ├── auth.php
│ ├── cache.php
│ ├── mail.php
│ ├── database.php
│ ├── session.php
│ └── app.php
├── controllers
│ ├── .gitkeep
│ ├── BaseController.php
│ ├── HomeController.php
│ ├── UsersController.php
│ ├── Api
│ │ └── PostsController.php
│ ├── AuthController.php
│ └── PostsController.php
├── database
│ ├── seeds
│ │ ├── .gitkeep
│ │ ├── DatabaseSeeder.php
│ │ └── UsersTableSeeder.php
│ ├── migrations
│ │ ├── .gitkeep
│ │ ├── 2014_04_19_111119_remember_token_for_users_table.php
│ │ ├── 2013_05_07_211323_create_posts_table.php
│ │ └── 2013_05_07_211532_create_users_table.php
│ └── testing.sqlite
├── start
│ ├── local.php
│ ├── artisan.php
│ └── global.php
├── storage
│ ├── .gitignore
│ ├── cache
│ │ └── .gitignore
│ ├── logs
│ │ └── .gitignore
│ ├── meta
│ │ └── .gitignore
│ ├── sessions
│ │ └── .gitignore
│ └── views
│ │ └── .gitignore
├── views
│ ├── flash.blade.php
│ ├── hello.blade.php
│ ├── form.blade.php
│ ├── emails
│ │ └── auth
│ │ │ └── reminder.blade.php
│ ├── special-characters.blade.php
│ ├── users
│ │ ├── show.blade.php
│ │ └── edit.blade.php
│ ├── posts
│ │ ├── create.blade.php
│ │ ├── edit.blade.php
│ │ ├── show.blade.php
│ │ └── index.blade.php
│ ├── layouts
│ │ └── scaffold.blade.php
│ └── auth
│ │ ├── login.blade.php
│ │ └── register.blade.php
├── models
│ ├── Post.php
│ └── User.php
├── tests
│ ├── TestCase.php
│ └── ExampleTest.php
├── lang
│ └── en
│ │ ├── pagination.php
│ │ ├── reminders.php
│ │ └── validation.php
├── routes.php
└── filters.php
├── .gitattributes
├── tests
├── unit
│ ├── _bootstrap.php
│ └── AuthTest.php
├── api
│ ├── _bootstrap.php
│ └── PostsResourceCest.php
├── acceptance
│ ├── _bootstrap.php
│ └── RegisterCept.php
├── unit.suite.yml
├── functional.suite.yml
├── functional
│ ├── FlashCept.php
│ ├── IndexCept.php
│ ├── BackCept.php
│ ├── SessionCept.php
│ ├── _bootstrap.php
│ ├── SpecialCharactersCept.php
│ ├── FormCept.php
│ ├── RegisterCept.php
│ ├── FormErrorsCept.php
│ ├── LoginCept.php
│ ├── EditProfileCept.php
│ ├── RoutesCest.php
│ ├── InternalDomainsCest.php
│ ├── AuthCest.php
│ └── PostCrudCest.php
├── api.suite.yml
├── _support
│ ├── Helper
│ │ ├── Api.php
│ │ ├── Unit.php
│ │ ├── Acceptance.php
│ │ └── Functional.php
│ ├── ApiTester.php
│ ├── UnitTester.php
│ ├── AcceptanceTester.php
│ ├── FunctionalTester.php
│ └── Page
│ │ └── Functional
│ │ └── Posts.php
├── acceptance.suite.yml
└── _data
│ └── dump.sql
├── CONTRIBUTING.md
├── .gitignore
├── codeception.yml
├── .travis.yml
├── server.php
├── phpunit.xml
├── composer.json
├── bootstrap
├── paths.php
├── start.php
└── autoload.php
├── readme.md
├── artisan
└── c3.php
/public/favicon.ico:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/commands/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
--------------------------------------------------------------------------------
/app/config/packages/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/controllers/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/database/seeds/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/public/packages/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/database/migrations/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/start/local.php:
--------------------------------------------------------------------------------
1 | Hello World!
5 |
6 | @stop
--------------------------------------------------------------------------------
/tests/acceptance/_bootstrap.php:
--------------------------------------------------------------------------------
1 | wantTo('see flash message');
4 | $I->amOnPage('/flash');
5 | $I->see("It's a flash", '.flash');
--------------------------------------------------------------------------------
/tests/functional/IndexCept.php:
--------------------------------------------------------------------------------
1 | wantTo('open index page of site');
4 | $I->amOnPage('/');
5 | $I->see('Hello World', 'h1');
6 |
--------------------------------------------------------------------------------
/tests/api.suite.yml:
--------------------------------------------------------------------------------
1 | class_name: ApiTester
2 | modules:
3 | enabled:
4 | - \Helper\Api
5 | - Asserts
6 | - Laravel4
7 | - REST:
8 | depends: Laravel4
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /bootstrap/compiled.php
2 | /vendor
3 | tests/_output
4 | tests/_support/_generated
5 | composer.phar
6 | composer.lock
7 | .DS_Store
8 | .idea
9 | /app/database/database.sqlite*
10 | /tags
11 |
--------------------------------------------------------------------------------
/tests/functional/BackCept.php:
--------------------------------------------------------------------------------
1 | wantTo('redirect back using /back route');
4 | $I->amOnPage('/');
5 | $I->amOnPage('/back');
6 | $I->seeCurrentUrlEquals('/');
7 |
--------------------------------------------------------------------------------
/tests/functional/SessionCept.php:
--------------------------------------------------------------------------------
1 | wantTo('set a session variable');
4 | $I->amOnPage('/session/My%20Message');
5 | $I->seeInSession('message', 'My Message');
6 |
--------------------------------------------------------------------------------
/tests/_support/Helper/Api.php:
--------------------------------------------------------------------------------
1 | call('UsersTableSeeder');
13 | }
14 |
15 | }
--------------------------------------------------------------------------------
/app/config/testing/database.php:
--------------------------------------------------------------------------------
1 | array(
6 |
7 | 'sqlite' => array(
8 | 'driver' => 'sqlite',
9 | 'database' => __DIR__.'/../../database/testing.sqlite',
10 | 'prefix' => '',
11 | ),
12 | )
13 |
14 | );
15 |
--------------------------------------------------------------------------------
/public/.htaccess:
--------------------------------------------------------------------------------
1 |
2 | Options -MultiViews
3 | RewriteEngine On
4 |
5 | RewriteCond %{REQUEST_FILENAME} !-d
6 | RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]
7 |
8 | RewriteCond %{REQUEST_FILENAME} !-f
9 | RewriteRule ^ index.php [L]
10 |
--------------------------------------------------------------------------------
/app/views/form.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.scaffold')
2 |
3 | @section('main')
4 |
5 | Your message: {{{ $message }}}
6 |
7 |
8 | {{ Form::open() }}
9 | {{ Form::text('message') }}
10 | {{ Form::submit('Submit') }}
11 | {{ Form::close() }}
12 | @stop
--------------------------------------------------------------------------------
/tests/functional/_bootstrap.php:
--------------------------------------------------------------------------------
1 | delete();
8 | User::create(array('email' => 'john@doe.com', 'password' => Hash::make('password')));
9 | }
10 |
11 | }
--------------------------------------------------------------------------------
/app/views/emails/auth/reminder.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Password Reset
8 |
9 |
10 | To reset your password, complete this form: {{ URL::to('password/reset', array($token)) }}.
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/models/Post.php:
--------------------------------------------------------------------------------
1 | 'required',
10 | 'body' => 'required'
11 | );
12 |
13 | /**
14 | * @var array
15 | */
16 | protected $fillable = array('title', 'body');
17 |
18 | }
--------------------------------------------------------------------------------
/tests/functional/SpecialCharactersCept.php:
--------------------------------------------------------------------------------
1 | wantTo('test for text that uses special characters');
4 |
5 | $I->amOnPage('/special-characters');
6 |
7 | $I->see('Straße', 'p.character');
8 | $I->see('Straße', 'p.html-encoded');
9 |
10 | $I->click('Straße', 'a.character');
11 | $I->click('Straße', 'a.html-encoded');
12 |
--------------------------------------------------------------------------------
/tests/functional/FormCept.php:
--------------------------------------------------------------------------------
1 | wantTo('submit a form');
4 | $I->amOnPage('/form');
5 | $I->fillField('message', 'My message!');
6 | $I->click('Submit');
7 |
8 | $I->see('Your message: My message!');
9 |
10 | $I->fillField('message', 'Another message!');
11 | $I->click('Submit');
12 |
13 | $I->see('Your message: Another message!');
14 |
--------------------------------------------------------------------------------
/app/controllers/BaseController.php:
--------------------------------------------------------------------------------
1 | layout))
14 | {
15 | $this->layout = View::make($this->layout);
16 | }
17 | }
18 |
19 | }
--------------------------------------------------------------------------------
/codeception.yml:
--------------------------------------------------------------------------------
1 | actor: Tester
2 | coverage:
3 | enabled: true
4 | include:
5 | - app/controllers/*
6 | - app/models/*
7 | paths:
8 | tests: tests
9 | log: tests/_output
10 | data: tests/_data
11 | helpers: tests/_support
12 | settings:
13 | bootstrap: _bootstrap.php
14 | suite_class: \PHPUnit_Framework_TestSuite
15 | colors: true
16 | memory_limit: 1024M
17 |
--------------------------------------------------------------------------------
/app/tests/TestCase.php:
--------------------------------------------------------------------------------
1 | client->request('GET', '/');
13 |
14 | $this->assertTrue($this->client->getResponse()->isOk());
15 |
16 | $this->assertCount(1, $crawler->filter('h1:contains("Hello World!")'));
17 | }
18 |
19 | }
--------------------------------------------------------------------------------
/app/views/special-characters.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.scaffold')
2 |
3 | @section('main')
4 | Straße
5 | Straße
6 | Straße
7 | Straße
8 |
9 |
13 | @stop
--------------------------------------------------------------------------------
/tests/acceptance.suite.yml:
--------------------------------------------------------------------------------
1 | class_name: AcceptanceTester
2 | coverage:
3 | remote: true
4 | remote_context_options:
5 | http:
6 | timeout: 60
7 | modules:
8 | enabled:
9 | - \Helper\Acceptance
10 | - PhpBrowser:
11 | url: http://l4.app
12 | - Db:
13 | dsn: sqlite:app/database/database.sqlite
14 | user:
15 | password:
16 | dump: tests/_data/dump.sql
--------------------------------------------------------------------------------
/tests/acceptance/RegisterCept.php:
--------------------------------------------------------------------------------
1 | wantTo('register a user');
4 |
5 | $I->amOnPage('/auth/register');
6 | $I->fillField('name', 'John Doe');
7 | $I->fillField('email', 'example@example.com');
8 | $I->fillField('password', 'password');
9 | $I->fillField('password_confirmation', 'password');
10 | $I->click('button[type=submit]');
11 |
12 | $I->amOnPage('/');
13 | $I->see('Logged in as example@example.com');
14 |
--------------------------------------------------------------------------------
/tests/functional/RegisterCept.php:
--------------------------------------------------------------------------------
1 | wantTo('register a user');
4 |
5 | $I->amOnPage('/auth/register');
6 | $I->fillField('name', 'John Doe');
7 | $I->fillField('email', 'example@example.com');
8 | $I->fillField('password', 'password');
9 | $I->fillField('password_confirmation', 'password');
10 | $I->click('button[type=submit]');
11 |
12 | $I->amOnPage('/');
13 | $I->seeRecord('users', ['email' => 'example@example.com']);
14 | $I->seeAuthentication();
15 |
--------------------------------------------------------------------------------
/app/start/artisan.php:
--------------------------------------------------------------------------------
1 | wantTo('test session errors');
4 |
5 | $I->amOnPage('/auth/register');
6 | $I->click('button[type=submit]');
7 |
8 | $I->seeCurrentUrlEquals('/auth/register');
9 | $I->see('The name field is required.');
10 | $I->seeFormHasErrors();
11 | $I->seeFormErrorMessage('name', 'The name field is required.');
12 | $I->seeFormErrorMessages(array(
13 | 'name' => 'The name field is required.',
14 | 'email' => 'The email field is required.'
15 | ));
--------------------------------------------------------------------------------
/tests/functional/LoginCept.php:
--------------------------------------------------------------------------------
1 | wantTo('login as a user');
4 |
5 | $I->haveRecord('users', [
6 | 'email' => 'john@doe.com',
7 | 'password' => Hash::make('password'),
8 | 'created_at' => new DateTime(),
9 | 'updated_at' => new DateTime(),
10 | ]);
11 |
12 | $I->amOnPage('/auth/login');
13 | $I->fillField('email', 'john@doe.com');
14 | $I->fillField('password', 'password');
15 | $I->click('Login');
16 |
17 | $I->amOnPage('/');
18 | $I->seeAuthentication();
19 | $I->see('Logged in as john@doe.com');
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: php
2 |
3 | php:
4 | - 5.4
5 | - 5.5
6 | - 5.6
7 | - hhvm
8 |
9 | matrix:
10 | allow_failures:
11 | - php: hhvm
12 |
13 | branches:
14 | except:
15 | - gh-pages
16 |
17 | before_script:
18 | - touch app/database/database.sqlite
19 | - composer self-update
20 | - composer install -n --prefer-source
21 | - php artisan migrate --seed -n --force
22 | - ./vendor/bin/codecept build
23 |
24 | script:
25 | - ./vendor/bin/codecept run unit
26 | - ./vendor/bin/codecept run api
27 | - ./vendor/bin/codecept run functional
28 |
--------------------------------------------------------------------------------
/server.php:
--------------------------------------------------------------------------------
1 | '« Previous',
17 |
18 | 'next' => 'Next »',
19 |
20 | );
--------------------------------------------------------------------------------
/app/config/testing/cache.php:
--------------------------------------------------------------------------------
1 | 'array',
19 |
20 | );
--------------------------------------------------------------------------------
/app/views/users/show.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.scaffold')
2 |
3 | @section('main')
4 |
5 | Show User
6 |
7 |
8 |
9 |
10 | | ID |
11 | Email |
12 | Actions |
13 |
14 |
15 |
16 |
17 |
18 | | {{ $user->id }} |
19 | {{ $user->email }} |
20 | {{ link_to_route('users.edit', 'Edit', array($user->id), array('class' => 'btn btn-info')) }} |
21 |
22 |
23 |
24 |
25 | @stop
--------------------------------------------------------------------------------
/phpunit.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
15 | ./app/tests/
16 |
17 |
18 |
--------------------------------------------------------------------------------
/tests/functional/EditProfileCept.php:
--------------------------------------------------------------------------------
1 | wantTo('edit a profile');
4 |
5 | $user = User::create(['email' => 'johndoe@example.com', 'password' => Hash::make('password')]);
6 | $I->amOnPage('/auth/login');
7 | $I->fillField('email', 'johndoe@example.com');
8 | $I->fillField('password', 'password');
9 | $I->click('Login');
10 |
11 | $I->amOnPage('/users/1');
12 | $I->see('Logged in as johndoe@example.com');
13 |
14 | $I->click('Edit');
15 | $I->fillField('Email', 'john@doe.com');
16 | $I->click('Update');
17 |
18 | $I->seeCurrentUrlEquals('/users/1');
19 | $I->see('Logged in as john@doe.com');
--------------------------------------------------------------------------------
/app/config/testing/session.php:
--------------------------------------------------------------------------------
1 | 'native',
20 |
21 | );
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "require": {
3 | "laravel/framework": "~4.2.17",
4 | "patchwork/utf8": "~1.2"
5 | },
6 | "require-dev": {
7 | "Codeception/Codeception": "2.1.x-dev",
8 | "flow/jsonpath": "~0.2"
9 | },
10 | "autoload": {
11 | "classmap": [
12 | "app/commands",
13 | "app/controllers",
14 | "app/models",
15 | "app/database/migrations",
16 | "app/database/seeds",
17 | "app/tests/TestCase.php"
18 | ]
19 | },
20 | "scripts": {
21 | "post-install-cmd": [
22 | "php artisan optimize"
23 | ],
24 | "post-update-cmd": [
25 | "php artisan optimize"
26 | ]
27 | },
28 | "config": {
29 | "preferred-install": "dist"
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/app/database/migrations/2014_04_19_111119_remember_token_for_users_table.php:
--------------------------------------------------------------------------------
1 | string('remember_token', 100)->nullable();
17 | });
18 | }
19 |
20 | /**
21 | * Reverse the migration.
22 | *
23 | * @return void
24 | */
25 | public function down()
26 | {
27 | Schema::table('users', function($table)
28 | {
29 | $table->dropColumn('remember_token');
30 | });
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/tests/_support/ApiTester.php:
--------------------------------------------------------------------------------
1 | "Passwords must be six characters and match the confirmation.",
17 |
18 | "user" => "We can't find a user with that e-mail address.",
19 |
20 | "token" => "This password reset token is invalid.",
21 |
22 | );
--------------------------------------------------------------------------------
/tests/_support/AcceptanceTester.php:
--------------------------------------------------------------------------------
1 | Edit User
6 | {{ Form::model($user, array('method' => 'PATCH', 'route' => array('users.update', $user->id))) }}
7 |
8 | -
9 | {{ Form::label('email', 'Email') }}
10 | {{ Form::text('email') }}
11 |
12 | -
13 | {{ Form::submit('Update', array('class' => 'btn btn-info')) }}
14 | {{ link_to_route('users.show', 'Cancel', $user->id, array('class' => 'btn')) }}
15 |
16 |
17 | {{ Form::close() }}
18 |
19 | @if ($errors->any())
20 |
21 | {{ implode('', $errors->all('- :message
')) }}
22 |
23 | @endif
24 |
25 | @stop
--------------------------------------------------------------------------------
/app/views/posts/create.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.scaffold')
2 |
3 | @section('main')
4 |
5 | Create Post
6 |
7 | {{ Form::open(array('route' => 'posts.store')) }}
8 |
9 | -
10 | {{ Form::label('title', 'Title:') }}
11 | {{ Form::text('title') }}
12 |
13 |
14 | -
15 | {{ Form::label('body', 'Body:') }}
16 | {{ Form::textarea('body') }}
17 |
18 |
19 | -
20 | {{ Form::submit('Submit', array('class' => 'btn')) }}
21 |
22 |
23 | {{ Form::close() }}
24 |
25 | @if ($errors->any())
26 |
27 | {{ implode('', $errors->all('- :message
')) }}
28 |
29 | @endif
30 |
31 | @stop
32 |
33 |
34 |
--------------------------------------------------------------------------------
/app/database/migrations/2013_05_07_211323_create_posts_table.php:
--------------------------------------------------------------------------------
1 | increments('id');
17 | $table->string('title');
18 | $table->text('body');
19 | $table->timestamps();
20 | });
21 | }
22 |
23 | /**
24 | * Reverse the migrations.
25 | *
26 | * @return void
27 | */
28 | public function down()
29 | {
30 | Schema::drop('posts');
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/app/database/migrations/2013_05_07_211532_create_users_table.php:
--------------------------------------------------------------------------------
1 | increments('id');
17 | $table->string('email')->unique();
18 | $table->string('password');
19 | $table->timestamps();
20 | });
21 | }
22 |
23 | /**
24 | * Reverse the migrations.
25 | *
26 | * @return void
27 | */
28 | public function down()
29 | {
30 | Schema::drop('users');
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/tests/_data/dump.sql:
--------------------------------------------------------------------------------
1 | PRAGMA foreign_keys=OFF;
2 | BEGIN TRANSACTION;
3 | CREATE TABLE "migrations" ("migration" varchar not null, "batch" integer not null);
4 | INSERT INTO "migrations" VALUES('2013_05_07_211323_create_posts_table',1);
5 | INSERT INTO "migrations" VALUES('2013_05_07_211532_create_users_table',1);
6 | INSERT INTO "migrations" VALUES('2014_04_19_111119_remember_token_for_users_table',1);
7 | CREATE TABLE "posts" ("id" integer not null primary key autoincrement, "title" varchar not null, "body" text not null, "created_at" datetime not null, "updated_at" datetime not null);
8 | CREATE TABLE "users" ("id" integer not null primary key autoincrement, "email" varchar not null, "password" varchar not null, "created_at" datetime not null, "updated_at" datetime not null, "remember_token" varchar null);
9 | CREATE UNIQUE INDEX users_email_unique on "users" ("email");
10 | COMMIT;
11 |
--------------------------------------------------------------------------------
/app/views/posts/edit.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.scaffold')
2 |
3 | @section('main')
4 |
5 | Edit Post
6 | {{ Form::model($post, array('method' => 'PATCH', 'route' => array('posts.update', $post->id))) }}
7 |
8 | -
9 | {{ Form::label('title', 'Title:') }}
10 | {{ Form::text('title') }}
11 |
12 |
13 | -
14 | {{ Form::label('body', 'Body:') }}
15 | {{ Form::textarea('body') }}
16 |
17 |
18 | -
19 | {{ Form::submit('Update', array('class' => 'btn btn-info')) }}
20 | {{ link_to_route('posts.show', 'Cancel', $post->id, array('class' => 'btn')) }}
21 |
22 |
23 | {{ Form::close() }}
24 |
25 | @if ($errors->any())
26 |
27 | {{ implode('', $errors->all('- :message
')) }}
28 |
29 | @endif
30 |
31 | @stop
--------------------------------------------------------------------------------
/tests/functional/RoutesCest.php:
--------------------------------------------------------------------------------
1 | amOnRoute('posts.index');
9 | $I->seeCurrentUrlEquals('/posts');
10 | $I->seeCurrentActionIs('PostsController@index');
11 | }
12 |
13 | public function openPageByAction(FunctionalTester $I)
14 | {
15 | $I->amOnAction('PostsController@index');
16 | $I->seeCurrentUrlEquals('/posts');
17 | $I->seeCurrentRouteIs('posts.index');
18 | }
19 |
20 | public function openRouteWithDomainSpecified(FunctionalTester $I)
21 | {
22 | $I->amOnRoute('domain');
23 | $I->seeResponseCodeIs(200);
24 | $I->see('Domain route');
25 | }
26 |
27 | public function visitARouteWithASubdomain(FunctionalTester $I)
28 | {
29 | $I->amOnRoute('subdomain');
30 | $I->see('Subdomain route');
31 | }
32 |
33 | }
--------------------------------------------------------------------------------
/tests/unit/AuthTest.php:
--------------------------------------------------------------------------------
1 | userAttributes= [
16 | 'email' => 'john@doe.com',
17 | 'password' => Hash::make('password'),
18 | 'created_at' => new DateTime(),
19 | 'updated_at' => new DateTime(),
20 | ];
21 | }
22 |
23 | public function testAuthFacadeReturnsCorrectInformationAfterLoggingIn()
24 | {
25 | $this->assertNull(Auth::user());
26 | $this->assertNull(Auth::id());
27 |
28 | $user = User::create($this->userAttributes);
29 | $this->tester->amLoggedAs($user);
30 |
31 | $this->assertEquals($user, Auth::user());
32 | $this->assertEquals($user->id, Auth::id());
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/app/views/posts/show.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.scaffold')
2 |
3 | @section('main')
4 |
5 | Show Post
6 |
7 | {{ link_to_route('posts.index', 'Return to all posts') }}
8 |
9 |
10 |
11 |
12 | | Title |
13 | Body |
14 |
15 |
16 |
17 |
18 |
19 | | {{ $post->title }} |
20 | {{ $post->body }} |
21 | {{ link_to_route('posts.edit', 'Edit', array($post->id), array('class' => 'btn btn-info')) }} |
22 |
23 | {{ Form::open(array('method' => 'DELETE', 'route' => array('posts.destroy', $post->id))) }}
24 | {{ Form::submit('Delete', array('class' => 'btn btn-danger')) }}
25 | {{ Form::close() }}
26 | |
27 |
28 |
29 |
30 |
31 | @stop
--------------------------------------------------------------------------------
/app/config/workbench.php:
--------------------------------------------------------------------------------
1 | '',
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Workbench Author E-Mail Address
21 | |--------------------------------------------------------------------------
22 | |
23 | | Like the option above, your e-mail address is used when generating new
24 | | workbench packages. The e-mail is placed in your composer.json file
25 | | automatically after the package is created by the workbench tool.
26 | |
27 | */
28 |
29 | 'email' => '',
30 |
31 | );
--------------------------------------------------------------------------------
/app/config/view.php:
--------------------------------------------------------------------------------
1 | array(__DIR__.'/../views'),
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Pagination View
21 | |--------------------------------------------------------------------------
22 | |
23 | | This view will be used to render the pagination link output, and can
24 | | be easily customized here to show any view you like. A clean view
25 | | compatible with Twitter's Bootstrap is given to you by default.
26 | |
27 | */
28 |
29 | 'pagination' => 'pagination::slider',
30 |
31 | );
32 |
--------------------------------------------------------------------------------
/app/routes.php:
--------------------------------------------------------------------------------
1 | 'example.com', 'as' => 'domain', 'uses' => 'HomeController@domain']);
3 | Route::get('', ['domain' => 'subdomain.example.com', 'as' => 'subdomain', 'uses' => 'HomeController@subdomain']);
4 | Route::get('', ['domain' => '{w}.example.com', 'as' => 'wildcard', 'uses' => 'HomeController@wildcard']);
5 | Route::get('', ['domain' => '{w1}.{w2}.example.com', 'as' => 'multiple-wildcards', 'uses' => 'HomeController@multipleWildcards']);
6 |
7 | Route::get('/', 'HomeController@index');
8 | Route::get('flash', 'HomeController@flash');
9 | Route::get('back', 'HomeController@back');
10 | Route::get('/secure', ['before' => 'auth', 'uses' => 'HomeController@secure']);
11 | Route::get('session/{message}', 'HomeController@session');
12 | Route::get('special-characters', 'HomeController@specialCharacters');
13 | Route::match(['get', 'post'], 'form', 'HomeController@form');
14 |
15 | Route::resource('posts', 'PostsController');
16 | Route::resource('api/posts', 'Api\PostsController');
17 | Route::resource('users', 'UsersController');
18 |
19 | Route::controller('auth', 'AuthController');
20 |
--------------------------------------------------------------------------------
/app/views/layouts/scaffold.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
12 |
13 |
14 |
15 |
16 | @if (Session::has('message'))
17 |
18 |
{{{ Session::get('message') }}}
19 |
20 | @endif
21 |
22 | @yield('main')
23 |
24 |
25 | @if (Auth::user())
26 | Logged in as {{{ Auth::user()->email }}}.
27 |
Logout
28 | @else
29 | Not logged in
30 | @endif
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/app/views/posts/index.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.scaffold')
2 |
3 | @section('main')
4 |
5 | All Posts
6 |
7 | {{ link_to_route('posts.create', 'Add new post') }}
8 |
9 | @if ($posts->count())
10 |
11 |
12 |
13 | | Title |
14 | Body |
15 |
16 |
17 |
18 |
19 | @foreach ($posts as $post)
20 |
21 | | {{ $post->title }} |
22 | {{ $post->body }} |
23 | {{ link_to_route('posts.edit', 'Edit', array($post->id), array('class' => 'btn btn-info')) }} |
24 |
25 | {{ Form::open(array('method' => 'DELETE', 'route' => array('posts.destroy', $post->id))) }}
26 | {{ Form::submit('Delete', array('class' => 'btn btn-danger')) }}
27 | {{ Form::close() }}
28 | |
29 |
30 | @endforeach
31 |
32 |
33 | @else
34 | There are no posts
35 | @endif
36 |
37 | @stop
--------------------------------------------------------------------------------
/tests/functional/InternalDomainsCest.php:
--------------------------------------------------------------------------------
1 | amOnPage('https://www.google.com');
9 | $I->fail('Visiting an external URL should throw an ExternalUrlException');
10 | } catch (\Codeception\Exception\ExternalUrlException $ignored) {
11 | }
12 | }
13 |
14 | public function testWithDomain(FunctionalTester $I)
15 | {
16 | $I->amOnPage('http://example.com');
17 | $I->see('Domain route');
18 | }
19 |
20 | public function testWithSubdomain(FunctionalTester $I)
21 | {
22 | $I->amOnPage('http://subdomain.example.com');
23 | $I->see('Subdomain route');
24 | }
25 |
26 | public function testWithWildcardInDomain(FunctionalTester $I)
27 | {
28 | $I->amOnPage('http://wildcard.example.com');
29 | $I->see('Wildcard route');
30 | }
31 |
32 | public function testWithMultipleWildcardsInDomain(FunctionalTester $I)
33 | {
34 | $I->amOnPage('http://wild.card.example.com');
35 | $I->see('Multiple wildcards route');
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/app/controllers/HomeController.php:
--------------------------------------------------------------------------------
1 | userAttributes= [
13 | 'email' => 'john@doe.com',
14 | 'password' => \Hash::make('password'),
15 | 'created_at' => new DateTime(),
16 | 'updated_at' => new DateTime(),
17 | ];
18 | }
19 |
20 | public function loginUsingUserRecord(FunctionalTester $I)
21 | {
22 | $I->amLoggedAs(User::create($this->userAttributes));
23 |
24 | $I->amOnPage(PostsPage::$url);
25 |
26 | $I->seeCurrentUrlEquals(PostsPage::$url);
27 | $I->seeAuthentication();
28 | }
29 |
30 | public function loginUsingCredentials(FunctionalTester $I)
31 | {
32 | $I->haveRecord('users', $this->userAttributes);
33 | $I->amLoggedAs(['email' => 'john@doe.com', 'password' => 'password']);
34 |
35 | $I->amOnPage(PostsPage::$url);
36 |
37 | $I->seeCurrentUrlEquals(PostsPage::$url);
38 | $I->seeAuthentication();
39 | }
40 |
41 | public function secureRouteWithoutAuthenticatedUser(FunctionalTester $I)
42 | {
43 | $I->haveEnabledFilters();
44 |
45 | $I->amOnPage('/secure');
46 |
47 | $I->seeCurrentUrlEquals('/auth/login');
48 | }
49 |
50 | public function secureRouteWithAuthenticatedUser(FunctionalTester $I)
51 | {
52 | $I->haveEnabledFilters();
53 | $I->amLoggedAs(User::create($this->userAttributes));
54 |
55 | $I->amOnPage('/secure');
56 |
57 | $I->see('Hello World');
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/app/config/queue.php:
--------------------------------------------------------------------------------
1 | 'sync',
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Queue Connections
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may configure the connection information for each server that
26 | | is used by your application. A default configuration has been added
27 | | for each back-end shipped with Laravel. You are free to add more.
28 | |
29 | */
30 |
31 | 'connections' => array(
32 |
33 | 'sync' => array(
34 | 'driver' => 'sync',
35 | ),
36 |
37 | 'beanstalkd' => array(
38 | 'driver' => 'beanstalkd',
39 | 'host' => 'localhost',
40 | 'queue' => 'default',
41 | ),
42 |
43 | 'sqs' => array(
44 | 'driver' => 'sqs',
45 | 'key' => 'your-public-key',
46 | 'secret' => 'your-secret-key',
47 | 'queue' => 'your-queue-url',
48 | 'region' => 'us-east-1',
49 | ),
50 |
51 | 'iron' => array(
52 | 'driver' => 'iron',
53 | 'project' => 'your-project-id',
54 | 'token' => 'your-token',
55 | 'queue' => 'your-queue-name',
56 | ),
57 |
58 | ),
59 |
60 | );
61 |
--------------------------------------------------------------------------------
/app/config/remote.php:
--------------------------------------------------------------------------------
1 | 'production',
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Remote Server Connections
21 | |--------------------------------------------------------------------------
22 | |
23 | | These are the servers that will be accessible via the SSH task runner
24 | | facilities of Laravel. This feature radically simplifies executing
25 | | tasks on your servers, such as deploying out these applications.
26 | |
27 | */
28 |
29 | 'connections' => array(
30 |
31 | 'production' => array(
32 | 'host' => '',
33 | 'username' => '',
34 | 'password' => '',
35 | 'key' => '',
36 | 'keyphrase' => '',
37 | 'root' => '/var/www',
38 | ),
39 |
40 | ),
41 |
42 | /*
43 | |--------------------------------------------------------------------------
44 | | Remote Server Groups
45 | |--------------------------------------------------------------------------
46 | |
47 | | Here you may list connections under a single group name, which allows
48 | | you to easily access all of the servers at once using a short name
49 | | that is extremely easy to remember, such as "web" or "database".
50 | |
51 | */
52 |
53 | 'groups' => array(
54 |
55 | 'web' => array('production')
56 |
57 | ),
58 |
59 | );
--------------------------------------------------------------------------------
/app/controllers/UsersController.php:
--------------------------------------------------------------------------------
1 | user = $user;
19 | }
20 |
21 | /**
22 | * Display the specified resource.
23 | *
24 | * @param int $id
25 | * @return Response
26 | */
27 | public function show($id)
28 | {
29 | $user = $this->user->findOrFail($id);
30 |
31 | return View::make('users.show', compact('user'));
32 | }
33 |
34 | /**
35 | * Show the form for editing the specified resource.
36 | *
37 | * @param int $id
38 | * @return Response
39 | */
40 | public function edit($id)
41 | {
42 | $user = $this->user->findOrFail($id);
43 |
44 | return View::make('users.edit', compact('user'));
45 | }
46 |
47 | /**
48 | * Update the specified resource in storage.
49 | *
50 | * @param int $id
51 | * @return Response
52 | */
53 | public function update($id)
54 | {
55 | $input = Input::only('email');
56 | $validation = Validator::make($input, ['email' => 'required|email']);
57 |
58 | if ($validation->passes())
59 | {
60 | $user = $this->user->find($id);
61 | $user->update($input);
62 |
63 | return Redirect::route('users.show', $id);
64 | }
65 |
66 | return Redirect::route('users.edit', $id)
67 | ->withInput()
68 | ->withErrors($validation)
69 | ->with('message', 'There were validation errors.');
70 | }
71 |
72 | }
--------------------------------------------------------------------------------
/public/index.php:
--------------------------------------------------------------------------------
1 |
10 | */
11 |
12 | /*
13 | |--------------------------------------------------------------------------
14 | | Register The Auto Loader
15 | |--------------------------------------------------------------------------
16 | |
17 | | Composer provides a convenient, automatically generated class loader
18 | | for our application. We just need to utilize it! We'll require it
19 | | into the script here so that we do not have to worry about the
20 | | loading of any our classes "manually". Feels great to relax.
21 | |
22 | */
23 |
24 | require __DIR__.'/../bootstrap/autoload.php';
25 |
26 | /*
27 | |--------------------------------------------------------------------------
28 | | Turn On The Lights
29 | |--------------------------------------------------------------------------
30 | |
31 | | We need to illuminate PHP development, so let's turn on the lights.
32 | | This bootstraps the framework and gets it ready for use, then it
33 | | will load up this application so that we can run it and send
34 | | the responses back to the browser and delight these users.
35 | |
36 | */
37 |
38 | $app = require_once __DIR__.'/../bootstrap/start.php';
39 |
40 | /*
41 | |--------------------------------------------------------------------------
42 | | Run The Application
43 | |--------------------------------------------------------------------------
44 | |
45 | | Once we have the application, we can simply call the run method,
46 | | which will execute the request and send the response back to
47 | | the client's browser allowing them to enjoy the creative
48 | | and wonderful application we have whipped up for them.
49 | |
50 | */
51 |
52 | $app->run();
--------------------------------------------------------------------------------
/tests/_support/Page/Functional/Posts.php:
--------------------------------------------------------------------------------
1 | '#title', 'body' => 'Body:'];
16 |
17 | /**
18 | * @var FunctionalTester;
19 | */
20 | protected $tester;
21 |
22 | public function __construct(\FunctionalTester $I)
23 | {
24 | $this->tester = $I;
25 | }
26 |
27 | public static function of(\FunctionalTester $I)
28 | {
29 | return new static($I);
30 | }
31 |
32 | public function createPost($fields = array())
33 | {
34 | $I = $this->tester;
35 | $I->amOnPage(self::$url);
36 | $I->click('Add new post');
37 | $this->fillFormFields($fields);
38 | $I->click('Submit');
39 |
40 | return $this;
41 | }
42 |
43 | public function editPost($id, $fields = array())
44 | {
45 | $I = $this->tester;
46 | $I->amOnPage(self::route("/$id/edit"));
47 | $I->see('Edit Post', 'h1');
48 | $this->fillFormFields($fields);
49 | $I->click('Update');
50 | }
51 |
52 | public function deletePost($id)
53 | {
54 | $I = $this->tester;
55 | $I->amOnPage($I->amOnPage(self::route("/$id")));
56 | $I->click('Delete');
57 | }
58 |
59 | protected function fillFormFields($data)
60 | {
61 | foreach ($data as $field => $value) {
62 | if (!isset(self::$formFields[$field])) {
63 | throw new \Exception("Form field $field does not exist");
64 | }
65 | $this->tester->fillField(self::$formFields[$field], $value);
66 | }
67 | }
68 |
69 | }
--------------------------------------------------------------------------------
/app/models/User.php:
--------------------------------------------------------------------------------
1 | getKey();
37 | }
38 |
39 | /**
40 | * Get the password for the user.
41 | *
42 | * @return string
43 | */
44 | public function getAuthPassword()
45 | {
46 | return $this->password;
47 | }
48 |
49 | /**
50 | * Get the token value for the "remember me" session.
51 | *
52 | * @return string
53 | */
54 | public function getRememberToken()
55 | {
56 | return $this->remember_token;
57 | }
58 |
59 | /**
60 | * Set the token value for the "remember me" session.
61 | *
62 | * @param string $value
63 | * @return void
64 | */
65 | public function setRememberToken($value)
66 | {
67 | $this->remember_token = $value;
68 | }
69 |
70 | /**
71 | * Get the column name for the "remember me" token.
72 | *
73 | * @return string
74 | */
75 | public function getRememberTokenName()
76 | {
77 | return 'remember_me';
78 | }
79 |
80 | /**
81 | * Get the e-mail address where password reminders are sent.
82 | *
83 | * @return string
84 | */
85 | public function getReminderEmail()
86 | {
87 | return $this->email;
88 | }
89 |
90 | }
--------------------------------------------------------------------------------
/tests/functional/PostCrudCest.php:
--------------------------------------------------------------------------------
1 | createPost(['title' => 'Hello world', 'body' => 'And greetings for all']);
11 | $I->seeCurrentUrlEquals(PostsPage::$url);
12 | $I->see('Hello world', '.table');
13 | }
14 |
15 | public function createPostValidationFails(FunctionalTester $I)
16 | {
17 | PostsPage::of($I)->createPost();
18 | $I->seeCurrentUrlEquals(PostsPage::route('/create'));
19 | $I->see('The body field is required.', '.error');
20 | $I->see('The title field is required.', '.error');
21 | }
22 |
23 | public function editPost(FunctionalTester $I)
24 | {
25 | $randTitle = "Edited at " . microtime();
26 | $id = $I->haveRecord('posts', $this->getPostAttributes());
27 | PostsPage::of($I)->editPost($id, ['title' => 'Edited at ' . $randTitle]);
28 | $I->seeCurrentUrlEquals(PostsPage::route("/$id"));
29 | $I->see('Show Post', 'h1');
30 | $I->see($randTitle);
31 | $I->dontSee('Hello Universe');
32 | }
33 |
34 | public function deletePost(FunctionalTester $I)
35 | {
36 | $id = $I->haveRecord('posts', $this->getPostAttributes());
37 | $I->amOnPage(PostsPage::$url);
38 | $I->see('Hello Universe');
39 | PostsPage::of($I)->deletePost($id);
40 | $I->seeCurrentUrlEquals(PostsPage::$url);
41 | $I->dontSee('Hello Universe');
42 | }
43 |
44 | private function getPostAttributes($attributes = [])
45 | {
46 | return array_merge([
47 | 'title' => 'Hello Universe',
48 | 'body' => 'You are so awesome',
49 | 'created_at' => new DateTime(),
50 | 'updated_at' => new DateTime()
51 | ], $attributes);
52 | }
53 |
54 | }
--------------------------------------------------------------------------------
/bootstrap/paths.php:
--------------------------------------------------------------------------------
1 | __DIR__.'/../app',
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Public Path
21 | |--------------------------------------------------------------------------
22 | |
23 | | The public path contains the assets for your web application, such as
24 | | your JavaScript and CSS files, and also contains the primary entry
25 | | point for web requests into these applications from the outside.
26 | |
27 | */
28 |
29 | 'public' => __DIR__.'/../public',
30 |
31 | /*
32 | |--------------------------------------------------------------------------
33 | | Base Path
34 | |--------------------------------------------------------------------------
35 | |
36 | | The base path is the root of the Laravel installation. Most likely you
37 | | will not need to change this value. But, if for some wild reason it
38 | | is necessary you will do so here, just proceed with some caution.
39 | |
40 | */
41 |
42 | 'base' => __DIR__.'/..',
43 |
44 | /*
45 | |--------------------------------------------------------------------------
46 | | Storage Path
47 | |--------------------------------------------------------------------------
48 | |
49 | | The storage path is used by Laravel to store cached Blade views, logs
50 | | and other pieces of information. You may modify the path here when
51 | | you want to change the location of this directory for your apps.
52 | |
53 | */
54 |
55 | 'storage' => __DIR__.'/../app/storage',
56 |
57 | );
58 |
--------------------------------------------------------------------------------
/app/config/auth.php:
--------------------------------------------------------------------------------
1 | 'eloquent',
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Authentication Model
23 | |--------------------------------------------------------------------------
24 | |
25 | | When using the "Eloquent" authentication driver, we need to know which
26 | | Eloquent model should be used to retrieve your users. Of course, it
27 | | is often just the "User" model but you may use whatever you like.
28 | |
29 | */
30 |
31 | 'model' => 'User',
32 |
33 | /*
34 | |--------------------------------------------------------------------------
35 | | Authentication Table
36 | |--------------------------------------------------------------------------
37 | |
38 | | When using the "Database" authentication driver, we need to know which
39 | | table should be used to retrieve your users. We have chosen a basic
40 | | default value but you may easily change it to any table you like.
41 | |
42 | */
43 |
44 | 'table' => 'users',
45 |
46 | /*
47 | |--------------------------------------------------------------------------
48 | | Password Reminder Settings
49 | |--------------------------------------------------------------------------
50 | |
51 | | Here you may set the settings for password reminders, including a view
52 | | that should be used as your password reminder e-mail. You will also
53 | | be able to set the name of the table that holds the reset tokens.
54 | |
55 | */
56 |
57 | 'reminder' => array(
58 |
59 | 'email' => 'emails.auth.reminder', 'table' => 'password_reminders',
60 |
61 | ),
62 |
63 | );
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | # Sample Laravel Application with Codeception tests.
2 |
3 | [](https://travis-ci.org/Codeception/sample-l4-app) <- see Travis CI integration
4 |
5 | ### Setup
6 |
7 | - Clone repo
8 | - Install dependencies:
9 | - `composer install`
10 | - Create databases:
11 | - `touch app/database/database.sqlite`
12 | - `touch app/database/testing.sqlite`
13 | - `php artisan migrate --seed`
14 | - `php artisan migrate --env=testing`
15 | - Server: run `php artisan serve`
16 | - Browse to localhost:8000/posts
17 | - Enter `john@doe.com` as username, and `password` as the password
18 |
19 | ### To test
20 |
21 | Run Codeception, installed via Composer
22 |
23 | ```
24 | ./vendor/bin/codecept run
25 | ```
26 |
27 | ## Tests
28 |
29 | Please check out some [good test examples](https://github.com/Codeception/sample-l4-app/tree/master/tests) provided.
30 |
31 | ### Functional Tests
32 |
33 | Demonstrates testing of [CRUD application](https://github.com/Codeception/sample-l4-app/blob/master/tests/functional/PostCrudCest.php) with
34 |
35 | * [PageObjects](https://github.com/Codeception/sample-l4-app/blob/master/tests%2Ffunctional%2F_pages%2FPostsPage.php)
36 | * [authentication](https://github.com/Codeception/sample-l4-app/blob/master/tests%2Ffunctional%2FAuthCest.php) (by user, credentials, http auth)
37 | * usage of session variables
38 | * [routes](https://github.com/Codeception/sample-l4-app/blob/master/tests%2Ffunctional%2FRoutesCest.php)
39 | * creating and checking records in database
40 |
41 | ### CLI Tests
42 |
43 | Demonstrates [testing of Artisan commands](https://github.com/Codeception/sample-l4-app/blob/master/tests%2Fcli%2FGenerateRepositoryCept.php). See [CliHelper](https://github.com/Codeception/sample-l4-app/blob/master/tests/_support/CliHelper.php) to learn how to perform cleanup between tests, and create cutom `runArtisan` command
44 |
45 | ### API Tests
46 |
47 | Demonstrates functional [testing of API](https://github.com/Codeception/sample-l4-app/blob/master/tests%2Fapi%2FPostsResourceCest.php) using REST and Laravel4 modules connected, with
48 |
49 | * partial json inclusion in response
50 | * GET/POST/PUT/DELETE requests
51 | * check changes inside database
52 |
--------------------------------------------------------------------------------
/app/commands/GenerateRepository.php:
--------------------------------------------------------------------------------
1 | model = \$model;
24 | }
25 |
26 | /**
27 | * Fetch a record by id
28 | *
29 | * @param \$id
30 | * @return mixed
31 | */
32 | public function getById(\$id)
33 | {
34 | return \$this->model->find(\$id);
35 | }
36 | }
37 | EOF;
38 |
39 |
40 | /**
41 | * The console command name.
42 | *
43 | * @var string
44 | */
45 | protected $name = 'generate:repository';
46 |
47 | /**
48 | * The console command description.
49 | *
50 | * @var string
51 | */
52 | protected $description = 'Creates empty repository.';
53 |
54 | /**
55 | * Create a new command instance.
56 | *
57 | * @return void
58 | */
59 | public function __construct()
60 | {
61 | parent::__construct();
62 | }
63 |
64 | /**
65 | * Execute the console command.
66 | *
67 | * @return mixed
68 | */
69 | public function fire()
70 | {
71 | $name = ucfirst($this->argument('name'));
72 | @mkdir('app/repositories',0755, true);
73 | $file = str_replace('{{name}}',$name, $this->template);
74 | file_put_contents($filename = "app/repositories/{$name}Repository.php", $file);
75 | $this->info("Repository $name generated in $filename");
76 | }
77 |
78 | /**
79 | * Get the console command arguments.
80 | *
81 | * @return array
82 | */
83 | protected function getArguments()
84 | {
85 | return array(
86 | array('name', InputArgument::REQUIRED, 'repository name.'),
87 | );
88 | }
89 |
90 | /**
91 | * Get the console command options.
92 | *
93 | * @return array
94 | */
95 | protected function getOptions()
96 | {
97 | return array(
98 | array('path', null, InputOption::VALUE_OPTIONAL, 'Path to Laravel app.', null),
99 | );
100 | }
101 |
102 | }
103 |
--------------------------------------------------------------------------------
/app/controllers/Api/PostsController.php:
--------------------------------------------------------------------------------
1 | post = $post;
25 | }
26 |
27 | /**
28 | * Display a listing of the resource.
29 | *
30 | * @return Response
31 | */
32 | public function index()
33 | {
34 | return Response::json($this->post->all());
35 | }
36 |
37 | /**
38 | * Store a newly created resource in storage.
39 | *
40 | * @return Response
41 | */
42 | public function store()
43 | {
44 | $input = Request::only('title','body');
45 | $validation = Validator::make($input, Post::$rules);
46 |
47 | if ($validation->passes()) {
48 | $post = $this->post->create($input);
49 | return $post;
50 | }
51 |
52 | return Response::json(['errors' => $validation->errors()->toArray()], 412);
53 | }
54 |
55 | /**
56 | * Display the specified resource.
57 | *
58 | * @param int $id
59 | * @return Response
60 | */
61 | public function show($id)
62 | {
63 | return $this->post->findOrFail($id);
64 | }
65 |
66 | /**
67 | * Update the specified resource in storage.
68 | *
69 | * @param int $id
70 | * @return Response
71 | */
72 | public function update($id)
73 | {
74 | $input = array_filter(
75 | Request::only('title','body'),
76 | function($value) {
77 | return ! is_null($value);
78 | }
79 | );
80 |
81 | if (! empty($input)) {
82 | $post = $this->post->find($id);
83 | $post->update($input);
84 |
85 | return $post;
86 | }
87 |
88 | return Response::json([], 412);
89 | }
90 |
91 | /**
92 | * Remove the specified resource from storage.
93 | *
94 | * @param int $id
95 | * @return Response
96 | */
97 | public function destroy($id)
98 | {
99 | $this->post->find($id)->delete();
100 | }
101 |
102 | }
103 |
--------------------------------------------------------------------------------
/app/filters.php:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
Login
9 |
10 | @if (count($errors) > 0)
11 |
12 |
Whoops! There were some problems with your input.
13 |
14 | @foreach ($errors->all() as $error)
15 | - {{ $error }}
16 | @endforeach
17 |
18 |
19 | @endif
20 |
21 |
46 |
47 |
48 |
49 |
50 |
51 | @endsection
--------------------------------------------------------------------------------
/bootstrap/start.php:
--------------------------------------------------------------------------------
1 | detectEnvironment(array(
28 |
29 | 'local' => array('your-machine-name'),
30 |
31 | ));
32 |
33 | /*
34 | |--------------------------------------------------------------------------
35 | | Bind Paths
36 | |--------------------------------------------------------------------------
37 | |
38 | | Here we are binding the paths configured in paths.php to the app. You
39 | | should not be changing these here. If you need to change these you
40 | | may do so within the paths.php file and they will be bound here.
41 | |
42 | */
43 |
44 | $app->bindInstallPaths(require __DIR__.'/paths.php');
45 |
46 | /*
47 | |--------------------------------------------------------------------------
48 | | Load The Application
49 | |--------------------------------------------------------------------------
50 | |
51 | | Here we will load the Illuminate application. We'll keep this is in a
52 | | separate location so we can isolate the creation of an application
53 | | from the actual running of the application with a given request.
54 | |
55 | */
56 |
57 | $framework = $app['path.base'].'/vendor/laravel/framework/src';
58 |
59 | require $framework.'/Illuminate/Foundation/start.php';
60 |
61 | /*
62 | |--------------------------------------------------------------------------
63 | | Return The Application
64 | |--------------------------------------------------------------------------
65 | |
66 | | This script returns the application instance. The instance is given to
67 | | the calling script so we can separate the building of the instances
68 | | from the actual running of the application and sending responses.
69 | |
70 | */
71 |
72 | return $app;
73 |
--------------------------------------------------------------------------------
/artisan:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env php
2 | boot();
33 |
34 | /*
35 | |--------------------------------------------------------------------------
36 | | Load The Artisan Console Application
37 | |--------------------------------------------------------------------------
38 | |
39 | | We'll need to run the script to load and return the Artisan console
40 | | application. We keep this in its own script so that we will load
41 | | the console application independent of running commands which
42 | | will allow us to fire commands from Routes when we want to.
43 | |
44 | */
45 |
46 | $artisan = Illuminate\Console\Application::start($app);
47 |
48 | /*
49 | |--------------------------------------------------------------------------
50 | | Run The Artisan Application
51 | |--------------------------------------------------------------------------
52 | |
53 | | When we run the console application, the current CLI command will be
54 | | executed in this console and the response sent back to a terminal
55 | | or another output device for the developers. Here goes nothing!
56 | |
57 | */
58 |
59 | $status = $artisan->run();
60 |
61 | /*
62 | |--------------------------------------------------------------------------
63 | | Shutdown The Application
64 | |--------------------------------------------------------------------------
65 | |
66 | | Once Artisan has finished running. We will fire off the shutdown events
67 | | so that any final work may be done by the application before we shut
68 | | down the process. This is the last thing to happen to the request.
69 | |
70 | */
71 |
72 | $app->shutdown();
73 |
74 | exit($status);
--------------------------------------------------------------------------------
/app/controllers/AuthController.php:
--------------------------------------------------------------------------------
1 | 'required|email', 'password' => 'required',
18 | ]);
19 |
20 | if ($validator->valid()) {
21 | if (Auth::attempt($credentials)) {
22 | return Redirect::intended('/');
23 | }
24 | }
25 |
26 | return Redirect::to('auth/login')
27 | ->withInput(Request::only('email'))
28 | ->withErrors(['email' => 'Invalid credentials']);
29 | }
30 |
31 | /**
32 | * @return \Illuminate\Http\Response
33 | */
34 | public function getRegister()
35 | {
36 | return View::make('auth.register');
37 | }
38 |
39 | /**
40 | * Handle a registration request for the application.
41 | *
42 | * @return \Illuminate\Http\Response
43 | */
44 | public function postRegister()
45 | {
46 | $validator = $this->getValidator(Request::all());
47 |
48 | if ($validator->fails())
49 | {
50 | return Redirect::to('auth/register')->withErrors($validator);
51 | }
52 |
53 | Auth::login($this->createUser(Request::all()));
54 |
55 | return Redirect::to('/');
56 | }
57 |
58 | /**
59 | * @return \Illuminate\Http\Response
60 | */
61 | public function getLogout()
62 | {
63 | Auth::logout();
64 |
65 | return Redirect::to('/');
66 | }
67 |
68 | /**
69 | * Get a validator for an incoming registration request.
70 | *
71 | * @param array $data
72 | * @return \Illuminate\Validation\Validator
73 | */
74 | protected function getValidator(array $data)
75 | {
76 | return Validator::make($data, [
77 | 'name' => 'required|max:255',
78 | 'email' => 'required|email|max:255|unique:users',
79 | 'password' => 'required|confirmed|min:6',
80 | ]);
81 | }
82 |
83 | /**
84 | * Create a new user instance after a valid registration.
85 | *
86 | * @param array $data
87 | * @return User
88 | */
89 | protected function createUser(array $data)
90 | {
91 | return User::create([
92 | 'name' => $data['name'],
93 | 'email' => $data['email'],
94 | 'password' => Hash::make($data['password']),
95 | ]);
96 | }
97 |
98 | }
99 |
--------------------------------------------------------------------------------
/bootstrap/autoload.php:
--------------------------------------------------------------------------------
1 | haveRecord('posts', $this->getPostAttributes(['title' => 'Game of Thrones']));
11 | $id2 = $I->haveRecord('posts', $this->getPostAttributes(['title' => 'Lord of the Rings']));
12 | $I->sendGET($this->endpoint);
13 | $I->seeResponseCodeIs(200);
14 | $I->seeResponseIsJson();
15 | $I->seeResponseContainsJson(['id' => "$id", 'title' => 'Game of Thrones']);
16 | $I->seeResponseContainsJson(['id' => "$id2", 'title' => 'Lord of the Rings']);
17 | $I->seeResponseContainsJson([['id' => "$id"], ['id' => "$id2"]]);
18 | }
19 |
20 | public function getSinglePost(ApiTester $I)
21 | {
22 | $id = $I->haveRecord('posts', $this->getPostAttributes(['title' => 'Starwars']));
23 | $I->sendGET($this->endpoint."/$id");
24 | $I->seeResponseCodeIs(200);
25 | $I->seeResponseIsJson();
26 | $I->seeResponseContainsJson(['id' => "$id", 'title' => 'Starwars']);
27 | $I->dontSeeResponseContainsJson([['id' => $id]]);
28 | }
29 |
30 | public function createPost(ApiTester $I)
31 | {
32 | $I->sendPOST($this->endpoint, ['title' => 'Game of Rings', 'body' => 'By George Tolkien']);
33 | $I->seeResponseCodeIs(200);
34 | $I->seeResponseIsJson();
35 | $I->seeResponseContainsJson(['title' => 'Game of Rings']);
36 | $id = $I->grabDataFromResponseByJsonPath('$.id')[0];
37 | $I->seeRecord('posts', ['id' => $id, 'title' => 'Game of Rings']);
38 | $I->sendGET($this->endpoint."/$id");
39 | $I->seeResponseCodeIs(200);
40 | $I->seeResponseIsJson();
41 | $I->seeResponseContainsJson(['title' => 'Game of Rings']);
42 | }
43 |
44 | public function updatePost(ApiTester $I)
45 | {
46 | $id = $I->haveRecord('posts', $this->getPostAttributes(['title' => 'Game of Thrones']));
47 | $I->sendPUT($this->endpoint."/$id", ['title' => 'Lord of Thrones']);
48 | $I->seeResponseCodeIs(200);
49 | $I->seeResponseIsJson();
50 | $I->seeResponseContainsJson(['title' => 'Lord of Thrones']);
51 | $I->seeRecord('posts', ['title' => 'Lord of Thrones']);
52 | $I->dontSeeRecord('posts', ['title' => 'Game of Thrones']);
53 | }
54 |
55 | public function deletePost(ApiTester $I)
56 | {
57 | $id = $I->haveRecord('posts', $this->getPostAttributes(['title' => 'Game of Thrones']));
58 | $I->sendDELETE($this->endpoint."/$id");
59 | $I->seeResponseCodeIs(200);
60 | $I->dontSeeRecord('posts', ['id' => $id]);
61 | }
62 |
63 | private function getPostAttributes($attributes = [])
64 | {
65 | return array_merge([
66 | 'title' => 'Hello Universe',
67 | 'body' => 'You are so awesome',
68 | 'created_at' => new DateTime(),
69 | 'updated_at' => new DateTime()
70 | ], $attributes);
71 | }
72 |
73 | }
--------------------------------------------------------------------------------
/app/config/cache.php:
--------------------------------------------------------------------------------
1 | 'file',
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | File Cache Location
23 | |--------------------------------------------------------------------------
24 | |
25 | | When using the "file" cache driver, we need a location where the cache
26 | | files may be stored. A sensible default has been specified, but you
27 | | are free to change it to any other place on disk that you desire.
28 | |
29 | */
30 |
31 | 'path' => storage_path().'/cache',
32 |
33 | /*
34 | |--------------------------------------------------------------------------
35 | | Database Cache Connection
36 | |--------------------------------------------------------------------------
37 | |
38 | | When using the "database" cache driver you may specify the connection
39 | | that should be used to store the cached items. When this option is
40 | | null the default database connection will be utilized for cache.
41 | |
42 | */
43 |
44 | 'connection' => null,
45 |
46 | /*
47 | |--------------------------------------------------------------------------
48 | | Database Cache Table
49 | |--------------------------------------------------------------------------
50 | |
51 | | When using the "database" cache driver we need to know the table that
52 | | should be used to store the cached items. A default table name has
53 | | been provided but you're free to change it however you deem fit.
54 | |
55 | */
56 |
57 | 'table' => 'cache',
58 |
59 | /*
60 | |--------------------------------------------------------------------------
61 | | Memcached Servers
62 | |--------------------------------------------------------------------------
63 | |
64 | | Now you may specify an array of your Memcached servers that should be
65 | | used when utilizing the Memcached cache driver. All of the servers
66 | | should contain a value for "host", "port", and "weight" options.
67 | |
68 | */
69 |
70 | 'memcached' => array(
71 |
72 | array('host' => '127.0.0.1', 'port' => 11211, 'weight' => 100),
73 |
74 | ),
75 |
76 | /*
77 | |--------------------------------------------------------------------------
78 | | Cache Key Prefix
79 | |--------------------------------------------------------------------------
80 | |
81 | | When utilizing a RAM based store such as APC or Memcached, there might
82 | | be other applications utilizing the same cache. So, we'll specify a
83 | | value to get prefixed to all our keys so we can avoid collisions.
84 | |
85 | */
86 |
87 | 'prefix' => 'laravel',
88 |
89 | );
90 |
--------------------------------------------------------------------------------
/app/views/auth/register.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.scaffold')
2 |
3 | @section('main')
4 |
5 |
6 |
7 |
8 |
Register
9 |
10 | @if (count($errors) > 0)
11 |
12 |
Whoops! There were some problems with your input.
13 |
14 | @foreach ($errors->all() as $error)
15 | - {{ $error }}
16 | @endforeach
17 |
18 |
19 | @endif
20 |
21 |
60 |
61 |
62 |
63 |
64 |
65 | @endsection
--------------------------------------------------------------------------------
/app/controllers/PostsController.php:
--------------------------------------------------------------------------------
1 | post = $post;
15 | }
16 |
17 | /**
18 | * Display a listing of the resource.
19 | *
20 | * @return Response
21 | */
22 | public function index()
23 | {
24 | $posts = $this->post->all();
25 |
26 | return View::make('posts.index', compact('posts'));
27 | }
28 |
29 | /**
30 | * Show the form for creating a new resource.
31 | *
32 | * @return Response
33 | */
34 | public function create()
35 | {
36 | return View::make('posts.create');
37 | }
38 |
39 | /**
40 | * Store a newly created resource in storage.
41 | *
42 | * @return Response
43 | */
44 | public function store()
45 | {
46 | $input = Input::only('title','body');
47 | $validation = Validator::make($input, Post::$rules);
48 |
49 | if ($validation->passes())
50 | {
51 | $this->post->create($input);
52 |
53 | return Redirect::route('posts.index');
54 | }
55 |
56 | return Redirect::route('posts.create')
57 | ->withInput()
58 | ->withErrors($validation)
59 | ->with('message', 'There were validation errors.');
60 | }
61 |
62 | /**
63 | * Display the specified resource.
64 | *
65 | * @param int $id
66 | * @return Response
67 | */
68 | public function show($id)
69 | {
70 | $post = $this->post->findOrFail($id);
71 |
72 | return View::make('posts.show', compact('post'));
73 | }
74 |
75 | /**
76 | * Show the form for editing the specified resource.
77 | *
78 | * @param int $id
79 | * @return Response
80 | */
81 | public function edit($id)
82 | {
83 | $post = $this->post->find($id);
84 |
85 | if (is_null($post))
86 | {
87 | return Redirect::route('posts.index');
88 | }
89 |
90 | return View::make('posts.edit', compact('post'));
91 | }
92 |
93 | /**
94 | * Update the specified resource in storage.
95 | *
96 | * @param int $id
97 | * @return Response
98 | */
99 | public function update($id)
100 | {
101 | $input = Input::only('title','body');
102 | $validation = Validator::make($input, Post::$rules);
103 |
104 | if ($validation->passes())
105 | {
106 | $post = $this->post->find($id);
107 | $post->update($input);
108 |
109 | return Redirect::route('posts.show', $id);
110 | }
111 |
112 | return Redirect::route('posts.edit', $id)
113 | ->withInput()
114 | ->withErrors($validation)
115 | ->with('message', 'There were validation errors.');
116 | }
117 |
118 | /**
119 | * Remove the specified resource from storage.
120 | *
121 | * @param int $id
122 | * @return Response
123 | */
124 | public function destroy($id)
125 | {
126 | $this->post->find($id)->delete();
127 |
128 | return Redirect::route('posts.index');
129 | }
130 |
131 | }
--------------------------------------------------------------------------------
/app/config/mail.php:
--------------------------------------------------------------------------------
1 | 'smtp',
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | SMTP Host Address
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may provide the host address of the SMTP server used by your
26 | | applications. A default option is provided that is compatible with
27 | | the Postmark mail service, which will provide reliable delivery.
28 | |
29 | */
30 |
31 | 'host' => 'smtp.mailgun.org',
32 |
33 | /*
34 | |--------------------------------------------------------------------------
35 | | SMTP Host Port
36 | |--------------------------------------------------------------------------
37 | |
38 | | This is the SMTP port used by your application to delivery e-mails to
39 | | users of your application. Like the host we have set this value to
40 | | stay compatible with the Postmark e-mail application by default.
41 | |
42 | */
43 |
44 | 'port' => 587,
45 |
46 | /*
47 | |--------------------------------------------------------------------------
48 | | Global "From" Address
49 | |--------------------------------------------------------------------------
50 | |
51 | | You may wish for all e-mails sent by your application to be sent from
52 | | the same address. Here, you may specify a name and address that is
53 | | used globally for all e-mails that are sent by your application.
54 | |
55 | */
56 |
57 | 'from' => array('address' => null, 'name' => null),
58 |
59 | /*
60 | |--------------------------------------------------------------------------
61 | | E-Mail Encryption Protocol
62 | |--------------------------------------------------------------------------
63 | |
64 | | Here you may specify the encryption protocol that should be used when
65 | | the application send e-mail messages. A sensible default using the
66 | | transport layer security protocol should provide great security.
67 | |
68 | */
69 |
70 | 'encryption' => 'tls',
71 |
72 | /*
73 | |--------------------------------------------------------------------------
74 | | SMTP Server Username
75 | |--------------------------------------------------------------------------
76 | |
77 | | If your SMTP server requires a username for authentication, you should
78 | | set it here. This will get used to authenticate with your server on
79 | | connection. You may also set the "password" value below this one.
80 | |
81 | */
82 |
83 | 'username' => null,
84 |
85 | /*
86 | |--------------------------------------------------------------------------
87 | | SMTP Server Password
88 | |--------------------------------------------------------------------------
89 | |
90 | | Here you may set the password required by your SMTP server to send out
91 | | messages from your application. This will be given to the server on
92 | | connection so that the application will be able to send messages.
93 | |
94 | */
95 |
96 | 'password' => null,
97 |
98 | );
99 |
--------------------------------------------------------------------------------
/app/config/database.php:
--------------------------------------------------------------------------------
1 | PDO::FETCH_CLASS,
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Default Database Connection Name
21 | |--------------------------------------------------------------------------
22 | |
23 | | Here you may specify which of the database connections below you wish
24 | | to use as your default connection for all database work. Of course
25 | | you may use many connections at once using the Database library.
26 | |
27 | */
28 |
29 | 'default' => 'sqlite',
30 |
31 | /*
32 | |--------------------------------------------------------------------------
33 | | Database Connections
34 | |--------------------------------------------------------------------------
35 | |
36 | | Here are each of the database connections setup for your application.
37 | | Of course, examples of configuring each database platform that is
38 | | supported by Laravel is shown below to make development simple.
39 | |
40 | |
41 | | All database work in Laravel is done through the PHP PDO facilities
42 | | so make sure you have the driver for your particular database of
43 | | choice installed on your machine before you begin development.
44 | |
45 | */
46 |
47 | 'connections' => array(
48 |
49 | 'sqlite' => array(
50 | 'driver' => 'sqlite',
51 | 'database' => __DIR__.'/../database/database.sqlite',
52 | 'prefix' => '',
53 | ),
54 |
55 | 'mysql' => array(
56 | 'driver' => 'mysql',
57 | 'host' => 'localhost',
58 | 'database' => 'l4-module',
59 | 'username' => 'root',
60 | 'password' => '',
61 | 'charset' => 'utf8',
62 | 'collation' => 'utf8_unicode_ci',
63 | 'prefix' => '',
64 | ),
65 |
66 | 'pgsql' => array(
67 | 'driver' => 'pgsql',
68 | 'host' => 'localhost',
69 | 'database' => 'database',
70 | 'username' => 'root',
71 | 'password' => '',
72 | 'charset' => 'utf8',
73 | 'prefix' => '',
74 | 'schema' => 'public',
75 | ),
76 |
77 | 'sqlsrv' => array(
78 | 'driver' => 'sqlsrv',
79 | 'host' => 'localhost',
80 | 'database' => 'database',
81 | 'username' => 'root',
82 | 'password' => '',
83 | 'prefix' => '',
84 | ),
85 |
86 | ),
87 |
88 | /*
89 | |--------------------------------------------------------------------------
90 | | Migration Repository Table
91 | |--------------------------------------------------------------------------
92 | |
93 | | This table keeps track of all the migrations that have already run for
94 | | your application. Using this information, we can determine which of
95 | | the migrations on disk have not actually be run in the databases.
96 | |
97 | */
98 |
99 | 'migrations' => 'migrations',
100 |
101 | /*
102 | |--------------------------------------------------------------------------
103 | | Redis Databases
104 | |--------------------------------------------------------------------------
105 | |
106 | | Redis is an open source, fast, and advanced key-value store that also
107 | | provides a richer set of commands than a typical key-value systems
108 | | such as APC or Memcached. Laravel makes it easy to dig right in.
109 | |
110 | */
111 |
112 | 'redis' => array(
113 |
114 | 'cluster' => true,
115 |
116 | 'default' => array(
117 | 'host' => '127.0.0.1',
118 | 'port' => 6379,
119 | 'database' => 0,
120 | ),
121 |
122 | ),
123 |
124 | );
125 |
--------------------------------------------------------------------------------
/app/lang/en/validation.php:
--------------------------------------------------------------------------------
1 | "The :attribute must be accepted.",
17 | "active_url" => "The :attribute is not a valid URL.",
18 | "after" => "The :attribute must be a date after :date.",
19 | "alpha" => "The :attribute may only contain letters.",
20 | "alpha_dash" => "The :attribute may only contain letters, numbers, and dashes.",
21 | "alpha_num" => "The :attribute may only contain letters and numbers.",
22 | "before" => "The :attribute must be a date before :date.",
23 | "between" => array(
24 | "numeric" => "The :attribute must be between :min - :max.",
25 | "file" => "The :attribute must be between :min - :max kilobytes.",
26 | "string" => "The :attribute must be between :min - :max characters.",
27 | ),
28 | "confirmed" => "The :attribute confirmation does not match.",
29 | "date" => "The :attribute is not a valid date.",
30 | "date_format" => "The :attribute does not match the format :format.",
31 | "different" => "The :attribute and :other must be different.",
32 | "digits" => "The :attribute must be :digits digits.",
33 | "digits_between" => "The :attribute must be between :min and :max digits.",
34 | "email" => "The :attribute format is invalid.",
35 | "exists" => "The selected :attribute is invalid.",
36 | "image" => "The :attribute must be an image.",
37 | "in" => "The selected :attribute is invalid.",
38 | "integer" => "The :attribute must be an integer.",
39 | "ip" => "The :attribute must be a valid IP address.",
40 | "max" => array(
41 | "numeric" => "The :attribute may not be greater than :max.",
42 | "file" => "The :attribute may not be greater than :max kilobytes.",
43 | "string" => "The :attribute may not be greater than :max characters.",
44 | ),
45 | "mimes" => "The :attribute must be a file of type: :values.",
46 | "min" => array(
47 | "numeric" => "The :attribute must be at least :min.",
48 | "file" => "The :attribute must be at least :min kilobytes.",
49 | "string" => "The :attribute must be at least :min characters.",
50 | ),
51 | "not_in" => "The selected :attribute is invalid.",
52 | "numeric" => "The :attribute must be a number.",
53 | "regex" => "The :attribute format is invalid.",
54 | "required" => "The :attribute field is required.",
55 | "required_if" => "The :attribute field is required when :other is :value.",
56 | "required_with" => "The :attribute field is required when :values is present.",
57 | "required_without" => "The :attribute field is required when :values is not present.",
58 | "same" => "The :attribute and :other must match.",
59 | "size" => array(
60 | "numeric" => "The :attribute must be :size.",
61 | "file" => "The :attribute must be :size kilobytes.",
62 | "string" => "The :attribute must be :size characters.",
63 | ),
64 | "unique" => "The :attribute has already been taken.",
65 | "url" => "The :attribute format is invalid.",
66 |
67 | /*
68 | |--------------------------------------------------------------------------
69 | | Custom Validation Language Lines
70 | |--------------------------------------------------------------------------
71 | |
72 | | Here you may specify custom validation messages for attributes using the
73 | | convention "attribute.rule" to name the lines. This makes it quick to
74 | | specify a specific custom language line for a given attribute rule.
75 | |
76 | */
77 |
78 | 'custom' => array(),
79 |
80 | /*
81 | |--------------------------------------------------------------------------
82 | | Custom Validation Attributes
83 | |--------------------------------------------------------------------------
84 | |
85 | | The following language lines are used to swap attribute place-holders
86 | | with something more reader friendly such as E-Mail Address instead
87 | | of "email". This simply helps us make messages a little cleaner.
88 | |
89 | */
90 |
91 | 'attributes' => array(),
92 |
93 | );
94 |
--------------------------------------------------------------------------------
/app/config/session.php:
--------------------------------------------------------------------------------
1 | 'native',
20 |
21 | /*
22 | |--------------------------------------------------------------------------
23 | | Session Lifetime
24 | |--------------------------------------------------------------------------
25 | |
26 | | Here you may specify the number of minutes that you wish the session
27 | | to be allowed to remain idle for it is expired. If you want them
28 | | to immediately expire when the browser closes, set it to zero.
29 | |
30 | */
31 |
32 | 'lifetime' => 120,
33 |
34 | /*
35 | |--------------------------------------------------------------------------
36 | | Session File Location
37 | |--------------------------------------------------------------------------
38 | |
39 | | When using the native session driver, we need a location where session
40 | | files may be stored. A default has been set for you but a different
41 | | location may be specified. This is only needed for file sessions.
42 | |
43 | */
44 |
45 | 'files' => storage_path().'/sessions',
46 |
47 | /*
48 | |--------------------------------------------------------------------------
49 | | Session Database Connection
50 | |--------------------------------------------------------------------------
51 | |
52 | | When using the "database" session driver, you may specify the database
53 | | connection that should be used to manage your sessions. This should
54 | | correspond to a connection in your "database" configuration file.
55 | |
56 | */
57 |
58 | 'connection' => null,
59 |
60 | /*
61 | |--------------------------------------------------------------------------
62 | | Session Database Table
63 | |--------------------------------------------------------------------------
64 | |
65 | | When using the "database" session driver, you may specify the table we
66 | | should use to manage the sessions. Of course, a sensible default is
67 | | provided for you; however, you are free to change this as needed.
68 | |
69 | */
70 |
71 | 'table' => 'sessions',
72 |
73 | /*
74 | |--------------------------------------------------------------------------
75 | | Session Sweeping Lottery
76 | |--------------------------------------------------------------------------
77 | |
78 | | Some session drivers must manually sweep their storage location to get
79 | | rid of old sessions from storage. Here are the chances that it will
80 | | happen on a given request. By default, the odds are 2 out of 100.
81 | |
82 | */
83 |
84 | 'lottery' => array(2, 100),
85 |
86 | /*
87 | |--------------------------------------------------------------------------
88 | | Session Cookie Name
89 | |--------------------------------------------------------------------------
90 | |
91 | | Here you may change the name of the cookie used to identify a session
92 | | instance by ID. The name specified here will get used every time a
93 | | new session cookie is created by the framework for every driver.
94 | |
95 | */
96 |
97 | 'cookie' => 'laravel_session',
98 |
99 | /*
100 | |--------------------------------------------------------------------------
101 | | Session Cookie Path
102 | |--------------------------------------------------------------------------
103 | |
104 | | The session cookie path determines the path for which the cookie will
105 | | be regarded as available. Typically, this will be the root path of
106 | | your application but you are free to change this when necessary.
107 | |
108 | */
109 |
110 | 'path' => '/',
111 |
112 | /*
113 | |--------------------------------------------------------------------------
114 | | Session Cookie Domain
115 | |--------------------------------------------------------------------------
116 | |
117 | | Here you may change the domain of the cookie used to identify a session
118 | | in your application. This will determine which domains the cookie is
119 | | available to in your application. A sensible default has been set.
120 | |
121 | */
122 |
123 | 'domain' => null,
124 |
125 | /*
126 | |--------------------------------------------------------------------------
127 | | Session Payload Cookie Name
128 | |--------------------------------------------------------------------------
129 | |
130 | | When using the "cookie" session driver, you may configure the name of
131 | | the cookie used as the session "payload". This cookie actually has
132 | | the encrypted session data stored within it for the application.
133 | |
134 | */
135 |
136 | 'payload' => 'laravel_payload',
137 |
138 | 'expire_on_close' => false
139 |
140 | );
141 |
--------------------------------------------------------------------------------
/app/config/app.php:
--------------------------------------------------------------------------------
1 | true,
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Application URL
21 | |--------------------------------------------------------------------------
22 | |
23 | | This URL is used by the console to properly generate URLs when using
24 | | the Artisan command line tool. You should set this to the root of
25 | | your application so that it is used when running Artisan tasks.
26 | |
27 | */
28 |
29 | 'url' => 'http://localhost',
30 |
31 | /*
32 | |--------------------------------------------------------------------------
33 | | Application Timezone
34 | |--------------------------------------------------------------------------
35 | |
36 | | Here you may specify the default timezone for your application, which
37 | | will be used by the PHP date and date-time functions. We have gone
38 | | ahead and set this to a sensible default for you out of the box.
39 | |
40 | */
41 |
42 | 'timezone' => 'UTC',
43 |
44 | /*
45 | |--------------------------------------------------------------------------
46 | | Application Locale Configuration
47 | |--------------------------------------------------------------------------
48 | |
49 | | The application locale determines the default locale that will be used
50 | | by the translation service provider. You are free to set this value
51 | | to any of the locales which will be supported by the application.
52 | |
53 | */
54 |
55 | 'locale' => 'en',
56 |
57 | /*
58 | |--------------------------------------------------------------------------
59 | | Encryption Key
60 | |--------------------------------------------------------------------------
61 | |
62 | | This key is used by the Illuminate encrypter service and should be set
63 | | to a random, long string, otherwise these encrypted values will not
64 | | be safe. Make sure to change it before deploying any application!
65 | |
66 | */
67 |
68 | 'key' => 'YourSecretKey!!!',
69 |
70 | /*
71 | |--------------------------------------------------------------------------
72 | | Autoloaded Service Providers
73 | |--------------------------------------------------------------------------
74 | |
75 | | The service providers listed here will be automatically loaded on the
76 | | request to your application. Feel free to add your own services to
77 | | this array to grant expanded functionality to your applications.
78 | |
79 | */
80 |
81 | 'providers' => array(
82 |
83 | 'Illuminate\Foundation\Providers\ArtisanServiceProvider',
84 | 'Illuminate\Auth\AuthServiceProvider',
85 | 'Illuminate\Cache\CacheServiceProvider',
86 | 'Illuminate\Foundation\Providers\CommandCreatorServiceProvider',
87 | 'Illuminate\Session\CommandsServiceProvider',
88 | 'Illuminate\Foundation\Providers\ComposerServiceProvider',
89 | 'Illuminate\Routing\ControllerServiceProvider',
90 | 'Illuminate\Cookie\CookieServiceProvider',
91 | 'Illuminate\Database\DatabaseServiceProvider',
92 | 'Illuminate\Encryption\EncryptionServiceProvider',
93 | 'Illuminate\Filesystem\FilesystemServiceProvider',
94 | 'Illuminate\Hashing\HashServiceProvider',
95 | 'Illuminate\Html\HtmlServiceProvider',
96 | 'Illuminate\Foundation\Providers\KeyGeneratorServiceProvider',
97 | 'Illuminate\Log\LogServiceProvider',
98 | 'Illuminate\Mail\MailServiceProvider',
99 | 'Illuminate\Foundation\Providers\MaintenanceServiceProvider',
100 | 'Illuminate\Database\MigrationServiceProvider',
101 | 'Illuminate\Foundation\Providers\OptimizeServiceProvider',
102 | 'Illuminate\Pagination\PaginationServiceProvider',
103 | 'Illuminate\Foundation\Providers\PublisherServiceProvider',
104 | 'Illuminate\Queue\QueueServiceProvider',
105 | 'Illuminate\Redis\RedisServiceProvider',
106 | 'Illuminate\Auth\Reminders\ReminderServiceProvider',
107 | 'Illuminate\Foundation\Providers\RouteListServiceProvider',
108 | 'Illuminate\Database\SeedServiceProvider',
109 | 'Illuminate\Foundation\Providers\ServerServiceProvider',
110 | 'Illuminate\Session\SessionServiceProvider',
111 | 'Illuminate\Foundation\Providers\TinkerServiceProvider',
112 | 'Illuminate\Translation\TranslationServiceProvider',
113 | 'Illuminate\Validation\ValidationServiceProvider',
114 | 'Illuminate\View\ViewServiceProvider',
115 | 'Illuminate\Workbench\WorkbenchServiceProvider',
116 |
117 | ),
118 |
119 | /*
120 | |--------------------------------------------------------------------------
121 | | Service Provider Manifest
122 | |--------------------------------------------------------------------------
123 | |
124 | | The service provider manifest is used by Laravel to lazy load service
125 | | providers which are not needed for each request, as well to keep a
126 | | list of all of the services. Here, you may set its storage spot.
127 | |
128 | */
129 |
130 | 'manifest' => storage_path().'/meta',
131 |
132 | /*
133 | |--------------------------------------------------------------------------
134 | | Class Aliases
135 | |--------------------------------------------------------------------------
136 | |
137 | | This array of class aliases will be registered when this application
138 | | is started. However, feel free to register as many as you wish as
139 | | the aliases are "lazy" loaded so they don't hinder performance.
140 | |
141 | */
142 |
143 | 'aliases' => array(
144 |
145 | 'App' => 'Illuminate\Support\Facades\App',
146 | 'Artisan' => 'Illuminate\Support\Facades\Artisan',
147 | 'Auth' => 'Illuminate\Support\Facades\Auth',
148 | 'Blade' => 'Illuminate\Support\Facades\Blade',
149 | 'Cache' => 'Illuminate\Support\Facades\Cache',
150 | 'ClassLoader' => 'Illuminate\Support\ClassLoader',
151 | 'Config' => 'Illuminate\Support\Facades\Config',
152 | 'Controller' => 'Illuminate\Routing\Controllers\Controller',
153 | 'Cookie' => 'Illuminate\Support\Facades\Cookie',
154 | 'Crypt' => 'Illuminate\Support\Facades\Crypt',
155 | 'DB' => 'Illuminate\Support\Facades\DB',
156 | 'Eloquent' => 'Illuminate\Database\Eloquent\Model',
157 | 'Event' => 'Illuminate\Support\Facades\Event',
158 | 'File' => 'Illuminate\Support\Facades\File',
159 | 'Form' => 'Illuminate\Support\Facades\Form',
160 | 'Hash' => 'Illuminate\Support\Facades\Hash',
161 | 'HTML' => 'Illuminate\Support\Facades\Html',
162 | 'Input' => 'Illuminate\Support\Facades\Input',
163 | 'Lang' => 'Illuminate\Support\Facades\Lang',
164 | 'Log' => 'Illuminate\Support\Facades\Log',
165 | 'Mail' => 'Illuminate\Support\Facades\Mail',
166 | 'Paginator' => 'Illuminate\Support\Facades\Paginator',
167 | 'Password' => 'Illuminate\Support\Facades\Password',
168 | 'Queue' => 'Illuminate\Support\Facades\Queue',
169 | 'Redirect' => 'Illuminate\Support\Facades\Redirect',
170 | 'Redis' => 'Illuminate\Support\Facades\Redis',
171 | 'Request' => 'Illuminate\Support\Facades\Request',
172 | 'Response' => 'Illuminate\Support\Facades\Response',
173 | 'Route' => 'Illuminate\Support\Facades\Route',
174 | 'Schema' => 'Illuminate\Support\Facades\Schema',
175 | 'Seeder' => 'Illuminate\Database\Seeder',
176 | 'Session' => 'Illuminate\Support\Facades\Session',
177 | 'Str' => 'Illuminate\Support\Str',
178 | 'URL' => 'Illuminate\Support\Facades\URL',
179 | 'Validator' => 'Illuminate\Support\Facades\Validator',
180 | 'View' => 'Illuminate\Support\Facades\View',
181 |
182 | ),
183 |
184 | );
185 |
--------------------------------------------------------------------------------
/c3.php:
--------------------------------------------------------------------------------
1 | $value) {
24 | $_SERVER["HTTP_X_CODECEPTION_".strtoupper($key)] = $value;
25 | }
26 | }
27 | }
28 |
29 | if (!array_key_exists('HTTP_X_CODECEPTION_CODECOVERAGE', $_SERVER)) {
30 | return;
31 | }
32 |
33 | if (!function_exists('__c3_error')) {
34 | function __c3_error($message)
35 | {
36 | file_put_contents(C3_CODECOVERAGE_MEDIATE_STORAGE . DIRECTORY_SEPARATOR . 'error.txt', $message);
37 | if (!headers_sent()) {
38 | header('X-Codeception-CodeCoverage-Error: ' . str_replace("\n", ' ', $message), true, 500);
39 | }
40 | setcookie('CODECEPTION_CODECOVERAGE_ERROR', $message);
41 | }
42 | }
43 |
44 | // Autoload Codeception classes
45 | if (!class_exists('\\Codeception\\Codecept')) {
46 | if (stream_resolve_include_path(__DIR__ . '/vendor/autoload.php')) {
47 | require_once __DIR__ . '/vendor/autoload.php';
48 | } elseif (file_exists(__DIR__ . '/codecept.phar')) {
49 | require_once 'phar://'.__DIR__ . '/codecept.phar/autoload.php';
50 | } elseif (stream_resolve_include_path('Codeception/autoload.php')) {
51 | require_once 'Codeception/autoload.php';
52 | } else {
53 | __c3_error('Codeception is not loaded. Please check that either PHAR or Composer or PEAR package can be used');
54 | }
55 | }
56 |
57 | // Load Codeception Config
58 | $config_file = realpath(__DIR__) . DIRECTORY_SEPARATOR . 'codeception.yml';
59 | if (isset($_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE_CONFIG'])) {
60 | $config_file = realpath(__DIR__) . DIRECTORY_SEPARATOR . $_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE_CONFIG'];
61 | }
62 | if (!file_exists($config_file)) {
63 | __c3_error(sprintf("Codeception config file '%s' not found", $config_file));
64 | }
65 | try {
66 | \Codeception\Configuration::config($config_file);
67 | } catch (\Exception $e) {
68 | __c3_error($e->getMessage());
69 | }
70 |
71 | if (!defined('C3_CODECOVERAGE_MEDIATE_STORAGE')) {
72 |
73 | // workaround for 'zend_mm_heap corrupted' problem
74 | gc_disable();
75 |
76 | if ((integer)ini_get('memory_limit') < 384) {
77 | ini_set('memory_limit', '384M');
78 | }
79 |
80 | define('C3_CODECOVERAGE_MEDIATE_STORAGE', Codeception\Configuration::logDir() . 'c3tmp');
81 | define('C3_CODECOVERAGE_PROJECT_ROOT', Codeception\Configuration::projectDir());
82 | define('C3_CODECOVERAGE_TESTNAME', $_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE']);
83 |
84 | function __c3_build_html_report(PHP_CodeCoverage $codeCoverage, $path)
85 | {
86 | $writer = new PHP_CodeCoverage_Report_HTML();
87 | $writer->process($codeCoverage, $path . 'html');
88 |
89 | if (file_exists($path . '.tar')) {
90 | unlink($path . '.tar');
91 | }
92 |
93 | $phar = new PharData($path . '.tar');
94 | $phar->setSignatureAlgorithm(Phar::SHA1);
95 | $files = $phar->buildFromDirectory($path . 'html');
96 | array_map('unlink', $files);
97 |
98 | if (in_array('GZ', Phar::getSupportedCompression())) {
99 | if (file_exists($path . '.tar.gz')) {
100 | unlink($path . '.tar.gz');
101 | }
102 |
103 | $phar->compress(\Phar::GZ);
104 |
105 | // close the file so that we can rename it
106 | unset($phar);
107 |
108 | unlink($path . '.tar');
109 | rename($path . '.tar.gz', $path . '.tar');
110 | }
111 |
112 | return $path . '.tar';
113 | }
114 |
115 | function __c3_build_clover_report(PHP_CodeCoverage $codeCoverage, $path)
116 | {
117 | $writer = new PHP_CodeCoverage_Report_Clover();
118 | $writer->process($codeCoverage, $path . '.clover.xml');
119 |
120 | return $path . '.clover.xml';
121 | }
122 |
123 | function __c3_send_file($filename)
124 | {
125 | if (!headers_sent()) {
126 | readfile($filename);
127 | }
128 |
129 | return __c3_exit();
130 | }
131 |
132 | /**
133 | * @param $filename
134 | * @return null|PHP_CodeCoverage
135 | */
136 | function __c3_factory($filename)
137 | {
138 | $phpCoverage = is_readable($filename)
139 | ? unserialize(file_get_contents($filename))
140 | : new PHP_CodeCoverage();
141 |
142 |
143 | if (isset($_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE_SUITE'])) {
144 | $suite = $_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE_SUITE'];
145 | try {
146 | $settings = \Codeception\Configuration::suiteSettings($suite, \Codeception\Configuration::config());
147 | } catch (Exception $e) {
148 | __c3_error($e->getMessage());
149 | }
150 | } else {
151 | $settings = \Codeception\Configuration::config();
152 | }
153 |
154 | try {
155 | \Codeception\Coverage\Filter::setup($phpCoverage)
156 | ->whiteList($settings)
157 | ->blackList($settings);
158 | } catch (Exception $e) {
159 | __c3_error($e->getMessage());
160 | }
161 |
162 | return $phpCoverage;
163 | }
164 |
165 | function __c3_exit()
166 | {
167 | if (!isset($_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE_DEBUG'])) {
168 | exit;
169 | }
170 | return null;
171 | }
172 |
173 | function __c3_clear()
174 | {
175 | \Codeception\Util\FileSystem::doEmptyDir(C3_CODECOVERAGE_MEDIATE_STORAGE);
176 | }
177 | }
178 |
179 | if (!is_dir(C3_CODECOVERAGE_MEDIATE_STORAGE)) {
180 | if (mkdir(C3_CODECOVERAGE_MEDIATE_STORAGE, 0777, true) === false) {
181 | __c3_error('Failed to create directory "' . C3_CODECOVERAGE_MEDIATE_STORAGE . '"');
182 | }
183 | }
184 |
185 | // evaluate base path for c3-related files
186 | $path = realpath(C3_CODECOVERAGE_MEDIATE_STORAGE) . DIRECTORY_SEPARATOR . 'codecoverage';
187 |
188 | $requested_c3_report = (strpos($_SERVER['REQUEST_URI'], 'c3/report') !== false);
189 |
190 | $complete_report = $current_report = $path . '.serialized';
191 | if ($requested_c3_report) {
192 | set_time_limit(0);
193 |
194 | $route = ltrim(strrchr($_SERVER['REQUEST_URI'], '/'), '/');
195 |
196 | if ($route == 'clear') {
197 | __c3_clear();
198 | return __c3_exit();
199 | }
200 |
201 | $codeCoverage = __c3_factory($complete_report);
202 |
203 | switch ($route) {
204 | case 'html':
205 | try {
206 | __c3_send_file(__c3_build_html_report($codeCoverage, $path));
207 | } catch (Exception $e) {
208 | __c3_error($e->getMessage());
209 | }
210 | return __c3_exit();
211 | case 'clover':
212 | try {
213 | __c3_send_file(__c3_build_clover_report($codeCoverage, $path));
214 | } catch (Exception $e) {
215 | __c3_error($e->getMessage());
216 | }
217 | return __c3_exit();
218 | case 'serialized':
219 | try {
220 | __c3_send_file($complete_report);
221 | } catch (Exception $e) {
222 | __c3_error($e->getMessage());
223 | }
224 | return __c3_exit();
225 | }
226 |
227 | } else {
228 | $codeCoverage = __c3_factory($current_report);
229 | $codeCoverage->start(C3_CODECOVERAGE_TESTNAME);
230 | if (!array_key_exists('HTTP_X_CODECEPTION_CODECOVERAGE_DEBUG', $_SERVER)) {
231 | register_shutdown_function(
232 | function () use ($codeCoverage, $current_report) {
233 | $codeCoverage->stop();
234 | file_put_contents($current_report, serialize($codeCoverage));
235 | }
236 | );
237 | }
238 | }
239 |
240 | // @codeCoverageIgnoreEnd
--------------------------------------------------------------------------------