public function testReflection() { $obj = new TestObject(); $reflection = $obj->getReflection(); $this->assertTrue($reflection instanceof ReflectionClass); $this->assertTrue($reflection instanceof Sabel_Reflection_Class); $this->assertEquals("TestObject", $reflection->getName()); $this->assertTrue($reflection->hasMethod("hoge")); }
/** * @see http://lists.shadanakar.org/onphp-dev-ru/0811/0774.html **/ public function testRecursiveContainers() { $this->markTestSkipped('wontfix'); foreach (DBTestPool::me()->getPool() as $db) { DBPool::me()->setDefault($db); TestObject::dao()->import(TestObject::create()->setId(1)->setName('test object')); TestType::dao()->import(TestType::create()->setId(1)->setName('test type')); $type = TestType::dao()->getById(1); $type->getObjects()->fetch()->setList(array(TestObject::dao()->getById(1)))->save(); $object = TestObject::dao()->getById(1); TestObject::dao()->save($object->setName('test object modified')); $list = $type->getObjects()->getList(); $modifiedObject = TestObject::dao()->getById(1); $this->assertEquals($list[0], $modifiedObject); } }
public function testObjectRender() { $obj = new TestObject(); $obj->template('Hello {{name}}{{#intro}}, my name is {{intro}}{{/intro}}!'); $this->assertEquals('Hello Regina, my name is James Bond!', $obj->render()); }
/** * Loads the given file as a Program, then returns it wrapped in a TestClass. * @param string $file The path to the file to load. * @return \Phortress\Program */ function loadGlassBoxProgram($file) { $program = new \Phortress\Program($file); $program = new \TestObject($program); $program->parse(); return $program; }
<?php class Observer { private $_invoker; public function invoke($invoker) { $this->_invoker = $invoker; echo "Observer: I see you!<br />"; } } class TestObject { private $observers = []; public function doo() { echo "TestObject: I do doo!<br />"; Mage::dispatchEvent('event_name'); } } $to1 = new TestObject(); $to1->doo(); $observer = new Observer(); $to1->bind($observer); echo "Object under observation<br />"; $to1->doo(); $to1->detach($observer); echo "Observation cancelled<br />"; $to1->doo();
require_once $_test_dir . '/unit/sfContextMock.class.php'; require_once dirname(__FILE__) . '/TestObject.php'; require_once dirname(__FILE__) . '/../../../lib/helper/HelperHelper.php'; require_once dirname(__FILE__) . '/../../../lib/helper/TagHelper.php'; require_once dirname(__FILE__) . '/../../../lib/helper/FormHelper.php'; require_once dirname(__FILE__) . '/../../../lib/helper/ObjectHelper.php'; $t = new lime_test(10); // object_textarea_tag() $t->diag('object_textarea_tag()'); $obj1 = new TestObject(); $t->is(object_textarea_tag($obj1, 'getValue'), '<textarea name="value" id="value">value</textarea>'); $t->is(object_textarea_tag($obj1, 'getValue', 'size=60x10'), '<textarea name="value" id="value" rows="10" cols="60">value</textarea>'); // objects_for_select() $t->diag('objects_for_select()'); $obj1 = new TestObject(); $obj2 = new TestObject(); $obj2->setText('text2'); $obj2->setValue('value2'); $actual = objects_for_select(array($obj1, $obj2), 'getValue', 'getText', 'value'); $expected = "<option value=\"value\" selected=\"selected\">text</option>\n<option value=\"value2\">text2</option>\n"; $t->is($expected, $actual); $actual = objects_for_select(array($obj1, $obj2), 'getValue'); $expected = "<option value=\"value\">value</option>\n<option value=\"value2\">value2</option>\n"; $t->is($expected, $actual); try { $actual = objects_for_select(array($obj1, $obj2), 'getNonExistantMethod'); $t->is($expected, $actual); $t->fail(); } catch (sfViewException $e) { $t->pass(); }
public function testGetDefaultPermissions() { $object = new TestObject(); $this->assertSame(0666, $object->getPermissions()); }
public function testBadMethod() { $obj = new TestObject(); $this->setExpectedException("BadMethodCallException"); $obj->bad(); }
public function populate() { $_REQUEST['showqueries'] = 0; set_time_limit(3600); $renderer = DebugView::create(); $renderer->writeHeader(); $renderer->writeInfo("Orient Environment Builder: Do not run while logged in as a member", Director::absoluteBaseURL()); echo "<div class=\"build\">"; $numTestObjects = 100; $content .= "<br /><br />Creating {$numTestObjects} test objects.. <br />"; for ($i = 0; $i < $numTestObjects; $i++) { $rand = rand(1, 10); $testObj = new TestObject(); $testObj->Code = 'orient-test-' . $rand; $testObj->Title = 'OrientDB Test ' . $rand; $testObj->Sort = 1; $testObj->write(false, true, true); // $content .= "{$testObj->Title} <br />"; } $content .= "Creating inherited object <br />"; $child = Family_Child::create(); $child->update(array('Name' => "Name First", 'Title' => 'Child')); $result = $child->write(); $numPosts = 100; $content .= "Creating {$numPosts} posts and authors <br />"; for ($i = 0; $i < $numPosts; $i++) { $rand = rand(1, 9); $author = new Person(); $author->Name = "Person {$rand}"; $id = $author->write(); $post = new Post(); $post->Title = "Post Title {$rand}"; $post->AuthorID = $id; $post->write(); } $numArticles = 100; $content .= "Creating {$numArticles} articles and at least as many tags <br />"; for ($i = 0; $i < $numArticles; $i++) { $rand = rand(1, 999); $article = new Article(); $article->Title = "Article {$rand}"; $id = $article->write(); $range = array(1, 2); foreach ($range as $val) { $tag = new Tag(); $tag->Name = "Tag {$val}"; $tag->write(); $article->Tags()->add($tag); } } echo $content; echo "</div>"; $renderer->writeFooter(); }
public function TestObjects() { return TestObject::get()->sort('@RID', 'DESC'); }
<?php require_once __DIR__ . '/common.php'; $num = isset($argv[1]) ? $argv[1] : 1000; printf("creating %d test domain objects\n", $num); benchmark($num, function () { $rel = new TestRelationship(); $object = new TestObject(); $object->TestRel = $rel; $rel->save(); $object->save(); });
<?php require_once __DIR__ . '/common.php'; // set up the database $migrator = new \Pheasant\Migrate\Migrator(); $migrator->create('testobject', TestObject::schema()); $migrator->create('testrelationship', TestRelationship::schema()); $connection = \Pheasant::instance()->connection(); $connection->sequencePool()->initialize()->clear(); $connection->table('testobject')->truncate(); $connection->table('testrelationship')->truncate();
public function testMoveShouldCallOnceClientMoveObject() { $client = $this->mockClient(array('moveObject' => function ($expectation) { $expectation->once(); })); $object = new TestObject($client, 'file.ffffffffffffffff.FFFFFFFFFFFFFFFF!123'); $object->move('path/to/file'); }
<?php require_once __DIR__ . '/common.php'; $num = isset($argv[1]) ? $argv[1] : 1000; printf("iterating over %d domain objects\n", $num); $memory = memory_get_usage(true); $timestart = microtime(true); $objects = TestObject::find()->limit($num); $counter = 0; printf("starting with %s bytes of memory used\n", number_format($memory)); foreach ($objects as $idx => $object) { if ($idx % 100 == 0) { printf("iterating %d of %d\n", $idx, $num); } $counter++; } $elapsedMs = (microtime(true) - $timestart) * 1000; printf("iterated over %d objects in in %.2fms (%.2f/ms)\n", $counter, $elapsedMs, $counter / $elapsedMs); printf("ending with %s bytes of memory used\n", number_format($memory)); printf("used %s bytes of memory\n", number_format(memory_get_usage(true) - $memory)); printf("constructs: %d destructs: %d\n", TestObject::$constructs, TestObject::$destructs);