diff --git a/.idea/workspace.xml b/.idea/workspace.xml index e486aa0..d46e7e7 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,7 +2,8 @@ - + + @@ -27,14 +28,11 @@ - - - - - + + - - + + @@ -53,29 +51,23 @@ @@ -88,9 +80,10 @@ - @@ -108,7 +101,7 @@ - PhpUndefinedClassInspection + PhpUndefinedFieldInspection @@ -186,7 +179,39 @@ + @@ -220,6 +246,9 @@ + + + @@ -228,9 +257,6 @@ - - - @@ -247,7 +273,7 @@ - + @@ -256,20 +282,41 @@ - + + + + + + + + + + + + + + + + + + + + + + - + - - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - - + + - + - - + + - + - + - + - - + + - + - - + + - + - - + + - + + + + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - - + + - + - - + + - + - - + + - - - - + - - + + diff --git a/.travis.yml b/.travis.yml index 3aef69f..5f07028 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,13 +12,14 @@ brnaches: only: - master before_script: - - mysql -e 'create database test;' + - mysql -e 'create database citest;' - cp app/config/testing/database.ci.php app/config/testing/database.php #copy over CI environment configuration | database conv + - cp app/config/database.ci.php app/config/database.php #copy over CI environment configuration | database conv - travis_retry composer self-update - travis_retry composer install --prefer-source --no-interaction --dev - chmod -R 777 app/storage/ - - yes | php artisan migrate - - yes | php artisan db:seed + - php artisan migrate --env=testing --no-interaction -vvv + - php artisan db:seed --env=testing --no-interaction -vvv - php -S localhost:8000 -t public & - sleep 5 # give artisan serve some time to start - vendor/bin/codecept build @@ -26,12 +27,14 @@ before_script: # should I do this to all other suites ? script: - - php vendor/bin/codecept run --report --coverage-xml + - php vendor/bin/codecept run --coverage-xml after_script: - wget https://scrutinizer-ci.com/ocular.phar - php ocular.phar code-coverage:upload --format=php-clover tests/_output/coverage.xml + after_failure: - cat app/storage/logs/laravel.log - - cat tests/_output/* \ No newline at end of file + - cat tests/_output/* + diff --git a/app/config/database.ci.php b/app/config/database.ci.php new file mode 100644 index 0000000..fa95f67 --- /dev/null +++ b/app/config/database.ci.php @@ -0,0 +1,126 @@ + PDO::FETCH_CLASS, + + /* + |-------------------------------------------------------------------------- + | Default Database Connection Name + |-------------------------------------------------------------------------- + | + | Here you may specify which of the database connections below you wish + | to use as your default connection for all database work. Of course + | you may use many connections at once using the Database library. + | + */ + + 'default' => 'mysql', + + /* + |-------------------------------------------------------------------------- + | Database Connections + |-------------------------------------------------------------------------- + | + | Here are each of the database connections setup for your application. + | Of course, examples of configuring each database platform that is + | supported by Laravel is shown below to make development simple. + | + | + | All database work in Laravel is done through the PHP PDO facilities + | so make sure you have the driver for your particular database of + | choice installed on your machine before you begin development. + | + */ + + 'connections' => array( + + 'sqlite' => array( + 'driver' => 'sqlite', + 'database' => __DIR__.'/../database/production.sqlite', + 'prefix' => '', + ), + + 'mysql' => array( + 'driver' => 'mysql', + 'host' => '127.0.0.1', + 'database' => 'citest', + 'username' => 'root', + 'password' => '', + 'charset' => 'utf8', + 'collation' => 'utf8_unicode_ci', + 'prefix' => '', + + ), + + + 'pgsql' => array( + 'driver' => 'pgsql', + 'host' => 'localhost', + 'database' => 'SE3800', + 'username' => 'postgres', + 'password' => 'SeniorDesign15', + 'charset' => 'utf8', + 'prefix' => '', + 'schema' => 'public', + ), + + 'sqlsrv' => array( + 'driver' => 'sqlsrv', + 'host' => 'localhost', + 'database' => 'database', + 'username' => 'root', + 'password' => '', + 'prefix' => '', + ), + + ), + + /* + |-------------------------------------------------------------------------- + | Migration Repository Table + |-------------------------------------------------------------------------- + | + | This table keeps track of all the migrations that have already run for + | your application. Using this information, we can determine which of + | the migrations on disk haven't actually been run in the database. + | + */ + + 'migrations' => 'migrations', + + /* + |-------------------------------------------------------------------------- + | Redis Databases + |-------------------------------------------------------------------------- + | + | Redis is an open source, fast, and advanced key-value store that also + | provides a richer set of commands than a typical key-value systems + | such as APC or Memcached. Laravel makes it easy to dig right in. + | + */ + + 'redis' => array( + + 'cluster' => false, + + 'default' => array( + 'host' => '127.0.0.1', + 'port' => 6379, + 'database' => 0, + ), + + ), + +); diff --git a/app/config/testing/database.ci.php b/app/config/testing/database.ci.php index 1a0f517..3853fab 100644 --- a/app/config/testing/database.ci.php +++ b/app/config/testing/database.ci.php @@ -1,54 +1,50 @@ + + array( - - 'mysql' => array( - 'driver' => 'mysql', - 'host' => 'localhost', - 'database' => 'test', - 'username' => 'root', - 'password' => '', - 'charset' => 'utf8', - 'collation' => 'utf8_unicode_ci', - 'prefix' => '', - ), - - 'pgsql' => array( - 'driver' => 'pgsql', - 'host' => 'localhost', - 'database' => 'homestead', - 'username' => 'homestead', - 'password' => 'secret', - 'charset' => 'utf8', - 'prefix' => '', - 'schema' => 'public', - ), - - ), - - ); + +return array( + + /* + |-------------------------------------------------------------------------- + | Database Connections + |-------------------------------------------------------------------------- + | + | Here are each of the database connections setup for your application. + | Of course, examples of configuring each database platform that is + | supported by Laravel is shown below to make development simple. + | + | + | All database work in Laravel is done through the PHP PDO facilities + | so make sure you have the driver for your particular database of + | choice installed on your machine before you begin development. + | + I had to add the port number in there: I got access dened + */ + + 'connections' => array( + + 'mysql' => array( + 'driver' => 'mysql', + 'host' => '127.0.0.1', + 'database' => 'citest', + 'username' => 'root', + 'password' => '', + 'charset' => 'utf8', + 'collation' => 'utf8_unicode_ci', + 'prefix' => '', + ), + + 'pgsql' => array( + 'driver' => 'pgsql', + 'host' => 'localhost', + 'database' => 'homestead', + 'username' => 'homestead', + 'password' => 'secret', + 'charset' => 'utf8', + 'prefix' => '', + 'schema' => 'public', + ), + + ), + +); \ No newline at end of file diff --git a/app/controllers/HomeController.php b/app/controllers/HomeController.php index ddce2e6..46cfae9 100644 --- a/app/controllers/HomeController.php +++ b/app/controllers/HomeController.php @@ -22,16 +22,42 @@ public function showWelcome() { return View::make('hello'); } + public function showRegistrar() + { + return View::make('/registrar'); + } + + public function register(){ + + + $validator = User::getValidator(Input::all()); + + if($validator->fails()){ + return Redirect::to('registrar')->withErrors($validator) + ->withInput(Input::except('password','password_confirm')); + }else{ + + $user = new User; + $user->first_name = Input::get('first_name'); + $user->last_name = Input::get('last_name'); + $user->username = Input::get('username'); + $user->email = Input::get('email'); + $user->password = Hash::make(Input::get('password')); + + $user->save(); + return View::make('conformation'); + } + + } public function login() { // setup the reules $rules = array( - 'username' => 'required', + 'username'=> 'required', 'password' => 'required', ); - $validator = Validator::make(Input::all(),$rules); if($validator->fails()){// case failure @@ -44,7 +70,6 @@ public function login() { 'password' => Input::get('password') ); -// dd(DB::connection('pgsql')); if (Auth::attempt($userdata)) { return View::make('mainPage'); diff --git a/app/database/migrations/2015_01_21_210343_create_users_table.php b/app/database/migrations/2015_01_21_210343_create_users_table.php index ffbdb8e..3bcdb4e 100644 --- a/app/database/migrations/2015_01_21_210343_create_users_table.php +++ b/app/database/migrations/2015_01_21_210343_create_users_table.php @@ -19,8 +19,10 @@ public function up() $table->string('last_name'); $table->string('username'); $table->string('password'); - $table->string('email')->unique;}); - } + $table->string('email')->unique; + $table->string('remember_token',100);}); + + } /** * Reverse the migrations. * diff --git a/app/database/seeds/UserTableSeeder.php b/app/database/seeds/UserTableSeeder.php index 223c035..7c480f1 100644 --- a/app/database/seeds/UserTableSeeder.php +++ b/app/database/seeds/UserTableSeeder.php @@ -15,7 +15,6 @@ public function run() 'last_name' => 'Almatrudi', 'email' => 'almatrudia@msoe.edu', 'password' => Hash::make('password') - )); } diff --git a/app/lang/en/validation.php b/app/lang/en/validation.php index 648516e..32e58dc 100644 --- a/app/lang/en/validation.php +++ b/app/lang/en/validation.php @@ -103,4 +103,5 @@ 'attributes' => array(), + ); diff --git a/app/models/User.php b/app/models/User.php index 6984c0a..beb0aab 100644 --- a/app/models/User.php +++ b/app/models/User.php @@ -28,6 +28,61 @@ class User extends Eloquent implements UserInterface, RemindableInterface { * my work based on the example */ + protected $fillable = array('first_name','last_name','username','password', 'email'); + + public static $rules = array( + 'first_name' => 'required', + 'last_name' => 'required', + 'username' => 'required|min:6|unique:users', + 'email' => 'required|email|unique:users', + 'password' => 'required|min:5|max:30|has:upper,lower,num', + 'password_confirm' => 'required|same:password' + ); + +public static $messages = array('password.has' => 'The password must have lower and upper letter and number.'); + + public static function getValidator($input){ + + Validator::extend('has', function($attr, $value, $params) { + + if (!count($params)) { + throw new \InvalidArgumentException('The has validation rule expects at least one parameter, 0 given.'); + } + + foreach ($params as $param) { + switch ($param) { + case 'num': + $regex = '/\pN/'; + break; + case 'letter': + $regex = '/\pL/'; + break; + case 'lower': + $regex = '/\p{Ll}/'; + break; + case 'upper': + $regex = '/\p{Lu}/'; + break; + case 'special': + $regex = '/[\pP\pS]/'; + break; + default: + $regex = $param; + } + + if (! preg_match($regex, $value)) { + return false; + } + } + + return true; + }); + + $validator = Validator::make($input, User::$rules,User::$messages); + + return $validator; + } + } diff --git a/app/routes.php b/app/routes.php index 95bd7f3..2604709 100644 --- a/app/routes.php +++ b/app/routes.php @@ -14,8 +14,18 @@ Route::get('login', array('uses'=>'HomeController@showWelcome')); Route::post('login', array('uses'=>'HomeController@login')); +Route::get('/registrar', array('uses'=>'HomeController@showRegistrar')); +Route::post('/registrar', array('uses'=>'HomeController@register')); + + // static page Route::get('about',function(){ return View::make('about'); -} -); +}); +Route::get('registrar',function(){ + return View::make('registrar'); +}); + +Route::get('',function(){ + return Redirect::to('login'); +}); \ No newline at end of file diff --git a/app/views/Conformation.blade.php b/app/views/Conformation.blade.php new file mode 100644 index 0000000..0f57133 --- /dev/null +++ b/app/views/Conformation.blade.php @@ -0,0 +1,16 @@ + + + + Registration Completed + + + + + + + + +

