本文整理汇总了PHP中ak_test_case函数的典型用法代码示例。如果您正苦于以下问题:PHP ak_test_case函数的具体用法?PHP ak_test_case怎么用?PHP ak_test_case使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ak_test_case函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_single_class
{
public function test_single_class()
{
$filename = AkConfig::getDir('fixtures') . DS . 'reflection_test_class.php';
$file = new AkReflectionFile($filename);
$this->assertEqual(1, count($file->getClasses()));
$classes = $file->getClasses();
$this->assertEqual('ReflectionTestClass1', $classes[0]->getName());
}
public function test_multiple_classes()
{
$filename = AkConfig::getDir('fixtures') . DS . 'reflection_test_classes.php';
$file = new AkReflectionFile($filename);
$this->assertEqual(2, count($file->getClasses()));
$classes = $file->getClasses();
$this->assertEqual('ReflectionTestClass1', $classes[0]->getName());
$this->assertEqual('ReflectionTestClass2', $classes[1]->getName());
}
public function test_special1()
{
$filename = AkConfig::getDir('fixtures') . DS . 'reflection_doc_block_test_class.php';
$file = new AkReflectionFile($filename);
$this->assertEqual(1, count($file->getClasses()));
$classes = $file->getClasses();
$this->assertEqual('ReflectionDocBlockTestClass', $classes[0]->getName());
$class = $classes[0];
$this->assertEqual('BaseActiveRecord', $class->getTag('ExtensionPoint'));
}
}
ak_test_case('ReflectionFile_TestCase');
示例2: test_find_should_return_appropriate_models
$this->assertEqual($OpenHouseMeeting->get('type'), 'Open house meeting');
$this->assertTrue($OpenHouseMeeting = $Event->findFirstBy('description', 'Networking event at Akelos'));
$this->assertEqual($OpenHouseMeeting->get('description'), 'Networking event at Akelos');
$this->assertEqual($OpenHouseMeeting->getType(), 'OpenHouseMeeting');
}
public function test_find_should_return_appropriate_models()
{
$Events = $this->Event->find('all');
$expected = array(1 => 'Event', 2 => 'Concert', 3 => 'OpenHouseMeeting');
foreach ($Events as $event) {
$this->assertEqual($event->getType(), $expected[$event->getId()]);
}
}
public function test_inheritance_should_lazy_load_right_model()
{
$this->installAndIncludeModels(array('Schedule' => 'id,name,event_id'));
$this->Schedule->create(array('name' => 'to OpenHouseMeeting', 'event_id' => 3));
$this->Schedule->create(array('name' => 'to Event', 'event_id' => 1));
$this->Schedule->create(array('name' => 'to Concert', 'event_id' => 2));
$scheds = $this->Schedule->find('all');
foreach ($scheds as $schedule) {
$schedule->event->load();
}
$expected = array(1 => 'OpenHouseMeeting', 2 => 'Event', 3 => 'Concert');
foreach ($scheds as $schedule) {
$this->assertEqual($schedule->event->getType(), $expected[$schedule->getId()]);
}
}
}
ak_test_case('TableInheritance_TestCase');
示例3: dirname
require_once dirname(__FILE__) . '/../config.php';
class Controller_forbidden_actions_TestCase extends AkWebTestCase
{
public $webserver_enabled;
public function __construct()
{
$this->webserver_enabled = AkConfig::getOption('webserver_enabled', false);
parent::__construct();
$this->_test_script = AkConfig::getOption('testing_url') . '/action_pack/public/index.php?ak=';
}
public function skip()
{
$this->skipIf(!$this->webserver_enabled, '[' . get_class($this) . '] Web server not enabled');
}
public function test_should_ignore_underscored_methods()
{
$this->setMaximumRedirects(0);
$this->get($this->_test_script . 'intranet/_forbidden');
$this->assertText('No action was specified');
}
public function test_should_not_allow_calling_action_controller_methods()
{
$this->setMaximumRedirects(0);
$this->get($this->_test_script . 'intranet/render');
$this->assertResponse(404);
$this->assertText('Forbidden action render called');
}
}
ak_test_case('Controller_forbidden_actions_TestCase');
示例4: AkReflectionFunction
$func = new AkReflectionFunction($string);
$func = new AkReflectionFunction($func->getDefinition());
$this->assertEqual('method2', $func->getName());
$this->assertEqual(array('test' => 1, 'test2' => 3, 'test3' => '$this->value'), $func->getDefaultOptions());
$this->assertEqual(array('test', 'test2', 'test3', 'test4'), $func->getAvailableOptions());
}
public function test_add_doc_block_tag()
{
$string = '
/**
* comment
* @return void
* @param $param1
* @param $param2
*/
public function &method2($param1,$param2) {
$default_options = array("test"=>1,
"test2"=>3,
"test3"=>$this->value);
$available_options = array("test","test2","test3","test4");
echo $default_options;
exit();
}
}';
$func = new AkReflectionFunction($string);
$func->setTag('WingsPluginInstaller', 'test');
//var_dump($func->toString());
}
}
ak_test_case('ReflectionFunction_TestCase');
示例5: test_first_level_serialization
}
public function test_first_level_serialization()
{
$bb1 = $this->Bb->create(array('name' => 'first bb', 'languages' => array('en', 'es', 'de')));
$cc1 = $this->Cc->create(array('name' => 'first cc'));
$cc2 = $this->Cc->create(array('name' => 'second cc'));
$first_cc_group = array($cc1, $cc2);
$bb1->cc->set($first_cc_group);
$bb1->save();
$this->assertFalse($bb1->isNewRecord());
$bb1retrieved = $this->Bb->find($bb1->id);
$this->assertFalse($bb1retrieved->isNewRecord());
$this->assertEqual(array('en', 'es', 'de'), $bb1retrieved->languages);
}
public function test_first_level_serialization_with_association_finder()
{
$bb1 = $this->Bb->create(array('name' => 'first bb', 'languages' => array('en', 'es', 'de')));
$cc1 = $this->Cc->create(array('name' => 'first cc'));
$cc2 = $this->Cc->create(array('name' => 'second cc'));
$first_cc_group = array($cc1, $cc2);
$bb1->cc->set($first_cc_group);
$bb1->save();
$this->assertFalse($bb1->isNewRecord());
$bb1retrieved = $this->Bb->find($bb1->id, array('include' => 'ccs'));
$this->assertFalse($bb1retrieved->isNewRecord());
$this->assertTrue(is_array($bb1retrieved->ccs));
$this->assertEqual(array('en', 'es', 'de'), $bb1retrieved->languages);
}
}
ak_test_case('Serialize_TestCase');
示例6: dirname
<?php
require_once dirname(__FILE__) . '/../router.php';
class RouteUrlencodesParameters_TestCase extends AkRouteUnitTest
{
public function testParametrizeDecodesReturnedParameters()
{
$this->withRoute('/author/:name')->get('/author/Martin+L.+Degree')->matches(array('name' => 'Martin L. Degree'));
}
public function testUrlizeEncodesGivenParameters()
{
$this->withRoute('/author/:name')->urlize(array('name' => 'Martin L. Degree'))->returns('/author/Martin+L.+Degree');
}
public function testParametrizeDecodesReturnedParametersWithFormat()
{
$this->withRoute('/author/:name.:format', array('format' => COMPULSORY))->get('/author/Martin+L.+Degree.pdf')->matches(array('name' => 'Martin L. Degree', 'format' => 'pdf'));
}
public function testUrlizeEncodesGivenParametersWithFormat()
{
$this->withRoute('/author/:name.:format', array('format' => COMPULSORY))->urlize(array('name' => 'Martin L. Degree', 'format' => 'pdf'))->returns('/author/Martin+L.+Degree.pdf');
}
}
ak_test_case('RouteUrlencodesParameters_TestCase');
示例7: array
$controller = $this->createControllerFor('index');
$controller->setLayout('application', array('only' => 'index'));
$this->expectRender(array('index.html', AkConfig::getDir('views') . DS . 'layouts/application.tpl'));
$controller->defaultRender();
}
public function testPickLayoutUnlessActionameMatches()
{
$this->createViewTemplate('index.html');
$this->createTemplate('layouts/application.tpl');
$controller = $this->createControllerFor('index');
$controller->setLayout('application', array('except' => 'index'));
$this->expectRender(array('index.html'));
$controller->defaultRender();
}
public function testPickFormatAccordingToRespondTo()
{
$this->createViewTemplate('index.xml');
$controller = $this->createControllerFor('index', 'xml');
$this->expectRender(array('index.xml'));
$controller->defaultRender();
}
public function testPickAlternativeHtmlTemplateFileWithoutTheHtmlExtension()
{
$this->createViewTemplate('index');
$controller = $this->createControllerFor('index');
$this->expectRender(array('index.html'));
$controller->defaultRender();
}
}
ak_test_case('TemplatePaths_TestCase');
示例8: dirname
require_once dirname(__FILE__) . '/../config.php';
class Controller_model_instantiation_TestCase extends AkWebTestCase
{
public function test_setup()
{
$TestSetup = new AkUnitTest();
$TestSetup->rebaseAppPaths();
$TestSetup->installAndIncludeModels(array('DummyPost' => 'id, title, body, hip_factor int, comments_count, posted_on, expires_at', 'DummyComment' => 'id,name,body,dummy_post_id,created_at'));
$this->webserver_enabled = AkConfig::getOption('webserver_enabled', false);
$this->_test_script = AkConfig::getOption('testing_url') . '/action_pack/public/index.php?ak=';
}
public function __destruct()
{
$TestSetup = new AkUnitTest();
$TestSetup->dropTables('all');
}
public function skip()
{
$this->skipIf(!AkConfig::getOption('webserver_enabled', false), '[' . get_class($this) . '] Web server not enabled');
}
public function test_should_access_public_action()
{
$this->setMaximumRedirects(0);
$this->get($this->_test_script . 'dummy_post/comments/1');
$this->assertResponse(200);
$this->assertTextMatch("1st post2nd post3rd post4th post5th post", 'Did not get expected result when calling ' . $this->_test_script . 'dummy_post/comments/1');
}
}
ak_test_case('Controller_model_instantiation_TestCase');
示例9: array
$Request = $this->partialMock('AkRequest', array('getRelativeUrlRoot'));
$Request->returnsByValue('getRelativeUrlRoot', '/subfolder');
$url = new AkUrl('/author/martin');
$url->setOptions(array('skip_relative_url_root' => false, 'relative_url_root' => '/subfolder'));
$this->assertEqual('/subfolder/author/martin', $url->path());
}
public function testUrl()
{
$url = $this->createUrl('/author');
$this->assertEqual('http://localhost/author', $url->url());
}
public function testToStringMethodDecidesIfOnlyThePathWillBeReturned()
{
$url = $this->createUrl('/author');
$this->assertEqual('http://localhost/author', "{$url}");
$url->setOptions(array('only_path' => true));
$this->assertEqual('/author', "{$url}");
}
/**
* @return AkUrl
*/
public function createUrl($path, $query = '')
{
$Request = $this->partialMock('AkRequest', array('getRelativeUrlRoot', 'getProtocol', 'getHostWithPort'), array('getRelativeUrlRoot' => '', 'getProtocol' => 'http', 'getHostWithPort' => 'localhost'));
$url = new AkUrl($path, $query);
$url->setOptions(array('relative_url_root' => '', 'protocol' => 'http', 'host' => 'localhost'));
return $this->Url = $url;
}
}
ak_test_case('Url_TestCase');
示例10: test_multilingual_getting_an_specific_locale
$this->assertEqual($Article->get('en_headline'), 'New PHP Framework re-released');
$this->assertEqual($Article->get('es_body'), 'Un equipo de programadores españoles ha re-lanzado un entorno de desarrollo para PHP...');
$this->assertEqual($Article->get('en_excerpt_limit'), 7);
}
public function test_multilingual_getting_an_specific_locale()
{
$Article = new Article();
$this->assertTrue($Article = $Article->findFirstBy('en_headline', 'New PHP Framework released'));
$this->assertEqual($Article->get('excerpt_limit', 'en'), 7);
$this->assertEqual($Article->get('excerpt_limit', 'es'), 3);
$this->assertEqual($Article->getAttribute('excerpt_limit', 'en'), 7);
$this->assertEqual($Article->getAttribute('excerpt_limit', 'es'), 3);
$this->assertEqual($Article->get('headline', 'en'), 'New PHP Framework released');
$this->assertEqual($Article->get('headline', 'es'), 'Se ha liberado un nuevo Framework para PHP');
$this->assertEqual($Article->getAttribute('headline', 'en'), 'New PHP Framework released');
$this->assertEqual($Article->getAttribute('headline', 'es'), 'Se ha liberado un nuevo Framework para PHP');
$this->assertEqual($Article->get('headline'), 'New PHP Framework released');
$this->assertEqual($Article->getAttribute('headline'), 'New PHP Framework released');
$this->assertEqual($Article->getAttributeLocales('headline'), array('en' => 'New PHP Framework released', 'es' => 'Se ha liberado un nuevo Framework para PHP'));
}
public function test_multilingual_setting_an_specific_locale()
{
$Article = new Article();
$Article->set('headline', 'Happiness on developers boost productivity', 'en');
$Article->set('headline', 'La felicidad de los programadores mejora la productivdad', 'es');
$this->assertEqual($Article->en_headline, 'Happiness on developers boost productivity');
$this->assertEqual($Article->es_headline, 'La felicidad de los programadores mejora la productivdad');
}
}
ak_test_case('I18n_TestCase');
示例11: test_for_form_tag_helpers
class FormTagHelper_TestCase extends HelperUnitTest
{
public function test_for_form_tag_helpers()
{
$Controller = new MockAkActionController($this);
$Controller->setReturnValue('urlFor', '/url/for/test');
$form_tag = new FormTagHelper();
$form_tag->setController($Controller);
$this->assertEqual($form_tag->form_tag(), '<form action="/url/for/test" method="post">');
$this->assertEqual($form_tag->form_tag(array(), array('method' => 'get')), '<form action="/url/for/test" method="get">');
$this->assertEqual($form_tag->form_tag(array(), array('multipart' => true)), '<form action="/url/for/test" enctype="multipart/form-data" method="post">');
$this->assertEqual($form_tag->end_form_tag(), '</form>');
$this->assertEqual($form_tag->start_form_tag(), '<form action="/url/for/test" method="post">');
$this->assertEqual($form_tag->select_tag('person', '<option>Bermi</option>', array('id' => 'bermi')), '<select id="bermi" name="person"><option>Bermi</option></select>');
$this->assertEqual($form_tag->text_field_tag('person', 'Bermi', array('id' => 'bermi')), '<input id="bermi" name="person" type="text" value="Bermi" />');
$this->assertEqual($form_tag->text_field_tag('person[1][name]', 'Bermi'), '<input id="person_1_name" name="person[1][name]" type="text" value="Bermi" />');
$this->assertEqual($form_tag->hidden_field_tag('person', 'Bermi', array('id' => 'bermi')), '<input id="bermi" name="person" type="hidden" value="Bermi" />');
$this->assertEqual($form_tag->file_field_tag('photo', array('id' => 'pick_photo')), '<input id="pick_photo" name="photo" type="file" />');
$this->assertEqual($form_tag->password_field_tag('password', '', array('id' => 'pass')), '<input id="pass" name="password" type="password" value="" />');
$this->assertEqual($form_tag->text_area_tag('address', 'My address', array('id' => 'address_box')), '<textarea id="address_box" name="address">My address</textarea>');
$this->assertEqual($form_tag->check_box_tag('subscribe', 'subscribed', true), '<input checked="checked" id="subscribe" name="subscribe" type="checkbox" value="subscribed" />');
$this->assertEqual($form_tag->radio_button_tag('subscribe', 'subscribed', true), '<input checked="checked" id="subscribe" name="subscribe" type="radio" value="subscribed" />');
$this->assertEqual($form_tag->submit_tag(), '<input name="commit" type="submit" value="Save changes" />');
$this->assertEqual($form_tag->submit_tag('Commit changes', array('disable_with' => "Wait'Please")), '<input name="commit" onclick="this.disabled=true;this.value=\'Wait\\\'Please\';this.form.submit();" type="submit" value="Commit changes" />');
/**
* @todo TEST FOR image_submit_tag($source, $options = array())
*/
}
}
ak_test_case('FormTagHelper_TestCase');
示例12: TestPerson
{
$Person = new TestPerson(array('first_name' => 'Alicia'));
$Person->validate();
$this->assertFalse($Person->hasErrors());
$Person = new TestPerson(array('last_name' => 'Sadurní', 'country' => 'ES'));
$Person->validate();
$this->assertEqual($Person->getErrorsOn('first_name'), $Person->getDefaultErrorMessageFor('blank'));
}
public function Test_of_isValid()
{
$Person = new TestPerson(array('country' => 'ES'));
$this->assertFalse($Person->isValid());
$this->assertEqual($Person->getErrors(), array('first_name' => array("can't be blank"), 'tos' => array("must be accepted")));
$Person->clearErrors();
$Person = $Person->findFirst(array('user_name = ?', 'bermi'));
$Person->set('tos', 0);
$this->assertFalse($Person->isValid());
$this->assertEqual($Person->getErrors(), array('email' => array("can't be blank")));
}
public function Test_of_validatesAssociated()
{
$Picture = new Picture(array('title' => 'Carlet'));
$Landlord = new Landlord();
$Landlord->test_validators = array('validatesPresenceOf' => array('name'));
$Picture->landlord->assign($Landlord);
$Picture->validatesAssociated('landlord');
$this->assertEqual($Picture->getErrorsOn('landlord'), $Picture->getDefaultErrorMessageFor('invalid'));
}
}
ak_test_case('Validations_TestCase');
示例13: array
$Comment3_1->save();
$Comment3_2->save();
$Test = $User1->findAllBy('name', 'Arno', array('order' => 'id ASC', 'include' => array('posts' => array('order' => 'id ASC', 'include' => array('comments' => array('order' => 'id ASC'))))));
$this->assertEqual($Test[0]->email, 'no-spam@bermilabs.com');
$this->assertEqual($Test[1]->email, 'no-spam2@bermilabs.com');
$this->assertEqual($Test[0]->posts[0]->title, 'Test1');
$this->assertEqual($Test[0]->posts[1]->title, 'Test2');
$this->assertEqual($Test[0]->posts[0]->comments[0]->name, 'Comment1_1');
$this->assertEqual($Test[0]->posts[0]->comments[1]->name, 'Comment1_2');
$this->assertEqual($Test[0]->posts[1]->comments[0]->name, 'Comment2_1');
$this->assertEqual($Test[0]->posts[1]->comments[1]->name, 'Comment2_2');
$this->assertEqual($Test[1]->posts[0]->title, 'Test3');
$this->assertEqual($Test[1]->posts[0]->comments[0]->name, 'Comment3_1');
$this->assertEqual($Test[1]->posts[0]->comments[1]->name, 'Comment3_2');
}
public function test_belongs_to_has_many()
{
$this->installAndIncludeModels('Many,Belong');
$hasMany = new Many();
$belongsTo = new Belong();
$many = $hasMany->create(array('name' => 'test'));
$belongs1 = $belongsTo->create(array('name' => 'belongs1'));
$belongs2 = $belongsTo->create(array('name' => 'belongs2'));
$array = array($belongs1, $belongs2);
$many->belong->set($array);
$result = $hasMany->findFirstBy('name', 'test', array('include' => 'belongs'));
$this->assertEqual(2, count($result->belongs));
}
}
ak_test_case('BelongsToFindIncludeOwner_TestCase');
示例14: test_should_establish_multiple_connections
$check_default_connection = AkDbAdapter::getInstance();
$this->assertReference($default_connection, $check_default_connection);
$this->assertReference($default_connection->connection, $check_default_connection->connection);
}
public function test_should_establish_multiple_connections()
{
$db_file_existed = false;
if (file_exists(AkConfig::getDir('config') . DS . 'database.yml')) {
$db_file_existed = true;
$db_settings = Ak::convert('yaml', 'array', AkConfig::getDir('config') . DS . 'database.yml');
}
$db_settings['sqlite_databases'] = array('database_file' => AK_TMP_DIR . DS . 'testing_sqlite_database.sqlite', 'type' => 'sqlite');
file_put_contents(AkConfig::getDir('config') . DS . 'database.yml', Ak::convert('array', 'yaml', $db_settings));
@unlink(AK_TMP_DIR . DS . 'testing_sqlite_database.sqlite');
$this->installAndIncludeModels(array('TestOtherConnection'));
Ak::import('test_other_connection');
$OtherConnection = new TestOtherConnection(array('name' => 'Delia'));
$this->assertTrue($OtherConnection->save());
$this->installAndIncludeModels(array('DummyModel' => 'id,name'));
$Dummy = new DummyModel();
$this->assertNotEqual($Dummy->getConnection(), $OtherConnection->getConnection());
unset($db_settings['sqlite_databases']);
if ($db_file_existed) {
file_put_contents(AkConfig::getDir('config') . DS . 'database.yml', Ak::convert('array', 'yaml', $db_settings));
} else {
unlink(AkConfig::getDir('config') . DS . 'database.yml');
}
}
}
ak_test_case('ConnectionHandling_TestCase', true);
示例15: test_with_relations_json
public function test_with_relations_json()
{
$person = $this->Person->create(array('first_name' => 'Hansi', 'last_name' => 'Müller', 'email' => 'hans@mueller.com'));
$person_created_at = gmdate('Y-m-d\\TH:i:s\\Z', Ak::getTimestamp($person->created_at));
$person->account->create(array('username' => 'hansi', 'password' => 'wilma'));
$account_created_at = gmdate('Y-m-d\\TH:i:s\\Z', Ak::getTimestamp($person->account->created_at));
$expected = <<<EOX
{"id":{$person->id},"first_name":"Hansi","last_name":"M\\u00fcller","email":"hans@mueller.com","created_at":"{$person_created_at}","account":{"id":{$person->account->id},"person_id":{$person->id},"username":"hansi","password":"wilma","is_enabled":0,"credit_limit":null,"firm_id":null,"reset_key":null,"created_at":"{$account_created_at}"}}
EOX;
$json = $person->toJson(array('include' => 'account'));
$this->_compareJson($expected, $json);
$person_reloaded = $person->fromJson($json);
$this->assertEqual($person->first_name, $person_reloaded->first_name);
$this->assertEqual($person->last_name, $person_reloaded->last_name);
$this->assertEqual($person->account->id, $person_reloaded->account->id);
}
private function _compareXml($expected, $given)
{
$expected = Ak::convert('xml', 'array', $expected);
$given = Ak::convert('xml', 'array', $given);
$this->assertEqual($expected, $given);
}
private function _compareJson($expected, $given)
{
$expected = json_decode($expected, true);
$given = json_decode($given, true);
$this->assertEqual($expected, $given);
}
}
ak_test_case('ConversionBetweenFormats_TestCase');