<?php

/**
 *
 * @var $scenario \Codeception\Scenario
 *
 * @author Brett O'Donnell <*****@*****.**>
 * @author Zain Ul abidin <*****@*****.**>
 * @copyright 2013 Mr PHP
 * @link https://github.com/cornernote/yii-audit-module
 * @license BSD-3-Clause https://raw.github.com/cornernote/yii-audit-module/master/LICENSE
 *
 * @package yii-audit-module
 */
$I = new WebGuy($scenario);
$I->wantTo('ensure method call on non-object is caught');
$I->amOnPage('site/methodOnNonObject');
$I->see('PHP error');
$I->see('Fatal error: Call to a member function iAmNotAnObject() on a non-object');
$I->canSeeInDatabase('audit_error', array('code' => '500', 'type' => 'PHP error', 'message' => 'Fatal error: Call to a member function iAmNotAnObject() on a non-object'));
<?php

/**
 *
 * @var $scenario \Codeception\Scenario
 *
 * @author Brett O'Donnell <*****@*****.**>
 * @author Zain Ul abidin <*****@*****.**>
 * @copyright 2013 Mr PHP
 * @link https://github.com/cornernote/yii-audit-module
 * @license BSD-3-Clause https://raw.github.com/cornernote/yii-audit-module/master/LICENSE
 *
 * @package yii-audit-module
 */
$I = new WebGuy($scenario);
$I->wantTo('ensure undefined function is caught');
$I->amOnPage('site/undefinedFunction');
$I->see('PHP error');
$I->see('Fatal error: Call to undefined function undefined_function()');
$I->canSeeInDatabase('audit_error', array('code' => '500', 'type' => 'PHP error', 'message' => 'Fatal error: Call to undefined function undefined_function()'));
<?php

/**
 *
 * @var $scenario \Codeception\Scenario
 *
 * @author Brett O'Donnell <*****@*****.**>
 * @author Zain Ul abidin <*****@*****.**>
 * @copyright 2013 Mr PHP
 * @link https://github.com/cornernote/yii-audit-module
 * @license BSD-3-Clause https://raw.github.com/cornernote/yii-audit-module/master/LICENSE
 *
 * @package yii-audit-module
 */
$I = new WebGuy($scenario);
$I->wantTo('ensure undefined variable is caught');
$I->amOnPage('site/undefinedVariable');
$I->see('PHP notice');
$I->see('Undefined variable: undefined_variable');
$I->canSeeInDatabase('audit_error', array('code' => '500', 'type' => 'PHP notice', 'message' => 'Undefined variable: undefined_variable'));
<?php

/**
 *
 * @var $scenario \Codeception\Scenario
 *
 * @author Brett O'Donnell <*****@*****.**>
 * @author Zain Ul abidin <*****@*****.**>
 * @copyright 2013 Mr PHP
 * @link https://github.com/cornernote/yii-audit-module
 * @license BSD-3-Clause https://raw.github.com/cornernote/yii-audit-module/master/LICENSE
 *
 * @package yii-audit-module
 */
$I = new WebGuy($scenario);
$I->wantTo('ensure property call on non-object is caught');
$I->amOnPage('site/propertyOnNonObject');
$I->see('PHP notice');
$I->see('Trying to get property of non-object');
$I->canSeeInDatabase('audit_error', array('code' => '500', 'type' => 'PHP notice', 'message' => 'Trying to get property of non-object'));
<?php

/**
 *
 * @var $scenario \Codeception\Scenario
 *
 * @author Brett O'Donnell <*****@*****.**>
 * @author Zain Ul abidin <*****@*****.**>
 * @copyright 2013 Mr PHP
 * @link https://github.com/cornernote/yii-audit-module
 * @license BSD-3-Clause https://raw.github.com/cornernote/yii-audit-module/master/LICENSE
 *
 * @package yii-audit-module
 */
$I = new WebGuy($scenario);
$I->wantTo('ensure http error 404 is caught');
$I->amOnPage('site/httpError404');
$I->see('Page Not Found');
$I->see('The requested URL was not found on this server.');
$I->canSeeInDatabase('audit_error', array('code' => '404', 'type' => 'CHttpException', 'message' => 'Page not found message.'));
<?php

/**
 *
 * @var $scenario \Codeception\Scenario
 *
 * @author Brett O'Donnell <*****@*****.**>
 * @author Zain Ul abidin <*****@*****.**>
 * @copyright 2013 Mr PHP
 * @link https://github.com/cornernote/yii-audit-module
 * @license BSD-3-Clause https://raw.github.com/cornernote/yii-audit-module/master/LICENSE
 *
 * @package yii-audit-module
 */
$I = new WebGuy($scenario);
$I->wantTo('ensure http error 403 is caught');
$I->amOnPage('site/httpError403');
$I->see('Unauthorized');
//$I->see('You do not have the proper credential to access this page.');
$I->canSeeInDatabase('audit_error', array('code' => '403', 'type' => 'CHttpException', 'message' => 'Unauthorized message.'));