I saved you to Database

+ \ No newline at end of file diff --git a/app/views/hello.blade.php b/app/views/hello.blade.php index 1a3c2c1..b84df90 100644 --- a/app/views/hello.blade.php +++ b/app/views/hello.blade.php @@ -35,11 +35,13 @@ - +

- +
+ +
diff --git a/app/views/registrar.blade.php b/app/views/registrar.blade.php new file mode 100644 index 0000000..7b3bc2c --- /dev/null +++ b/app/views/registrar.blade.php @@ -0,0 +1,89 @@ + + + + + Registration Form! + + + + + + + + +
+
+ + + + @if ($errors->has()) +
+ @foreach ($errors->all() as $error) + {{ $error }}
+ @endforeach +
+ @endif + + + + +
+ +
+ + + @if ($errors->has('first_name'))

{{ $errors->first('first_name') }}

@endif + +
+ +
+ + + @if ($errors->has('last_name'))

{{ $errors->first('last_name') }}

@endif +
+ +
+ + + @if ($errors->has('username'))

{{ $errors->first('username') }}

@endif + +
+ +
+ + + @if ($errors->has('email'))

{{ $errors->first('email') }}

@endif + +
+ +
+ + + @if ($errors->has('password'))

{{ $errors->first('password') }}

@endif + +
+ +
+ + + @if ($errors->has('password_confirm'))

