Page_Tester::init PHP Method

init() public method

public init ( )
    public function init()
    {
        parent::init();
        if (!$this->auto_test) {
            $this->setVariance(array('Test'));
            return;
            // used for multi-page testing
        }
        $this->grid = $this->add('Grid');
        /** @type Grid $this->grid */
        $this->grid->addColumn('template', 'name')->setTemplate('<a href="' . $this->app->url(null, array('testonly' => '')) . '<?$name?>"><?$name?></a>');
        $this->setVariance(array('Test'));
        //$this->setVariance(array('GiTemplate','SMlite'));
        $this->runTests();
        if (!$_GET['testonly']) {
            /** @type Form $f */
            $f = $this->add('Form');
            $ff = $f->addField('Text', 'responses');
            $this->responses = '    public $proper_responses=array(
                ' . implode(',
                ', $this->responses) . '
                );';
            $ff->set($this->responses);
            $ff->js('click')->select();
        }
    }

Usage Example

示例#1
0
 function init()
 {
     $this->db = $this->add('DB');
     try {
         $this->db->query('drop table author');
     } catch (PDOException $e) {
     }
     try {
         $this->db->query('drop table book');
     } catch (PDOException $e) {
     }
     try {
         $this->db->query('drop table contact');
     } catch (PDOException $e) {
     }
     $this->db->query('create table author (id int not null primary key auto_increment, name varchar(255), email varchar(255),my_contact int)');
     $this->db->query('create table book (id int not null primary key auto_increment, name varchar(255), isbn varchar(255), author_id int)');
     $this->db->query('create table contact (id int not null primary key auto_increment, address varchar(255), line1 varchar(255), street varchar(255), author_id int)');
     $this->api->pathfinder->addLocation('..', array('addons' => 'atk4-addons'));
     $this->a = $a = $this->add($this->author_class);
     $this->a->deleteAll();
     $a = $this->a;
     if ($a->hasMethod('addCache')) {
         $c = $a->addCache('Dumper', 'zz');
         $c->setPrimarySource($a, 'Array');
     }
     $n = array('Anne', 'Jane', 'Aileen', 'John', 'Peter', 'Gavin', 'David', 'Marin', 'Skuja');
     $s = array('Smith', 'Blogs', 'Coder', 'Tester', 'Hacker');
     for ($x = 0; $x < 100; $x++) {
         $a['name'] = $this->r($n) . ' ' . $this->r($s);
         $a->saveAndUnload();
     }
     parent::init();
 }
All Usage Examples Of Page_Tester::init