예제 #1
0
 public function testNonStringThrowsException()
 {
     $this->setExpectedException('Exception');
     $this->palindrome_tester->isPalindrome(array('crash' => 'bang'));
     $this->palindrome_tester->isPalindrome(new \DateTime());
     $this->palindrome_tester->isPalindrome(135);
 }
 public function testIntialize()
 {
     $default = new DefaultLocale();
     $sm = new ServiceManager();
     $sm->setService('config', array('locale' => 'sv_SE'));
     $default->initialize('foo', $sm);
     $tester = new Tester();
     $this->assertSame(Locale::getDefault(), $tester->getLocale());
     $default->initialize($tester, $sm);
     $this->assertSame('sv_SE', $tester->getLocale());
 }
예제 #3
0
 public function __call($name, $params)
 {
     if (substr($name, 0, 7) === 'public_') {
         $name = substr($name, 7);
         if (method_exists($this, $name)) {
             return call_user_func_array(array($this, $name), $params);
         }
     }
     $parents = class_parents($this);
     if (is_array($parents)) {
         foreach ($parents as $classname) {
             if (method_exists($classname, '__call')) {
                 return parent::__call($name, $params);
             }
         }
     }
     throw new Exception("Method {$name} does not exist for this class");
 }
예제 #4
0
 /**
  * This method will find private methods started with test_ in
  * the current class and will execute each method in succession
  * by passing $t argument to it. Before each test execution
  * takes place, $t->prepareForTest($test) will be called. It must
  * return non-false for test to be carried out.
  *
  * $test will be an array containing keys for 'name', 'object' and
  * 'class'
  */
 function runTests(Tester $tester = null)
 {
     $test = array('object' => $this->name, 'class' => get_class($this));
     foreach (get_class_methods($this) as $method) {
         if (strpos($method, 'test_') === 0) {
             $test['name'] = substr($method, 5);
         } else {
             continue;
         }
         if ($tester && $tester->prepareForTest($test) === false) {
             continue;
         }
         if ($tester) {
             $r = $tester->results;
             $r->unload();
             $r->set($test);
         }
         // Proceed with test
         $me = memory_get_peak_usage();
         $ms = microtime(true);
         $this->_ticks = 0;
         declare (ticks=1);
         register_tick_function(array($this, '_ticker'));
         // Execute here
         try {
             $result = $this->{$method}($tester);
         } catch (Exception $e) {
             unregister_tick_function(array($this, '_ticker'));
             $time = microtime(true) - $ms;
             $memory = memory_get_peak_usage() - $me;
             $ticks = $this->_ticks;
             if ($e instanceof Exception_SkipTests) {
                 if ($tester) {
                     $r['exception'] = 'SKIPPED';
                     $r->saveAndUnload();
                 }
                 return array('skipped' => $e->getMessage());
             }
             if ($tester) {
                 $r['time'] = $time;
                 $r['memory'] = $memory;
                 $r['ticks'] = $ticks;
                 $r['exception'] = $e;
                 $r->saveAndUnload();
             }
             continue;
         }
         // Unregister
         unregister_tick_function(array($this, '_ticker'));
         $time = microtime(true) - $ms;
         $memory = memory_get_peak_usage() - $me;
         $ticks = $this->_ticks - 3;
         // there are always minimum of 3 ticks
         if ($tester) {
             $r['time'] = $time;
             $r['memory'] = $memory;
             $r['ticks'] = $ticks;
             $r['is_success'] = true;
             $r['result'] = $result;
             $r->saveAndUnload();
         }
     }
 }
예제 #5
0
<?php