{{ $errors->first('password_confirm') }}

@endif + +
+ + + +
+ +
+
+ + + \ No newline at end of file diff --git a/readme.md b/readme.md index 26c8689..173772d 100644 --- a/readme.md +++ b/readme.md @@ -1,28 +1,4 @@ -## Laravel PHP Framework - -[![Build Status](https://travis-ci.org/laravel/framework.svg)](https://travis-ci.org/laravel/framework) -[![Total Downloads](https://poser.pugx.org/laravel/framework/downloads.svg)](https://packagist.org/packages/laravel/framework) -[![Latest Stable Version](https://poser.pugx.org/laravel/framework/v/stable.svg)](https://packagist.org/packages/laravel/framework) -[![Latest Unstable Version](https://poser.pugx.org/laravel/framework/v/unstable.svg)](https://packagist.org/packages/laravel/framework) -[![License](https://poser.pugx.org/laravel/framework/license.svg)](https://packagist.org/packages/laravel/framework) - -Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable, creative experience to be truly fulfilling. Laravel attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as authentication, routing, sessions, and caching. - -Laravel aims to make the development process a pleasing one for the developer without sacrificing application functionality. Happy developers make the best code. To this end, we've attempted to combine the very best of what we have seen in other web frameworks, including frameworks implemented in other languages, such as Ruby on Rails, ASP.NET MVC, and Sinatra. - -Laravel is accessible, yet powerful, providing powerful tools needed for large, robust applications. A superb inversion of control container, expressive migration system, and tightly integrated unit testing support give you the tools you need to build any application with which you are tasked. - -## Official Documentation - -Documentation for the entire framework can be found on the [Laravel website](http://laravel.com/docs). - -### Contributing To Laravel - -**All issues and pull requests should be filed on the [laravel/framework](http://github.com/laravel/framework) repository.** - -### License - -The Laravel framework is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT) [![Build Status](https://travis-ci.org/Alamink/laravel.svg?branch=master)](https://travis-ci.org/Alamink/laravel) -[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/Alamink/laravel/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/Alamink/laravel/?branch=master) \ No newline at end of file +[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/Alamink/laravel/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/Alamink/laravel/?branch=master) +[![Code Coverage](https://scrutinizer-ci.com/g/Alamink/laravel/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/Alamink/laravel/?branch=master) \ No newline at end of file diff --git a/tests/acceptance.suite.yml b/tests/acceptance.suite.yml index 9c0ffc0..7bf3f3e 100644 --- a/tests/acceptance.suite.yml +++ b/tests/acceptance.suite.yml @@ -6,9 +6,11 @@ class_name: AcceptanceTester modules: + enabled: - PhpBrowser - AcceptanceHelper + - Laravel4 config: PhpBrowser: url: 'http://laravel.local:8000' diff --git a/tests/acceptance/AcceptanceTester.php b/tests/acceptance/AcceptanceTester.php index c9df97a..ab81fa5 100644 --- a/tests/acceptance/AcceptanceTester.php +++ b/tests/acceptance/AcceptanceTester.php @@ -1,4 +1,4 @@ -scenario->runStep(new \Codeception\Step\Condition('amHttpAuthenticated', func_get_args())); @@ -66,7 +67,7 @@ public function amHttpAuthenticated($username, $password) { * ``` * * @param $page - * @see \Codeception\Module\PhpBrowser::amOnPage() + * @see \Codeception\Lib\InnerBrowser::amOnPage() */ public function amOnPage($page) { return $this->scenario->runStep(new \Codeception\Step\Condition('amOnPage', func_get_args())); @@ -1117,6 +1118,7 @@ public function grabValueFrom($field) { * [!] Method is generated. Documentation taken from corresponding module. * * Sets a cookie with the given name and value. + * You can set additional cookie params like `domain`, `path`, `expire`, `secure` in array passed as last argument. * * ``` php * * ``` * - * @param $cookie - * @param $value + * @param $name + * @param $val + * @param array $params + * @internal param $cookie + * @internal param $value * * @return mixed * @see \Codeception\Lib\InnerBrowser::setCookie() */ - public function setCookie($name, $val) { + public function setCookie($name, $val, $params = null) { return $this->scenario->runStep(new \Codeception\Step\Action('setCookie', func_get_args())); } @@ -1139,13 +1144,15 @@ public function setCookie($name, $val) { * [!] Method is generated. Documentation taken from corresponding module. * * Grabs a cookie value. + * You can set additional cookie params like `domain`, `path` in array passed as last argument. * * @param $cookie * + * @param array $params * @return mixed * @see \Codeception\Lib\InnerBrowser::grabCookie() */ - public function grabCookie($name) { + public function grabCookie($name, $params = null) { return $this->scenario->runStep(new \Codeception\Step\Action('grabCookie', func_get_args())); } @@ -1154,6 +1161,7 @@ public function grabCookie($name) { * [!] Method is generated. Documentation taken from corresponding module. * * Checks that a cookie with the given name is set. + * You can set additional cookie params like `domain`, `path` as array passed in last argument. * * ``` php * scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeCookie', func_get_args())); } /** * [!] Method is generated. Documentation taken from corresponding module. * * Checks that a cookie with the given name is set. + * You can set additional cookie params like `domain`, `path` as array passed in last argument. * * ``` php * scenario->runStep(new \Codeception\Step\Assertion('seeCookie', func_get_args())); } @@ -1195,27 +1204,31 @@ public function seeCookie($name) { * [!] Method is generated. Documentation taken from corresponding module. * * Checks that there isn't a cookie with the given name. + * You can set additional cookie params like `domain`, `path` as array passed in last argument. * * @param $cookie * + * @param array $params * @return mixed * Conditional Assertion: Test won't be stopped on fail * @see \Codeception\Lib\InnerBrowser::dontSeeCookie() */ - public function cantSeeCookie($name) { + public function cantSeeCookie($name, $params = null) { return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCookie', func_get_args())); } /** * [!] Method is generated. Documentation taken from corresponding module. * * Checks that there isn't a cookie with the given name. + * You can set additional cookie params like `domain`, `path` as array passed in last argument. * * @param $cookie * + * @param array $params * @return mixed * @see \Codeception\Lib\InnerBrowser::dontSeeCookie() */ - public function dontSeeCookie($name) { + public function dontSeeCookie($name, $params = null) { return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeCookie', func_get_args())); } @@ -1224,13 +1237,15 @@ public function dontSeeCookie($name) { * [!] Method is generated. Documentation taken from corresponding module. * * Unsets cookie with the given name. + * You can set additional cookie params like `domain`, `path` in array passed as last argument. * * @param $cookie * + * @param array $params * @return mixed * @see \Codeception\Lib\InnerBrowser::resetCookie() */ - public function resetCookie($name) { + public function resetCookie($name, $params = null) { return $this->scenario->runStep(new \Codeception\Step\Action('resetCookie', func_get_args())); } @@ -1584,4 +1599,488 @@ public function cantSeeInTitle($title) { public function dontSeeInTitle($title) { return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeInTitle', func_get_args())); } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Enable Laravel filters for next requests. + * @see \Codeception\Module\Laravel4::haveEnabledFilters() + */ + public function haveEnabledFilters() { + return $this->scenario->runStep(new \Codeception\Step\Action('haveEnabledFilters', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Disable Laravel filters for next requests. + * @see \Codeception\Module\Laravel4::haveDisabledFilters() + */ + public function haveDisabledFilters() { + return $this->scenario->runStep(new \Codeception\Step\Action('haveDisabledFilters', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Opens web page using route name and parameters. + * + * ```php + * amOnRoute('posts.create'); + * ?> + * ``` + * + * @param $route + * @param array $params + * @see \Codeception\Module\Laravel4::amOnRoute() + */ + public function amOnRoute($route, $params = null) { + return $this->scenario->runStep(new \Codeception\Step\Condition('amOnRoute', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Opens web page by action name + * + * ```php + * amOnAction('PostsController@index'); + * ?> + * ``` + * + * @param $action + * @param array $params + * @see \Codeception\Module\Laravel4::amOnAction() + */ + public function amOnAction($action, $params = null) { + return $this->scenario->runStep(new \Codeception\Step\Condition('amOnAction', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that current url matches route + * + * ```php + * seeCurrentRouteIs('posts.index'); + * ?> + * ``` + * @param $route + * @param array $params + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\Laravel4::seeCurrentRouteIs() + */ + public function canSeeCurrentRouteIs($route, $params = null) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeCurrentRouteIs', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that current url matches route + * + * ```php + * seeCurrentRouteIs('posts.index'); + * ?> + * ``` + * @param $route + * @param array $params + * @see \Codeception\Module\Laravel4::seeCurrentRouteIs() + */ + public function seeCurrentRouteIs($route, $params = null) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('seeCurrentRouteIs', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that current url matches action + * + * ```php + * seeCurrentActionIs('PostsController@index'); + * ?> + * ``` + * + * @param $action + * @param array $params + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\Laravel4::seeCurrentActionIs() + */ + public function canSeeCurrentActionIs($action, $params = null) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeCurrentActionIs', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that current url matches action + * + * ```php + * seeCurrentActionIs('PostsController@index'); + * ?> + * ``` + * + * @param $action + * @param array $params + * @see \Codeception\Module\Laravel4::seeCurrentActionIs() + */ + public function seeCurrentActionIs($action, $params = null) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('seeCurrentActionIs', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Assert that the session has a given list of values. + * + * @param string|array $key + * @param mixed $value + * @return void + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\Laravel4::seeInSession() + */ + public function canSeeInSession($key, $value = null) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeInSession', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Assert that the session has a given list of values. + * + * @param string|array $key + * @param mixed $value + * @return void + * @see \Codeception\Module\Laravel4::seeInSession() + */ + public function seeInSession($key, $value = null) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('seeInSession', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Assert that the session has a given list of values. + * + * @param array $bindings + * @return void + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\Laravel4::seeSessionHasValues() + */ + public function canSeeSessionHasValues($bindings) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeSessionHasValues', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Assert that the session has a given list of values. + * + * @param array $bindings + * @return void + * @see \Codeception\Module\Laravel4::seeSessionHasValues() + */ + public function seeSessionHasValues($bindings) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('seeSessionHasValues', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Assert that Session has error messages + * The seeSessionHasValues cannot be used, as Message bag Object is returned by Laravel4 + * + * Useful for validation messages and generally messages array + * e.g. + * return `Redirect::to('register')->withErrors($validator);` + * + * Example of Usage + * + * ``` php + * seeSessionErrorMessage(array('username'=>'Invalid Username')); + * ?> + * ``` + * @param array $bindings + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\Laravel4::seeSessionErrorMessage() + */ + public function canSeeSessionErrorMessage($bindings) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeSessionErrorMessage', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Assert that Session has error messages + * The seeSessionHasValues cannot be used, as Message bag Object is returned by Laravel4 + * + * Useful for validation messages and generally messages array + * e.g. + * return `Redirect::to('register')->withErrors($validator);` + * + * Example of Usage + * + * ``` php + * seeSessionErrorMessage(array('username'=>'Invalid Username')); + * ?> + * ``` + * @param array $bindings + * @see \Codeception\Module\Laravel4::seeSessionErrorMessage() + */ + public function seeSessionErrorMessage($bindings) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('seeSessionErrorMessage', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Assert that the session has errors bound. + * + * @return bool + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\Laravel4::seeSessionHasErrors() + */ + public function canSeeSessionHasErrors() { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeSessionHasErrors', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Assert that the session has errors bound. + * + * @return bool + * @see \Codeception\Module\Laravel4::seeSessionHasErrors() + */ + public function seeSessionHasErrors() { + return $this->scenario->runStep(new \Codeception\Step\Assertion('seeSessionHasErrors', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Set the currently logged in user for the application. + * Takes either `UserInterface` instance or array of credentials. + * + * @param \Illuminate\Auth\UserInterface|array $user + * @param string $driver + * @return void + * @see \Codeception\Module\Laravel4::amLoggedAs() + */ + public function amLoggedAs($user, $driver = null) { + return $this->scenario->runStep(new \Codeception\Step\Condition('amLoggedAs', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Logs user out + * @see \Codeception\Module\Laravel4::logout() + */ + public function logout() { + return $this->scenario->runStep(new \Codeception\Step\Action('logout', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that user is authenticated + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\Laravel4::seeAuthentication() + */ + public function canSeeAuthentication() { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeAuthentication', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that user is authenticated + * @see \Codeception\Module\Laravel4::seeAuthentication() + */ + public function seeAuthentication() { + return $this->scenario->runStep(new \Codeception\Step\Assertion('seeAuthentication', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Check that user is not authenticated + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\Laravel4::dontSeeAuthentication() + */ + public function cantSeeAuthentication() { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeAuthentication', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Check that user is not authenticated + * @see \Codeception\Module\Laravel4::dontSeeAuthentication() + */ + public function dontSeeAuthentication() { + return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeAuthentication', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Return an instance of a class from the IoC Container. + * (http://laravel.com/docs/ioc) + * + * Example + * ``` php + * grabService('foo'); + * + * // Will return an instance of FooBar, also works for singletons. + * ?> + * ``` + * + * @param string $class + * @return mixed + * @see \Codeception\Module\Laravel4::grabService() + */ + public function grabService($class) { + return $this->scenario->runStep(new \Codeception\Step\Action('grabService', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Inserts record into the database. + * + * ``` php + * haveRecord('users', array('name' => 'Davert')); + * ?> + * ``` + * + * @param $model + * @param array $attributes + * @return mixed + * @see \Codeception\Module\Laravel4::haveRecord() + */ + public function haveRecord($model, $attributes = null) { + return $this->scenario->runStep(new \Codeception\Step\Action('haveRecord', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that record exists in database. + * + * ``` php + * $I->seeRecord('users', array('name' => 'davert')); + * ``` + * + * @param $model + * @param array $attributes + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\Laravel4::seeRecord() + */ + public function canSeeRecord($model, $attributes = null) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeRecord', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that record exists in database. + * + * ``` php + * $I->seeRecord('users', array('name' => 'davert')); + * ``` + * + * @param $model + * @param array $attributes + * @see \Codeception\Module\Laravel4::seeRecord() + */ + public function seeRecord($model, $attributes = null) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('seeRecord', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that record does not exist in database. + * + * ``` php + * dontSeeRecord('users', array('name' => 'davert')); + * ?> + * ``` + * + * @param $model + * @param array $attributes + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\Laravel4::dontSeeRecord() + */ + public function cantSeeRecord($model, $attributes = null) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeRecord', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that record does not exist in database. + * + * ``` php + * dontSeeRecord('users', array('name' => 'davert')); + * ?> + * ``` + * + * @param $model + * @param array $attributes + * @see \Codeception\Module\Laravel4::dontSeeRecord() + */ + public function dontSeeRecord($model, $attributes = null) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeRecord', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Retrieves record from database + * + * ``` php + * grabRecord('users', array('name' => 'davert')); + * ?> + * ``` + * + * @param $model + * @param array $attributes + * @return mixed + * @see \Codeception\Module\Laravel4::grabRecord() + */ + public function grabRecord($model, $attributes = null) { + return $this->scenario->runStep(new \Codeception\Step\Action('grabRecord', func_get_args())); + } } diff --git a/tests/acceptance/WelcomeCest.php b/tests/acceptance/WelcomeCest.php index 397c46a..87c0630 100644 --- a/tests/acceptance/WelcomeCest.php +++ b/tests/acceptance/WelcomeCest.php @@ -5,6 +5,9 @@ class WelcomeCest //black box test public function _before(AcceptanceTester $I) { + Artisan::call('migrate:rollback'); + Artisan::call('migrate'); + Artisan::call('db:seed'); } public function _after(AcceptanceTester $I) @@ -19,20 +22,44 @@ public function testMainPage(AcceptanceTester $I) $I->see('Login with Alamin'); } - public function testAboutPage(AcceptanceTester $I){ + public function testAboutPage(AcceptanceTester $I) + { $I->wantTo('ensure that about page works'); $I->amOnPage('/about'); $I->see('Alamin almatrudi'); } - /* public function testLogin(AcceptanceTester $I){ + public function testLogin(AcceptanceTester $I) + { $I->wantTo('ensure that logs in works and direct me to main page'); $I->amOnPage('/login'); - $I->fillField('username','almatrudia'); - $I->fillField('password','password'); + $I->fillField('username', 'almatrudia'); + $I->fillField('password', 'password'); $I->click('Submit'); $I->see('You logged in to main page'); - }*/ + } + public function testRegistrationCorrectly(AcceptanceTester $I) + { +// $I->wantTo('ensure that I can registrar with correct information'); +// +// $I->amOnPage('/registrar'); +// $I->fillField('first_name', 'Alamin'); +// $I->fillField('last_name', 'Almatrudi'); +// $I->fillField('username', 'uniqeUserName'); +// $I->fillField('email', 'me@hotmail.com'); +// $I->fillField('password', 'passworD365'); +// $I->fillField('password_confirm', 'passworD365'); +// $I->click('Register'); +// +// $I->see('I saved you to Database'); + + } + public function testRegistrarPage(AcceptanceTester $I) + { + $I->wantTo('ensure that the registrar page works'); + $I->amOnPage('/registrar'); + $I->see('Register'); + } } \ No newline at end of file diff --git a/tests/functional/FunctionalTester.php b/tests/functional/FunctionalTester.php index 0788a95..e6a60bd 100644 --- a/tests/functional/FunctionalTester.php +++ b/tests/functional/FunctionalTester.php @@ -1,4 +1,4 @@ - * ``` * - * @param $cookie - * @param $value + * @param $name + * @param $val + * @param array $params + * @internal param $cookie + * @internal param $value * * @return mixed * @see \Codeception\Lib\InnerBrowser::setCookie() */ - public function setCookie($name, $val) { + public function setCookie($name, $val, $params = null) { return $this->scenario->runStep(new \Codeception\Step\Action('setCookie', func_get_args())); } @@ -1873,13 +1877,15 @@ public function setCookie($name, $val) { * [!] Method is generated. Documentation taken from corresponding module. * * Grabs a cookie value. + * You can set additional cookie params like `domain`, `path` in array passed as last argument. * * @param $cookie * + * @param array $params * @return mixed * @see \Codeception\Lib\InnerBrowser::grabCookie() */ - public function grabCookie($name) { + public function grabCookie($name, $params = null) { return $this->scenario->runStep(new \Codeception\Step\Action('grabCookie', func_get_args())); } @@ -1888,6 +1894,7 @@ public function grabCookie($name) { * [!] Method is generated. Documentation taken from corresponding module. * * Checks that a cookie with the given name is set. + * You can set additional cookie params like `domain`, `path` as array passed in last argument. * * ``` php * scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeCookie', func_get_args())); } /** * [!] Method is generated. Documentation taken from corresponding module. * * Checks that a cookie with the given name is set. + * You can set additional cookie params like `domain`, `path` as array passed in last argument. * * ``` php * scenario->runStep(new \Codeception\Step\Assertion('seeCookie', func_get_args())); } @@ -1929,27 +1937,31 @@ public function seeCookie($name) { * [!] Method is generated. Documentation taken from corresponding module. * * Checks that there isn't a cookie with the given name. + * You can set additional cookie params like `domain`, `path` as array passed in last argument. * * @param $cookie * + * @param array $params * @return mixed * Conditional Assertion: Test won't be stopped on fail * @see \Codeception\Lib\InnerBrowser::dontSeeCookie() */ - public function cantSeeCookie($name) { + public function cantSeeCookie($name, $params = null) { return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCookie', func_get_args())); } /** * [!] Method is generated. Documentation taken from corresponding module. * * Checks that there isn't a cookie with the given name. + * You can set additional cookie params like `domain`, `path` as array passed in last argument. * * @param $cookie * + * @param array $params * @return mixed * @see \Codeception\Lib\InnerBrowser::dontSeeCookie() */ - public function dontSeeCookie($name) { + public function dontSeeCookie($name, $params = null) { return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeCookie', func_get_args())); } @@ -1958,13 +1970,15 @@ public function dontSeeCookie($name) { * [!] Method is generated. Documentation taken from corresponding module. * * Unsets cookie with the given name. + * You can set additional cookie params like `domain`, `path` in array passed as last argument. * * @param $cookie * + * @param array $params * @return mixed * @see \Codeception\Lib\InnerBrowser::resetCookie() */ - public function resetCookie($name) { + public function resetCookie($name, $params = null) { return $this->scenario->runStep(new \Codeception\Step\Action('resetCookie', func_get_args())); } diff --git a/tests/functional/WelcomeControllerCest.php b/tests/functional/WelcomeControllerCest.php index 4cc6451..d617207 100644 --- a/tests/functional/WelcomeControllerCest.php +++ b/tests/functional/WelcomeControllerCest.php @@ -5,6 +5,9 @@ class WelcomeControllerCest { public function _before(FunctionalTester $I) { + Artisan::call('migrate:rollback'); + Artisan::call('migrate'); + Artisan::call('db:seed'); } public function _after(FunctionalTester $I) @@ -25,7 +28,7 @@ public function testAboutPage(FunctionalTester $I){ $I->seeResponseCodeIs('200'); } - /*public function testLogin(FunctionalTester $I){ + public function testLogin(FunctionalTester $I){ $I->wantTo('ensure that logs in works and direct me to main page'); $I->amOnPage('/login'); $I->fillField('username','almatrudia'); @@ -34,5 +37,25 @@ public function testAboutPage(FunctionalTester $I){ $I->seeResponseCodeIs('200'); $I->seeCurrentUrlEquals('/login'); + } + public function testRegistrarPage(FunctionalTester $I){ + $I->wantTo('ensure that Registrar page works'); + $I->amOnPage('/registrar'); + $I->seeResponseCodeIs('200'); + + } + /* public function testRegistrationCorrectly(FunctionalTester $I) + { + $I->wantTo('ensure that I can registrar with correct information'); + $I->amOnPage('/registrar'); + $I->fillField('first_name', 'Alamin'); + $I->fillField('last_name', 'Almatrudi'); + $I->fillField('username', 'uniqeUserName'); + $I->fillField('email', 'me@hotmail.com'); + $I->fillField('password', 'passworD365'); + $I->fillField('password_confirm', 'passworD365'); + $I->click('Register'); + $I->seeResponseCodeIs('200'); + }*/ } \ No newline at end of file diff --git a/tests/unit/ExampleTestCest.php b/tests/unit/ExampleTestCest.php index 1425433..1991a2b 100644 --- a/tests/unit/ExampleTestCest.php +++ b/tests/unit/ExampleTestCest.php @@ -11,11 +11,225 @@ public function _after(UnitTester $I) { } - // tests - public function tryToTest(UnitTester $I) + public function TestValidatorPasswordMin(UnitTester $I) + + { + $I->wantTo('I want to test Validator When missing the min pass len'); + $user = array( + 'first_name' => 'my name', + 'last_name' => 'my last name', + 'username' => 'username', + 'email' => 'myemail@me.com', + 'password' => '1234', + 'password_confirm' => '1234' + ); + $validator = User::getValidator($user); + $I->assertTrue($validator->fails()); + + } + public function TestValidatorPasswordNum(UnitTester $I) + + { + $I->wantTo('I want to test Validator When missing num in pass'); + $user = array( + 'first_name' => 'my name', + 'last_name' => 'my last name', + 'username' => 'username', + 'email' => 'myemail@me.com', + 'password' => 'ABcdF', + 'password_confirm' => 'ABcdF' + ); + $validator = User::getValidator($user); + $I->assertTrue($validator->fails()); + + } + public function TestValidatorPasswordLower(UnitTester $I) + + { + $I->wantTo('I want to test Validator When missing lower in pass'); + $user = array( + 'first_name' => 'my name', + 'last_name' => 'my last name', + 'username' => 'username', + 'email' => 'myemail@me.com', + 'password' => 'ADFG4560', + 'password_confirm' => 'ADFG4560' + ); + $validator = User::getValidator($user); + $I->assertTrue($validator->fails()); + + } + public function TestValidatorPasswordUpper(UnitTester $I) + + { + $I->wantTo('I want to test Validator When missing upper in pass'); + $user = array( + 'first_name' => 'my name', + 'last_name' => 'my last name', + 'username' => 'username', + 'email' => 'myemail@me.com', + 'password' => 'asdf4560', + 'password_confirm' => 'asdf4560' + ); + $validator = User::getValidator($user); + $I->assertTrue($validator->fails()); + + } + + + public function TestValidatorMissingPassword(UnitTester $I) + + { + $I->wantTo('I want to test Validator when missing first name'); + + $user = array( + 'last_name' => 'my last name', + 'username' => 'username', + 'email' => 'myemaml@me.com', + 'password' => 'NicePas12', + 'password_confirm' => 'NicePas12' + + ); + + $validator = User::getValidator($user); + $I->assertTrue($validator->fails()); + + } + + public function TestValidatorMissingLastName(UnitTester $I) + + { + $I->wantTo('I want to test Validator When missing last name'); + $user = array( + 'first_name' => 'my name', + 'username' => 'username', + 'email' => 'myemaml@me.com', + 'password' => 'NicePas12', + 'password_confirm' => 'NicePas12' + + ); + $validator = User::getValidator($user); + $I->assertTrue($validator->fails()); + + } + + public function TestValidatorMissingUserName(UnitTester $I) + + { + $I->wantTo('I want to test Validator When missing userName'); + $user = array( + 'first_name' => 'my name', + 'last_name' => 'my last name', + 'email' => 'myemaml@me.com', + 'password' => 'NicePas12', + 'password_confirm' => 'NicePas12' + + ); + $validator = User::getValidator($user); + $I->assertTrue($validator->fails()); + + } + public function TestValidatorUserNameShort(UnitTester $I) + + { + $I->wantTo('I want to test Validator When userName is short'); + $user = array( + 'first_name' => 'my name', + 'last_name' => 'my last name', + 'username' => 'Alam', + 'email' => 'myemaml@me.com', + 'password' => 'NicePas12', + 'password_confirm' => 'NicePas12' + + ); + $validator = User::getValidator($user); + $I->assertTrue($validator->fails()); + } + + public function TestValidatorUserNameExists(UnitTester $I) + { + $I->wantTo('I want to test Validator When userName is used'); + $user = array( + 'first_name' => 'my name', + 'last_name' => 'my last name', + 'username' => 'almatrudia', + 'email' => 'myemaml@me.com', + 'password' => 'NicePas12', + 'password_confirm' => 'NicePas12' + + ); + $validator = User::getValidator($user); + $I->assertTrue($validator->fails()); + + } + public function ToTestValidatorEmailFormat(UnitTester $I) + { + + $I->wantTo('I want to test Validator When email is not good format'); + $user = array( + 'first_name' => 'my name', + 'last_name' => 'my last name', + 'username' => 'username', + 'email' => 'myemaml', + 'password' => 'NicePas12', + 'password_confirm' => 'NicePas12' + ); + + $validator = User::getValidator($user); + $I->assertTrue($validator->fails()); + + } + public function ToTestValidatorEmailIsUsed(UnitTester $I) + { + + $I->wantTo('I want to test Validator When email is used'); + $user = array( + 'first_name' => 'my name', + 'last_name' => 'my last name', + 'username' => 'username', + 'email' => 'almatrudia@msoe.edu', + 'password' => 'NicePas12', + 'password_confirm' => 'NicePas12' + ); + + $validator = User::getValidator($user); + $I->assertTrue($validator->fails()); + + } + + public function ToTestValidatorMissingEmail(UnitTester $I) { + $I->wantTo('I want to test Validator When missing email'); + $user = array( + 'first_name' => 'my name', + 'last_name' => 'my last name', + 'username' => 'username', + 'password' => 'NicePas12', + 'password_confirm' => 'NicePas12' + ); + + $validator = User::getValidator($user); + $I->assertTrue($validator->fails()); + } + public function TestValidatorPasses(UnitTester $I) + + { + $I->wantTo('I want to test Validator Passes'); + $user = array( + 'first_name' => 'my name', + 'last_name' => 'my last name', + 'username' => 'username', + 'email' => 'myemaml@me.com', + 'password' => 'NicePas12', + 'password_confirm' => 'NicePas12' + + ); + $validator = User::getValidator($user); + $I->assertFalse($validator->fails()); + + } -} \ No newline at end of file +}