Additional MVC Translator BC fixes #5692

Merged
merged 4 commits into from Jan 7, 2014

Projects

None yet

3 participants

@weierophinney
Member
  • Made MVC translator a proxy (added __call method)
  • Added a getTranslator() method to the MVC translator
  • Inject the Zend\I18n\Translator\TranslatorInterface service into the service manager if the MVC translator factory creates a new i18n Translator instance.

This PR also adds unit tests for both the MVC translator and its associated factory.

weierophinney added some commits Jan 7, 2014
@weierophinney weierophinney Make MVC translator a proxy
- Added `__call()` implementation to proxy unknown method calls to the
  underlying translator instance.
- Added a `getTranslator()` method to allow direct access to the
  underlying translator instance.
- Added unit tests for the above functionality.
1b49fce
@weierophinney weierophinney Added tests for implementations
- Ensure MVC implementation is an i18n translator implementation
- Ensure MVC implementation is a validator translator implementation
a27f5d3
@weierophinney weierophinney Added tests for TranslatorServiceFactory
- Tested all behaviors
- Added a behavior: inject the i18n TranslatorInterface service if
  created via the Translator::factory
73ad47d
@weierophinney
Member

Ping @dstockto - this PR is what will fix your issues.

@DASPRiD DASPRiD commented on the diff Jan 7, 2014
tests/ZendTest/Mvc/I18n/TranslatorTest.php
+ *
+ * @link http://github.com/zendframework/zf2 for the canonical source repository
+ * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+
+namespace ZendTest\Mvc\I18n;
+
+use PHPUnit_Framework_TestCase as TestCase;
+use Zend\Mvc\I18n\Translator;
+
+class TranslatorTest extends TestCase
+{
+ public function setUp()
+ {
+ $this->i18nTranslator = $this->getMock('Zend\I18n\Translator\Translator');
@DASPRiD
DASPRiD Jan 7, 2014 Member

Shouldn't you mock the interface instead here?

@weierophinney
weierophinney Jan 7, 2014 Member

I didn't mock the interface as, later, in one of the test methods, I mock one of the method calls (setLocale).

@DASPRiD
Member
DASPRiD commented Jan 7, 2014

Apart from the CS failues, this looks good. Approved for merging.

@weierophinney weierophinney merged commit 1ce0cc2 into zendframework:develop Jan 7, 2014
@weierophinney weierophinney deleted the weierophinney:hotfix/mvc-translator-proxy-methods branch Jan 7, 2014
@DASPRiD DASPRiD was assigned Jan 7, 2014
@dstockto
dstockto commented Jan 8, 2014

@weierophinney The new code did not fix the issue without code changes in the application, but putting
'factories' => [
'Zend\I18n\Translator\TranslatorInterface' => 'Zend\I18n\Translator\TranslatorServiceFactory',
],

in my service_manager config did get it to go back to working and translations are working again with no more fatal error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment