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

Replace SPOON_CHARSET by $container->getParameter('kernel.charset') #1140

Conversation

jeroendesloovere
Copy link
Member

Fixes #1138

@WouterSioen
Copy link
Member

somebody's on a roll! 👍

@jeroendesloovere
Copy link
Member Author

@WouterSioen If everybody continues to contribute its share of the pie. The symfony conversion will be over soon and w'll be able to create amazing sh*t!

@WouterSioen
Copy link
Member

You went to fast here. The tests are failing. This could give you a hint: https://travis-ci.org/forkcms/forkcms/jobs/54884901

@jeroendesloovere
Copy link
Member Author

Strange, I don't get any error in the backend. I even can use that truncate function without problems...
Could it be that Travis is wrong?

@jeroendesloovere
Copy link
Member Author

Is it possible that it fails because 'kernel.charset' is not set in any parameters files (f.e.: parameters.yml.travis)

@WouterSioen
Copy link
Member

Because it's a unit test, there is no backend model containing a container yet. I would do this: create a mock object "container" that returns 'UTF-8' when getParameter('kernel.charset') is called. Then do a "BackendModel::setContainer()" with this mock object.

If you need more info to create this, I'd be happy to help.

@WouterSioen
Copy link
Member

You could do something like this:

$containerMock = $this
    ->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')
    ->disableOriginalConstructor()
    ->getMock()
;

$containerMock->expects($this->any())
    ->method('getParameter')
    ->with('kernel.charset')
    ->will($this->returnValue('UTF-8'))
;

BackendModel::setContainer($containerMock);

Something like this should work.

@WouterSioen
Copy link
Member

Note that you should also be able to remove the defined('SPOON_CHARSET') || define('SPOON_CHARSET', 'UTF-8'); line

@WouterSioen
Copy link
Member

And in the frontend the same for frontend.

@WouterSioen
Copy link
Member

👍

@WouterSioen
Copy link
Member

I'll squash and merge this

@WouterSioen WouterSioen self-assigned this May 6, 2015
@WouterSioen
Copy link
Member

merged

@WouterSioen WouterSioen closed this May 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace SPOON_CHARSET by $container->getParameter('kernel.charset')
2 participants