示例#1
0
 public function startTest($title = NULL)
 {
     $test = new UnitTest($this);
     $test->title = $title === NULL ? md5(uniqid(rand())) : $title;
     $this->testStack[$test->getId()] = $test;
     return $test;
 }
示例#2
0
文件: UnitTest.php 项目: rsms/phpab
 /** @return UnitTest */
 public static function instance()
 {
     if (!self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
示例#3
0
文件: RouterTest.php 项目: saiber/www
 public function setUp()
 {
     parent::setUp();
     $this->request = new Request();
     $this->router = new Router($this->request);
     $this->router->setBaseDir('/', '/');
 }
示例#4
0
 public function tearDown()
 {
     ActiveRecordModel::executeUpdate('DROP TABLE LoadReferenceParent');
     ActiveRecordModel::executeUpdate('DROP TABLE LoadReferenceChild');
     ActiveRecordModel::executeUpdate('DROP TABLE LoadReferenceSuper');
     return parent::tearDown();
 }
示例#5
0
 public function action_index()
 {
     // Display all Unit tests found by default
     $tests = NULL;
     if ($this->request->param('test_dir') !== NULL) {
         $tests = UnitTest::find_tests($this->request->param('test_dir'));
     }
     // Display requested tests
     $this->request->response = UnitTest::factory($tests)->run();
 }
示例#6
0
 /**
  * Run tests
  *
  * @return void
  */
 public function test()
 {
     # Refresh assert bindings
     UnitTest::instance()->refreshAssertBindings();
     # Reset case storage & passed-cache
     $this->cases = array();
     $this->allCasesPassed = true;
     # Implementation-specific test logic
     $this->performTests();
 }
 public function setUp()
 {
     $this->fixtures('unit_tests', 'unit_tests_more');
     // paginated collection from array
     $files = array(new File(1, 'alpha'), new File(2, 'beta'), new File(3, 'gamma'), new File(4, 'delta'), new File(5, 'epsilon'), new File(6, 'zeta'), new File(7, 'eta'), new File(8, 'theta'), new File(9, 'iota'), new File(10, 'kappa'), new File(11, 'lamda'), new File(12, 'mu'), new File(13, 'nu'), new File(14, 'xi'), new File(15, 'omikron'), new File(16, 'pi'), new File(17, 'rho'), new File(18, 'sigma'), new File(19, 'tau'), new File(20, 'upsilon'), new File(21, 'phi'), new File(22, 'chi'), new File(23, 'psi'), new File(24, 'omega'));
     $this->_array = new Mad_Model_PaginatedCollection(array_slice($files, 10, 5), 3, 5, count($files));
     // paginated collection from model collection
     $testCount = UnitTest::count();
     $tests = UnitTest::find('all', array('offset' => '5', 'limit' => '5'));
     $this->_models = new Mad_Model_PaginatedCollection($tests, 2, 5, $testCount);
 }
示例#8
0
 /**
  * Run tests
  *
  * @return void
  */
 public function test()
 {
     $oldAssertionStorage =& UnitTest::instance()->getAssertionStorage();
     UnitTest::instance()->setAssertionStorage($this->assertions);
     try {
         $this->performTests();
     } catch (Exception $e) {
         $this->exception = $e;
     }
     UnitTest::instance()->setAssertionStorage($oldAssertionStorage);
     $this->updateAssertions();
 }
 public function __construct()
 {
     parent::__construct('Godaddy Shared Hosting Compatibility');
 }
示例#10
0
 public function testEmailValidation()
 {
     $this->fixtures('unit_tests');
     $test = UnitTest::find(1);
     $test->email_value = 'asdf';
     $this->assertFalse($test->isValid());
     $this->assertTrue($test->errors->isInvalid('email_value'));
     $this->assertEquals(1, count($test->errors->on('email_value')));
     $this->assertFalse($test->save());
 }
 function actionUnitMethod($method)
 {
     $meth = Method::model()->findByPk($method);
     if ($meth == null) {
         throw new CHttpException(404, 'Method not found :-(');
     }
     $t = UnitTest::model()->findByAttributes(array('id_method' => $method));
     if ($t != null) {
         $this->redirect(array('view', 'id' => $t->id_test));
     } else {
         $model = new Test();
         $special = new UnitTest();
         $special->id_method = $id_method;
         // Uncomment the following line if AJAX validation is needed
         // $this->performAjaxValidation($model);
         if (isset($_POST['Test'])) {
             $model->attributes = $_POST['Test'];
             $special->id_test = 0;
             if ($model->save()) {
                 $special->id_test = $model->id_test;
                 $special->save(false);
                 $this->redirect(array('view', 'id' => $model->id_test));
             }
         }
         $this->render('create', array('model' => $model, 'special' => $special));
     }
 }
示例#12
0
error_reporting(E_ALL);
if (!defined('TEST_INITIALIZED')) {
    // load classes and mount paths
    $cd = getcwd();
    $_SERVER["SCRIPT_FILENAME"] = dirname(__FILE__);
    chdir(dirname(dirname(__FILE__)));
    chdir('..');
    include_once 'application/Initialize.php';
    $arPath = realpath(getcwd() . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . 'activerecord' . DIRECTORY_SEPARATOR . 'ActiveRecord.php');
    include_once $arPath;
    ActiveRecord::setDSN('mysql://root@server/livecart');
    // set unittest and simpletest library root directory
    $libDir = dirname(dirname(__FILE__)) . '/_library/';
    ClassLoader::mountPath('phpunit', realpath($libDir . 'phpunit/'));
    ClassLoader::mountPath('unittest', realpath($libDir . 'unittest') . '/');
    ClassLoader::mountPath('testdir', dirname(__FILE__) . '/');
    ClassLoader::import("phpunit.*");
    ClassLoader::import("unittest.*");
    ClassLoader::import("testdir.*");
    ClassLoader::import('unittest.UnitTest');
    chdir($cd);
    define('TEST_INITIALIZED', true);
    ClassLoader::import('application.LiveCart');
    UnitTest::setApplication(new LiveCart());
    UnitTest::getApplication()->getConfig()->setAutoSave(false);
    UnitTest::getApplication()->getConfig()->set('EMAIL_METHOD', 'FAKE');
}
ClassLoader::import('application.system.*');
ClassLoader::import('library.locale.Locale');
ClassLoader::import('test.mock.Swift_Connection_Fake');
require_once 'LiveCartTest.php';
示例#13
0
 function __construct($debug)
 {
     $this->r = new AddictDatabase("brokenva_addicttest");
     parent::__construct($debug);
 }
示例#14
0
 public function testAssertNoDifferenceFalse()
 {
     try {
         $diff = $this->assertNoDifference('UnitTest::count()');
         UnitTest::create(array('string_value' => 'foo bar', 'integer_value' => 12345, 'email_value' => '*****@*****.**'));
         $diff->end();
     } catch (Exception $e) {
     }
     $this->assertTrue($e instanceof PHPUnit_Framework_AssertionFailedError);
 }
 function actionUnitTest($id, $raw = 0)
 {
     $test = UnitTest::model()->findByPk($id);
     if ($test == null) {
         throw new CHttpException(404, 'Test not found');
     }
     $this->render_code('unit_test', $raw, false, array('test' => $test));
 }
示例#16
0
 public function testBeforeUpdateException()
 {
     try {
         $test = UnitTest::find(1);
         $test->updateAttributes(array('integer_value' => '123', 'string_value' => 'before update test'));
         $test->saveEx();
         $this->fail();
     } catch (Mad_Model_Exception_Validation $e) {
         // validation errors
         $this->assertEquals(1, count($test->errors));
         foreach ($test->errors->fullMessages() as $msg) {
             $this->assertEquals('String value cannot be renamed to before update test', $msg);
         }
     }
 }
 public function setUp()
 {
     parent::setUp();
     $this->parser = new DomNodeParser();
 }
示例#18
0
 protected function setUp()
 {
     parent::setUp();
     $this->cleanupDb();
 }
 public function setUp()
 {
     parent::setUp();
     $this->converter = new Converter(new DomNodeParser(), new MarkdownRenderer());
 }
示例#20
0
 public function testRenderPartialModelCollection()
 {
     $this->fixtures('unit_tests');
     $this->_view->myObjects = UnitTest::find('all', array('limit' => 2));
     $expected = '<div><p>name a</p><p>name b</p></div>';
     $this->assertEquals($expected, $this->_view->render('testPartialCollection'));
 }
示例#21
0
<?php

$tests = UnitTest::model()->findAll();
foreach ($tests as $t) {
    echo strtolower($t->public_id()) . ".cpp";
}
 protected function getDataSet()
 {
     return parent::generateDataset(array("units.yml", "users.yml"));
 }
示例#23
0
文件: EventTest.php 项目: vimac/zan
 public function tearDown()
 {
     parent::tearDown();
     Event::clear();
     $this->dataMap = [];
 }
示例#24
0
function test_row(UnitTest $test, $indentation, TableCreator $table_creator)
{
    return $table_creator->row(array($table_creator->child_indentation($indentation), $test->public_id(), $test->test->description, $test->method->name . "()", 'success'));
}
示例#25
0
 public function testUniqueUpdateInvalid()
 {
     $this->fixtures('unit_tests');
     $this->model = UnitTest::find(1);
     $options = array();
     $validation = Mad_Model_Validation_Base::factory('uniqueness', 'string_value', $options);
     $this->model->string_value = 'name b';
     $validation->validate('save', $this->model);
     $this->assertEquals(array('has already been taken'), $this->model->errors->on('string_value'));
 }
示例#26
0
文件: TaskTest.php 项目: vimac/zan
 public function tearDown()
 {
     parent::tearDown();
 }
示例#27
0
 public function __construct()
 {
     parent::__construct();
     $this->instance = new OsCommerceImport('mysql://root@server/oscommerce');
     $this->importer = new LiveCartImporter($this->instance);
 }
示例#28
0
 public static function setApplication(Application $app)
 {
     self::$application = $app;
 }
示例#29
0
        $ci->load->assert($this);
        $ci->dbforge->assert($this);
    }
    public function test_rename_column()
    {
        $ci =& get_instance();
        $ci->load = new Mock_Loader();
        $ci->dbforge = new Mock_DBForge();
        $ci->db = new Mock_DB();
        $ci->load->expect_call('dbforge');
        $ci->db->expect_call('field_data', 1, array('table_name'));
        $ci->dbforge->expect_call('modify_column', 1, array('table_name', array('column_name' => array('name' => 'new_column_name', 'type' => 'INT'))));
        Schema::rename_column('table_name', 'column_name', 'new_column_name');
        $ci->load->assert($this);
        $ci->dbforge->assert($this);
    }
    public function test_modify_column()
    {
        $ci =& get_instance();
        $ci->load = new Mock_Loader();
        $ci->dbforge = new Mock_DBForge();
        $ci->load->expect_call('dbforge');
        $ci->dbforge->expect_call('modify_column', 1, array('table_name', array('column_name' => array('type' => 'INT', 'other' => 'here'))));
        Schema::modify_column('table_name', 'column_name', 'integer', array('other' => 'here'));
        $ci->load->assert($this);
        $ci->dbforge->assert($this);
    }
}
if (!defined('SCHEMA_TEST_ALL')) {
    UnitTest::test();
}
示例#30
0
 public function testShouldSerializeNullBinary()
 {
     $user = new UnitTest(array('blob_value' => null));
     $xml = $user->toXml();
     $this->assertContains('<blob-value encoding="base64" type="binary" nil="true"></blob-value>', $xml);
 }