Added new (clean) yii boilerplate
This commit is contained in:
25
www/protected/tests/WebTestCase.php
Normal file
25
www/protected/tests/WebTestCase.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Change the following URL based on your server configuration
|
||||
* Make sure the URL ends with a slash so that we can use relative URLs in test cases
|
||||
*/
|
||||
define('TEST_BASE_URL','http://localhost/testdrive/index-test.php/');
|
||||
|
||||
/**
|
||||
* The base class for functional test cases.
|
||||
* In this class, we set the base URL for the test application.
|
||||
* We also provide some common methods to be used by concrete test classes.
|
||||
*/
|
||||
class WebTestCase extends CWebTestCase
|
||||
{
|
||||
/**
|
||||
* Sets up before each test method runs.
|
||||
* This mainly sets the base URL for the test application.
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->setBrowserUrl(TEST_BASE_URL);
|
||||
}
|
||||
}
|
||||
10
www/protected/tests/bootstrap.php
Normal file
10
www/protected/tests/bootstrap.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
// change the following paths if necessary
|
||||
$yiit=dirname(__FILE__).'/../../../framework/yiit.php';
|
||||
$config=dirname(__FILE__).'/../config/test.php';
|
||||
|
||||
require_once($yiit);
|
||||
require_once(dirname(__FILE__).'/WebTestCase.php');
|
||||
|
||||
Yii::createWebApplication($config);
|
||||
0
www/protected/tests/fixtures/.gitkeep
vendored
Normal file
0
www/protected/tests/fixtures/.gitkeep
vendored
Normal file
47
www/protected/tests/functional/SiteTest.php
Normal file
47
www/protected/tests/functional/SiteTest.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
class SiteTest extends WebTestCase
|
||||
{
|
||||
public function testIndex()
|
||||
{
|
||||
$this->open('');
|
||||
$this->assertTextPresent('Welcome');
|
||||
}
|
||||
|
||||
public function testContact()
|
||||
{
|
||||
$this->open('?r=site/contact');
|
||||
$this->assertTextPresent('Contact Us');
|
||||
$this->assertElementPresent('name=ContactForm[name]');
|
||||
|
||||
$this->type('name=ContactForm[name]','tester');
|
||||
$this->type('name=ContactForm[email]','tester@example.com');
|
||||
$this->type('name=ContactForm[subject]','test subject');
|
||||
$this->click("//input[@value='Submit']");
|
||||
$this->waitForTextPresent('Body cannot be blank.');
|
||||
}
|
||||
|
||||
public function testLoginLogout()
|
||||
{
|
||||
$this->open('');
|
||||
// ensure the user is logged out
|
||||
if($this->isTextPresent('Logout'))
|
||||
$this->clickAndWait('link=Logout (demo)');
|
||||
|
||||
// test login process, including validation
|
||||
$this->clickAndWait('link=Login');
|
||||
$this->assertElementPresent('name=LoginForm[username]');
|
||||
$this->type('name=LoginForm[username]','demo');
|
||||
$this->click("//input[@value='Login']");
|
||||
$this->waitForTextPresent('Password cannot be blank.');
|
||||
$this->type('name=LoginForm[password]','demo');
|
||||
$this->clickAndWait("//input[@value='Login']");
|
||||
$this->assertTextNotPresent('Password cannot be blank.');
|
||||
$this->assertTextPresent('Logout');
|
||||
|
||||
// test logout process
|
||||
$this->assertTextNotPresent('Login');
|
||||
$this->clickAndWait('link=Logout (demo)');
|
||||
$this->assertTextPresent('Login');
|
||||
}
|
||||
}
|
||||
13
www/protected/tests/phpunit.xml
Normal file
13
www/protected/tests/phpunit.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<phpunit bootstrap="bootstrap.php"
|
||||
colors="false"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
stopOnFailure="false">
|
||||
|
||||
<selenium>
|
||||
<browser name="Internet Explorer" browser="*iexplore" />
|
||||
<browser name="Firefox" browser="*firefox" />
|
||||
</selenium>
|
||||
|
||||
</phpunit>
|
||||
2
www/protected/tests/report/.gitignore
vendored
Normal file
2
www/protected/tests/report/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
0
www/protected/tests/unit/.gitkeep
Normal file
0
www/protected/tests/unit/.gitkeep
Normal file
Reference in New Issue
Block a user