require_once 'StringOperationsObj.php';
$tester = new Tester();
$tester->TestAll();
    public function setTableDefinition()
    {
        $this->hasColumn('title', 'string', 255);
        $this->hasColumn('content', 'string', null);
    }
    public function setUp()
    {
        parent::setUp();
        $search = new rtSearchTemplate(array('fields' => array('title', 'content')));
        $this->actAs($search);
    }
}
Doctrine_Core::dropDatabases();
Doctrine_Core::createDatabases();
Doctrine_Core::createTablesFromArray(array('Tester', 'rtIndex'));
$tester = new Tester();
$t->is($tester->getSearchFields(), array('title', 'content'), '->getSearchFields() returns an array of configured fields');
$title = 'Hello, this is a test object!';
$content = 'It really doesn\'t do too much. Just a little bit of text to hold and save for testing.';
$tester['title'] = $title;
$tester['content'] = $content;
$t->is($tester->getSearchBlob(), $title . ' ' . $content, '->getSearchBlob() returns a combined string');
$blob_array = array('hello', 'test', 'object', 'realli', 'doesnt', 'text', 'hold', 'save', 'test');
$t->is(array_values($tester->getSearchIndexArray()), $blob_array, '->getSearchIndexArray() returns a stemmed array of words');
Doctrine_Core::createTablesFromArray(array('Tester'));
//$t->is($tester->getLanguages(), false, '->getLanguages() returns false for non i18n doctrine models');
class I18NTester extends Doctrine_Record
{
    public function setTableDefinition()
    {
        $this->hasColumn('title', 'string', 255);
예제 #7
0
    /**
     * Determine if PHP is being run from the CLI
     * 
     * @return boolean
     */
    public function isCli()
    {
        return php_sapi_name() === 'cli';
    }
}
/*
|--------------------------------------------------------------------------
| Contentify Installation Launcher
|--------------------------------------------------------------------------
*/
$tester = new Tester();
if ($tester->isCli()) {
    $tester->run();
    echo "The installer cannot be launched from a console.\n\r";
    echo 'Please navigate to the website with a browser to install Contentify.';
} else {
    if (!file_exists(__DIR__ . '/../storage/app/.install')) {
        die('Contentify already has been installed.');
    }
    echo '<html><head><title>Installer</title>
        <link href="http://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet" type="text/css">
        <style>body { margin: 20px; font-family: "Open Sans", arial; color: #666 }</style></head><body><table>';
    $tester->run();
    echo '</table><a href="./install" style="display: inline-block; padding: 20px; text-decoration: none; 
        background-color: #00afff; color: white; font-size: 18px; border-radius: 5px">Launch Installer</a>';
    echo '</body></html>';
예제 #8
0
function runTests()
{
    $t = new Tester();
    $t->test("ASCII to ASCII", convert("Hello World!", 'ascii', 'ascii'), "Hello World!");
    $t->test("ASCII to EDF 1.0.43 and back", convert(convert("Hello World!", 'ascii', 'edf_1_0_43'), 'edf_1_0_43', 'ascii'), "Hello World!");
    $t->testLcMatches("ASCII to EDF 1.0.43", bin2hex(convert("Hello World!", 'ascii', 'edf_1_0_43')), "89454446650D0A1A0AFEFF7C687474703A2F2F6675747572616D65726C696E2E636F6D2F7C466F726D61742076657273696F6E3A31.+");
    return $t->results();
}
예제 #9
0
function negative()
{
    return Tester::bool_to_string(Example::positive(-1));
}
예제 #10
0
    private $name;
    function __construct($name)
    {
        $this->name = $name;
    }
    public function makeNoise()
    {
        echo $this->name . " say: Meow<br>";
    }
    public function moveLeft()
    {
        echo $this->name . " moves left<br>";
    }
    public function moveRight()
    {
        echo $this->name . " moves right<br>";
    }
}
class Tester
{
    public static function makeNoise(Noise $noiseClass)
    {
        $noiseClass->makeNoise();
    }
}
Tester::makeNoise(new ChildClass());
$c = new Cat("Tom");
Tester::makeNoise($c);
echo "<hr>And cat may do some things:<br>";
$c->moveLeft();
$c->moveRight();
예제 #11
0
Doctrine_Core::createTablesFromArray(array('Tester', 'rtIndex'));
$tester = new Tester();
$tester['title'] = 'Hello, this is a test object, a balloon is great!';
$tester['content'] = 'Balloons really are great. Infact, ninety-nine of them make a wonderful song.';
$tester->save();
$table = Doctrine::getTable('rtIndex');
$t->is($table->getSearchResultsAsArray('19283hd'), false, '->getSearchResultsAsArray() returns false for a search on something which isn\'t in the index.');
$r = $table->getSearchResultsAsArray('balloon');
$t->is(is_array($r), true, '->getSearchResultsAsArray() returns an array for a valid search.');
$t->is(count($r), 1, '->getSearchResultsAsArray() returns correct no. of rows.');
$row_comparison = array('id' => '4', 'model' => 'Tester', 'model_id' => '1', 'lang' => 'en', 'relevance' => '2');
$t->is($r[0], $row_comparison, '->getSearchResultsAsArray() rows are the correct structure.');
$tester2 = new Tester();
$tester2['title'] = 'Colours';
$tester2['content'] = 'Red, green, blue and yellow are just a few of the colours.';
$tester2->save();
$tester3 = new Tester();
$tester3['title'] = 'Party';
$tester3['content'] = 'Ribbons, balloons, wine, some good food. Got it!';
$tester3->save();
$r = $table->getSearchResultsAsArray('balloon, object');
$t->is(count($r), 2, '->getSearchResultsAsArray() returns correct no. of rows... after new items added.');
$r = $table->getSearchResults('balloon, object');
$t->is(count($r), 2, '->getSearchResults() returns correct no. of rows... after new items added.');
$t->isa_ok($r, Doctrine_Collection, '->getSearchResults() returns a Doctrine_Collection object.');
$t->diag('Test some rtIndex object usage.');
$t->isa_ok($r[0]->getObject(), Tester, '->getObject() returns a Tester object.');
$r = $table->getSearchResults('balloon, object');
$r = $table->hydrateResults($r);
$t->is(count($r), 2, '->hydrateResults() returns correct no. of rows... after new items added.');
$t->isa_ok($r, Doctrine_Collection, '->hydrateResults() returns a Doctrine_Collection object.');
예제 #12
0
--TEST--
ZE2 a class cannot extend an interface
--SKIPIF--
<?php 
if (version_compare(zend_version(), '2.0.0-dev', '<')) {
    die('skip ZendEngine 2 needed');
}
?>
--FILE--
<?php 
interface Test
{
    function show();
}
class Tester extends Test
{
    function show()
    {
        echo __METHOD__ . "\n";
    }
}
$o = new Tester();
$o->show();
?>
===DONE===
--EXPECTF--

Fatal error: Tester cannot extend from Test - it is not an class in %s on line %d, position %d
예제 #13
0
    public function run()
    {
        printf("%s: %lu running\n", __CLASS__, $this->getThreadId());
        foreach ($this->tests as $test) {
            /* this tests protected method access on a nonsense method, and reads some data directly */
            printf("%s: %lu working %lu ... %s/%d\n", __CLASS__, $this->getThreadId(), $test->getThreadId(), $test->my, $test->scopeTestFunc());
            /* this is us directly writing another threads members, just for something to do */
            $test->reading = rand() * 10 * microtime(true) / 10;
            /* tell the test thread we are done and it can read what was written now */
            $test->isFinished(true);
        }
        /* the process is waiting to handle failed tests */
        printf("%s: %lu notifying process: %d\n", __CLASS__, $this->getThreadId(), $this->notify());
    }
}
printf("Process: running\n");
$tests = array(new SyncTest(), new SyncTest());
$tester = new Tester($tests);
$tester->start();
$tester->wait();
printf("Process: notified\n");
foreach ($tests as $test) {
    if (!$test->isJoined() && $test->isWaiting()) {
        printf("Process: notifying %lu\n", $test->getThreadId());
        printf("Process: notified %lu: %d\n", $test->getThreadId(), $test->notify());
    } else {
        printf("Process: done with %lu\n", $test->getThreadId());
    }
    printf("Process: read %lu: %s\n", $test->getThreadId(), $test->reading);
}
printf("Process: notifying %lu\n", $tester->getThreadId());
예제 #14
0
파일: index.php 프로젝트: nxnc/WPF_MW
<?php

class Tester
{
    public $pub = 'public';
    private $priv = 'private';
    protected $prot = 'protected';
    public function iterateVars()
    {
        foreach ($this as $key => $value) {
            echo $key . ' => ' . $value . '<br />';
        }
    }
}
$test = new Tester();
echo 'Methode<br />';
$test->iterateVars();
echo 'Objekt<br />';
foreach ($test as $key => $value) {
    echo $key . ' => ' . $value . '<br />';
}
예제 #15
0
Simply put, :: is for class-level properties, and -> is for object-level properties.
- If the property belongs to the class, use ::
- If the property belongs to an instance of the class, use ->
*/
class Tester
{
    public $foo;
    const BLAH = "lala";
    public static function bar()
    {
        echo "Tester\n";
    }
}
$t = new Tester();
$t->foo;
Tester::bar();
printf("%s\n", Tester::BLAH);
/* When you declare a class, it is by default 'static'. You can access any method in that class using the :: operator, and in any scope. This means if I create a lib class, I can access it wherever I want and it doesn't need to be globaled:
*/
class lib
{
    static function foo()
    {
        echo "Hello\n";
    }
}
lib::foo();
/* Now, when you create an instance of this class by using the new keyword, you use -> to access methods and values, because you are referring to that specific instance of the class. You can think of -> as inside of. (Note, you must remove the static keyword) IE:
*/
class lib2
{
예제 #16
0
<?php

include '../before.php';
Tester::describe('Undefined Variable Example', Tester::describe('__construct', Tester::it('should construct.', Tester::func('construct'), '')) . Tester::describe('hello', Tester::it('should say hello.', Tester::func('sayHello'), 'hello')), true);
/* Functions to return values for the test inputs */
function construct()
{
    return $unknown_var;
}
function sayHello()
{
    return 'hello';
}
예제 #17
0
<?php

include '../before.php';
Tester::describe('Divide by Zero Error Example', Tester::describe('Do Math', Tester::it('should do math.', Tester::func('doMath'), 4)), true);
/* Functions to return values for the test inputs */
function doMath()
{
    $x = 1;
    return $x / 0;
}
예제 #18
0
	<td class='strong'>
		<?=$testTask->id;?>
	</td>
</tr>

<tr>
	<th>状态:</th>
	<td class='red'>
		<?=$testTask->statusDesc();?>
	</td>
</tr>

<tr>
	<th>测试人:</th>
	<td>
		<?php echo HtmlControl::getSelectCtrImp(Tester::toArray4HtmlCtr($testers), 'testerId', $testTask->getTester()->id); ?>
	</td>
</tr>

<tr>
	<th>名称:</th>
	<td><input type="text" id="name" name="name" size=70 value="<?=$testTask->name;?>" class="f14 h25"/></td>
</tr>

<tr>
	<th>版本:</th>
	<td><input type="text" id="testVer" name="testVer" value="<?=$testTask->testVer;?>" class="f14 h25"/></td>
</tr>

<tr>
	<th>环境:</th>
예제 #19
0
파일: place.php 프로젝트: KooLru/validator
class Tester extends wiki_places
{
    use test;
    function t($wiki, $right)
    {
        $this->region = 'TEST';
        $this->useCache = true;
        $url = $this->domain . '/wiki/' . urlencode($wiki) . '?action=edit';
        $url = str_replace(array('%28', '%29'), array('(', ')'), $url);
        $page = $this->download($url);
        $this->parse($page);
        $obj = $this->objects[count($this->objects) - 1];
        $this->test($obj['place'], $right, $wiki);
    }
}
$v = new Tester('RU-MOS');
// по OSM wiki
$v->t('Усвяты', 'town');
$v->t('Сосновый_Бор_(Себежский_район)', 'village');
$v->t('Новое_Девяткино', 'town');
$v->t('Шуйское_(Вологодская_область)', 'town');
$v->t('Линово_(Псковская_область)', 'village');
$v->t('Развилка_(Московская_область)', 'town');
// сельский от 8 тыс.
$v->t('Бобров_(город)', 'town');
// адм. центр района
$v->t('Олонецкий_Шлюз', 'locality');
// Хутор, но населения 0
$v->t('Верхние_Осельки', 'village');
// адм. центр сельского поселения
$v->t('Лапшаур', 'village');
예제 #20
0
}
class Book extends Model
{
    public function authors()
    {
        return $this->has_many_through('Author');
    }
}
$book = Model::factory('Book')->find_one(1);
$authors = $book->authors()->find_many();
$expected = "SELECT `author`.* FROM `author` JOIN `author_book` ON `author`.`id` = `author_book`.`author_id` WHERE `author_book`.`book_id` = '1'";
Tester::check_query("has_many_through relation", $expected);
class AuthorTwo extends Model
{
}
class WroteTheBook extends Model
{
}
class BookTwo extends Model
{
    public function authors()
    {
        return $this->has_many_through('AuthorTwo', 'WroteTheBook', 'custom_book_id', 'custom_author_id');
    }
}
$book2 = Model::factory('BookTwo')->find_one(1);
$authors2 = $book2->authors()->find_many();
$expected = "SELECT `author_two`.* FROM `author_two` JOIN `wrote_the_book` ON `author_two`.`id` = `wrote_the_book`.`custom_author_id` WHERE `wrote_the_book`.`custom_book_id` = '1'";
Tester::check_query("has_many_through relation with custom intermediate model and key names", $expected);
Tester::report();
예제 #21
0
#!/usr/bin/php
<?php 
require_once 'test.php';
require_once '../Validator.class.php';
require_once '../../parser/bank/sberbank.php';
class Tester extends sberbank
{
    use test;
    function __construct()
    {
    }
    function t($x, $right)
    {
        $this->test($this->time($this->parseTime($x)), $right, $right);
    }
}
$v = new Tester('');
$v->t('Пн.:с 09:00 до 13:00, Сб.:с 09:00 до 13:00', 'Mo,Sa 09:00-13:00');
$v->t('Пн.:с 09:00 до 14:15 (обед с 13:00 до 13:30)', 'Mo 09:00-13:00,13:30-14:15');
예제 #22
0
<?php

require_once 'Tester.php';
$tests = array('eval' => 'php', 'unserialize' => 'phps', 'json_decode' => 'json');
$data = array();
foreach ($tests as $test) {
    include_once "data_{$test}.php";
}
$tester = new Tester(1000);
$tester->setTestData($data);
$tester->setTests($tests);
$tester->runTests();
$tester->printResults();
예제 #23
0
 function getTesterMain()
 {
     $tester = new Tester($this->user);
     return $tester->getPage();
 }
예제 #24
0
<?php

include_once "recommender-system-tester.php";
// all you should do is change the config array
$config = array('topN' => 20, 'recommenders' => array('key1' => array('name' => 'KeywordRecommender', 'weight' => 1, 'config' => array('name' => KEY_NO_EXPANSION))), 'splitters' => array('key2' => array('name' => 'KFoldCrossSplitter', 'config' => array('k_fold' => 10))), 'evaluators' => array('key2' => array('name' => 'ConfusionMatrixEvaluator', 'config' => array())));
$tester = new Tester($config);
$tester->run();
예제 #25
0
        } else {
            return TRUE;
        }
    }
}
class Tester
{
    var $tests = array();
    function add($test)
    {
        $this->tests[] = $test;
    }
    function run()
    {
        foreach ($this->tests as $test) {
            $result = $test->run();
            print "<p>";
            print $test->title() . ": ";
            if ($result !== TRUE) {
                print "<span style='color: red;'>Fail: " . htmlentities($result) . "</span>";
            } else {
                print "<span style='color: green;'>Success</span>";
            }
            print "</p>";
        }
    }
}
$tester = new Tester();
$tester->add(new FunctionTest('wiki_render', 'AWikiWord', "<p><a href='AWikiWord'>AWikiWord</a></p>"));
$tester->add(new StrstrTest('wiki_render', '- not bold -', "<strong>"));
$tester->run();
예제 #26
0
<?php

include '../before.php';
Tester::describe('Capture HTML Example', Tester::describe('Do HTML', Tester::it('should output code.', Tester::func('html'), 'Some text')), true);
/* Functions to return values for the test inputs */
function html()
{
    echo "<p>Some text</p>";
}
예제 #27
0
파일: test.php 프로젝트: neotok/simplepo
"foo bar\\n"
"a \\" quote"
msgstr ""

#: standard input:116 input:1115 input:1205
#: input:1838 input:1868 
#~ msgid "Password"
#~ "xxx"
#~ msgstr "Mot de passe:"
#~ "xxx"

FILE;
StringStreamController::createRef('reference', $easy_file);
$fh = fopen('string://reference', 'r');
$store = new TempPoMsgStore();
$t = new Tester();
$parser = new POParser($store);
$parser->parseEntriesFromStream($fh);
$objects = $store->read();
$t->assertTrue($objects[1]);
$t->assertTrue($objects[0]);
$t->assertFalse($objects[10]);
$t->assertTrue($objects[0]['msgid']);
$t->assertTrue($objects[0]['msgstr']);
$t->assertFalse($objects[0]['should_not_exist']);
$t->assertEquals($objects[0]['msgid'], 'Password');
$t->assertEquals($objects[0]['msgstr'], 'Mot de passe:');
$t->assertEquals($objects[1]['msgid'], "Hard idfoo bar\na \" quote");
$t->assertEquals($objects[2]['msgid'], 'Passwordxxx');
$t->assertEquals($objects[2]['msgstr'], 'Mot de passe:xxx');
$t->assertTrue($objects[2]['is_obsolete']);
예제 #28
0
파일: test.php 프로젝트: funkyidol/usergrid
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/**
 * @file
 * main entry point for running tests
 *
 * @author Rod Simpson <*****@*****.**>
 * @since 09-Mar-2013
 */
