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

Proposed Fix for Issue #10800 #11983

Merged
merged 1 commit into from
Jul 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions phalcon/mvc/model.zep
Original file line number Diff line number Diff line change
Expand Up @@ -4246,6 +4246,12 @@ abstract class Model implements EntityInterface, ModelInterface, ResultInterface
let relation = <RelationInterface> manager->getRelationByAlias(modelName, lowerProperty);
if typeof relation == "object" {

/*
Not fetch a relation if it is on CamelCase
*/
if isset this->{lowerProperty} && typeof this->{lowerProperty} == "object" {
return this->{lowerProperty};
}
/**
* Get the related records
*/
Expand Down
55 changes: 55 additions & 0 deletions tests/unit/Mvc/ModelTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

namespace Phalcon\Test\Unit\Mvc;

use Phalcon\Mvc\Model\Criteria;
use Phalcon\Test\Models\AlbumORama\Albums;
use Phalcon\Test\Module\UnitTest;

/**
* \Phalcon\Test\Unit\Mvc\Model\ManagerTest
* Tests the Phalcon\Mvc\Model\Manager component
*
* @copyright (c) 2011-2016 Phalcon Team
* @link http://www.phalconphp.com
* @author Andres Gutierrez <[email protected]>
* @author Serghei Iakovlev <[email protected]>
* @author Wojciech Ślawski <[email protected]>
* @package Phalcon\Test\Unit\Mvc\Model
*
* The contents of this file are 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 [email protected]
* so that we can send you a copy immediately.
*/
class ModelTest extends UnitTest
{
/**
* @var Manager
*/
private $modelsManager;


protected function _before()
{
parent::_before();
/** @var \Phalcon\Mvc\Application $app */
$app = $this->tester->getApplication();
$this->modelsManager = $app->getDI()->getShared('modelsManager');
}

public function testCamelCaseRelation()
{
$this->specify(
"CamelCase relation calls should be the same cache",
function () {
$this->modelsManager->registerNamespaceAlias('AlbumORama','Phalcon\Test\Models\AlbumORama');
$album = Albums::findFirst();
$album->artist->name = 'NotArtist';
expect($album->artist->name)->equals($album->Artist->name);
}
);
}
}