<?php
class ZFDoctrine_Application_Resource_DoctrineTest extends PHPUnit_Framework_TestCase
{
public function setUp()
{
if (method_exists('Doctrine_Manager', 'resetInstance')) { // as of 1.2ALPHA3
Doctrine_Manager::resetInstance();
}
$this->application = new Zend_Application('testing');
$this->bootstrap = new Zend_Application_Bootstrap_Bootstrap($this->application);
Zend_Controller_Front::getInstance()->resetInstance();
}
public function testInitializationReturnsParablesApplicationResourceDoctrine()
{
$options = array();
$resource = new ZFDoctrine_Application_Resource_Doctrine($options);
$resource->setBootstrap($this->bootstrap);
$doctrine = $resource->init();
$this->assertType('ZFDoctrine_Registry', $doctrine);
}
public function testInitializationInitializesManager()
{
$options = array(
'manager' => array(
'attributes' => array(
'attr_auto_accessor_override' => false,
'attr_auto_free_query_objects' => false,
'attr_autoload_table_classes' => false,
// 'attr_cascade_saves' => true,
// 'attr_collection_class' => 'Doctrine_Collection',
// 'attr_create_tables' => true,
'attr_decimal_places' => 2,
'attr_default_column_options' => array(
'type' => 'string',
'length' => 255,
'notnull' => true,
),
'attr_default_identifier_options' => array(
'name' => '%s_id',
'type' => 'string',
'length' => 16,
),
'attr_default_param_namespace' => 'doctrine',
// 'attr_def_text_length' => 4096,
// 'attr_def_varchar_length' => 255,
'attr_emulate_database' => false,
'attr_export' => 'export_all',
'attr_fkname_format' => "%s",
'attr_hydrate_overwrite' => true,
'attr_idxname_format' => "%s_idx",
'attr_load_references' => true,
'attr_model_loading' => 'model_loading_conservative',
'attr_portability' => 'portability_none',
// 'attr_query_class' => 'Doctrine_Query',
'attr_query_limit' => 'limit_records',
'attr_quote_identifier' => false,
'attr_recursive_merge_fixtures' => false,
'attr_seqcol_name' => 'id',
'attr_seqname_format' => "%s_seq",
// 'attr_table_class' => 'Doctrine_Table',
// 'attr_tblclass_format' => "",
'attr_tblname_format' => "%s",
'attr_throw_exceptions' => true,
'attr_use_dql_callbacks' => false,
'attr_use_native_enum' => false,
'attr_validate' => 'validate_none',
),
),
);
$resource = new ZFDoctrine_Application_Resource_Doctrine($options);
$resource->setBootstrap($this->bootstrap);
$resource->init();
$reflect = new ReflectionClass('Doctrine');
$doctrineConstants = $reflect->getConstants();
$manager = Doctrine_Manager::getInstance();
foreach ($options['manager']['attributes'] as $key => $value) {
$attrIdx = $doctrineConstants[strtoupper($key)];
$attrVal = $value;
if (is_string($value)) {
$value = strtoupper($value);
if (array_key_exists($value, $doctrineConstants)) {
$attrVal = $doctrineConstants[$value];
}
}
$this->assertEquals($attrVal, $manager->getAttribute($attrIdx));
}
}
/**
* @expectedException Zend_Application_Resource_Exception
*/
public function testPassingInvalidManagerAttributeShouldRaiseException()
{
$options = array(
'manager' => array(
'attributes' => array(
'invalid' => 1,
),
),
);
$resource = new ZFDoctrine_Application_Resource_Doctrine($options);
$resource->setBootstrap($this->bootstrap);
$resource->init();
}
public function testInitializationInitializesManagerApcQueryCache()
{
if (extension_loaded('apc')) {
$options = array(
'manager' => array(
'attributes' => array(
'attr_query_cache' => array(
'driver' => 'apc',
),
),
),
);
$resource = new ZFDoctrine_Application_Resource_Doctrine($options);
$resource->setBootstrap($this->bootstrap);
$resource->init();
$manager = Doctrine_Manager::getInstance();
$cache = $manager->getAttribute(Doctrine::ATTR_QUERY_CACHE);
$this->assertThat(
$cache,
$this->isInstanceOf('Doctrine_Cache_Apc')
);
}
}
public function testInitializationInitializesManagerDbQueryCache()
{
if (extension_loaded('sqlite')) {
$options = array(
'manager' => array(
'attributes' => array(
'attr_query_cache' => array(
'driver' => 'db',
'options' => array(
'dsn' => 'sqlite::memory:',
'tableName' => 'doctrine_query_cache',
),
),
),
),
);
$resource = new ZFDoctrine_Application_Resource_Doctrine($options);
$resource->setBootstrap($this->bootstrap);
$resource->init();
$manager = Doctrine_Manager::getInstance();
$cache = $manager->getAttribute(Doctrine::ATTR_QUERY_CACHE);
$this->assertThat(
$cache,
$this->isInstanceOf('Doctrine_Cache_Db')
);
}
}
public function testInitializationInitializesManagerMemcacheQueryCache()
{
if (extension_loaded('memcache')) {
$options = array(
'manager' => array(
'attributes' => array(
'attr_query_cache' => array(
'driver' => 'memcache',
'options' => array(
'servers' => array(
'host' => 'localhost',
'port' => 11211,
'persistent' => true,
),
'compression' => false,
),
),
),
),
);
$resource = new ZFDoctrine_Application_Resource_Doctrine($options);
$resource->setBootstrap($this->bootstrap);
$resource->init();
$manager = Doctrine_Manager::getInstance();
$cache = $manager->getAttribute(Doctrine::ATTR_QUERY_CACHE);
$this->assertThat(
$cache,
$this->isInstanceOf('Doctrine_Cache_Memcache')
);
}
}
public function testInitializationInitializesManagerXcacheQueryCache()
{
if (extension_loaded('xcache')) {
$options = array(
'manager' => array(
'attributes' => array(
'attr_
没有合适的资源?快使用搜索试试~ 我知道了~
zf-doctrine, 一个Zend框架 1.x 和 Doctrine 1.2集成.zip
共53个文件
php:42个
yml:5个
phtml:2个
需积分: 9 0 下载量 35 浏览量
2019-10-11
02:54:34
上传
评论
收藏 71KB ZIP 举报
温馨提示
zf-doctrine, 一个Zend框架 1.x 和 Doctrine 1.2集成 Doctrine 1与 Zend 框架集成项目试图提供 Doctrine 1与 Zend 框架的完整集成。 以下组件属于这里集成:Zend_Application资源Zend框架模块项目支持用于 Doctrine 模型生成,迁移
资源推荐
资源详情
资源评论
收起资源包目录
zf-doctrine.zip (53个子文件)
zf-doctrine-master
library
ZFDoctrine
Tool
DoctrineProvider.php 17KB
ResponseImportListener.php 1KB
Context
DataFixturesDirectory.php 666B
MigrationsDirectory.php 664B
YamlSchemaDirectory.php 660B
SqlDirectory.php 643B
Core.php 6KB
Registry.php 2KB
View
Helper
ModelList.php 4KB
files
scripts
pagination.phtml 862B
list.phtml 2KB
Paginator
Adapter
DoctrineQuery.php 2KB
Import
Builder.php 2KB
Schema.php 5KB
ImportListener.php 707B
Application
Resource
Doctrine.php 11KB
Form
Model
Adapter
Interface.php 3KB
Doctrine.php 5KB
SubForm.php 3KB
Model.php 11KB
DoctrineException.php 2KB
Controller
Helper
ModelForm.php 4KB
tests
ZFDoctrine
CoreTest.php 2KB
_files
library
Default
Model
Group.php 74B
Base
Group.php 79B
Blog
Model
Category.php 74B
Base
Category.php 79B
models
User.php 56B
Base
User.php 70B
modules
blog
models
Post.php 66B
Base
Post.php 75B
AllTests.php 474B
Import
SchemaTest.php 4KB
_files
UnknownModule.yml 59B
InvalidZendModel.yml 59B
TwoModules.yml 702B
BuilderTest.php 5KB
Application
Resource
_files
sqlite.db 119KB
DoctrineTest.php 36KB
Form
Model
Adapter
_files
models
generated
BaseComment.php 926B
BaseUser.php 793B
BaseArticle.php 739B
User.php 123B
Comment.php 129B
Article.php 129B
DoctrineTest.php 3KB
ModelTest.php 11KB
phpunit.xml-dist 308B
TestHelper.php 878B
examples
forum.yml 927B
Zfplanet
zfplanet.yml 4KB
README.markdown 27KB
CREDITS 297B
共 53 条
- 1
资源评论
weixin_38743968
- 粉丝: 404
- 资源: 2万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功