//@han {include-sdk}
include '../autoloader.inc.php';
usergrid_autoload('Apache\\Usergrid\\Client');
//@solo
//@han {create-new-client}
$client = new Apache\Usergrid\Client('1hotrod', 'sandbox');
//@solo
include 'Tester.php';
$tester = new Tester();
include 'generic.php';
include 'entity.php';
include 'collection.php';
include 'user.php';
include 'client_auth.php';
include 'push.php';
//--------------------------------------------------------------
// Summary
//--------------------------------------------------------------
$tester->printSummary();
예제 #29
0
파일: bug65291.php 프로젝트: badlamer/hhvm
<?php

trait TestTrait
{
    public static function testStaticFunction()
    {
        return __CLASS__;
    }
}
class Tester
{
    use TestTrait;
}
$foo = Tester::testStaticFunction();
get_defined_constants();
get_defined_constants(true);
echo $foo;
예제 #30
0
class Child extends Tester
{
    function test()
    {
        var_dump(get_class_vars("Tester"));
    }
    static function testStatic()
    {
        var_dump(get_class_vars("Tester"));
    }
}
echo "*** Testing get_class_vars() : testing visibility\n";
echo "\n-- From global context --\n";
var_dump(get_class_vars("Tester"));
echo "\n-- From inside an object instance --\n";
$instance = new Tester();
$instance->test();
echo "\n-- From  a static context --\n";
Tester::testStatic();
echo "\n-- From inside an  parent object instance --\n";
$parent = new Ancestor();
$parent->test();
echo "\n-- From a parents static context --\n";
Ancestor::testStatic();
echo "\n-- From inside a child object instance --\n";
$child = new Child();
$child->test();
echo "\n-- From a child's static context --\n";
Child::testStatic();
?>
===DONE===