Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix notices when phalcon.orm.column_renaming is 0 and implement reset() for metadata adapters #1952

Merged
merged 7 commits into from Feb 4, 2014
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Test case for #1801
  • Loading branch information
sjinks committed Feb 2, 2014
commit fa64ac982c9e78c6883c51de92658cef54e8f829
119 changes: 119 additions & 0 deletions unit-tests/Issue1801.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<?php

/*
+------------------------------------------------------------------------+
| Phalcon Framework |
+------------------------------------------------------------------------+
| Copyright (c) 2011-2012 Phalcon Team (http://www.phalconphp.com) |
+------------------------------------------------------------------------+
| This source file is subject to the New BSD License that is bundled |
| with this package in the file docs/LICENSE.txt. |
| |
| If you did not receive a copy of the license and are unable to |
| obtain it through the world-wide-web, please send an email |
| to license@phalconphp.com so we can send you a copy immediately. |
+------------------------------------------------------------------------+
| Authors: Andres Gutierrez <andres@phalconphp.com> |
| Eduar Carvajal <eduar@phalconphp.com> |
| Vladimir Kolesnikov <vladimir@extrememember.com> |
+------------------------------------------------------------------------+
*/

/**
* This test has to be in a separate file and cannot be combined with ModelsTest
*/
class Issue1801 extends PHPUnit_Framework_TestCase
{

public function __construct()
{
spl_autoload_register(array($this, 'modelsAutoloader'));
}

public function __destruct()
{
spl_autoload_unregister(array($this, 'modelsAutoloader'));
}

public function modelsAutoloader($className)
{
if (file_exists('unit-tests/models/'.$className.'.php')) {
require 'unit-tests/models/'.$className.'.php';
}
}

public function tearDown()
{
Phalcon\Mvc\Model::setup(array('columnRenaming' => true));
parent::tearDown();
}

protected function _getDI($dbService)
{
Phalcon\DI::reset();

$di = new Phalcon\DI\FactoryDefault();

$di->set('db', $dbService);
return $di;
}

public function test1801Mysql()
{
require 'unit-tests/config.db.php';
if (empty($configMysql)) {
$this->markTestSkipped("Skipped");
return;
}

$di = $this->_getDI(function(){
require 'unit-tests/config.db.php';
$db = new Phalcon\Db\Adapter\Pdo\Mysql($configMysql);
return $db;
});

$this->issue1801($di);
}

public function test1801Postgresql()
{
require 'unit-tests/config.db.php';
if (empty($configPostgresql)) {
$this->markTestSkipped("Skipped");
return;
}

$di = $this->_getDI(function(){
require 'unit-tests/config.db.php';
return new Phalcon\Db\Adapter\Pdo\Postgresql($configPostgresql);
});

$this->issue1801($di);
}

public function test1801Sqlite()
{
require 'unit-tests/config.db.php';
if (empty($configSqlite)) {
$this->markTestSkipped("Skipped");
return;
}

$di = $this->_getDI(function(){
require 'unit-tests/config.db.php';
return new Phalcon\Db\Adapter\Pdo\Sqlite($configSqlite);
});

$this->issue1801($di);
}

protected function issue1801($di)
{
Phalcon\Mvc\Model::setup(array('columnRenaming' => false));

$robot = Robots::findFirst(1);
$di->get('modelsMetadata')->reset();
$robot = Robots::findFirst(1);
}

}
2 changes: 2 additions & 0 deletions unit-tests/phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@

<!-- Image -->
<file>unit-tests/ImageTest.php</file>

<file>unit-tests/Issue1801.php</file>
</testsuite>
<testsuite name="PHPT Test Suite">
<file>unit-tests/PHPTTestSuite.php</file>
Expand Down