symfony

Testing special characters with PHP Unit

…衆ロ難τιáo~ 提交于 2021-02-07 08:20:07
问题 I am testing my controller from Symfony2 with PHPUnit and the class WebTestCase return self::$client->request( 'POST', '/withdraw', array("amount" => 130), array(),array()); $this->assertEquals( "You can withdraw up to £100.00.", $crawler->filter("#error-notification")->text()); But I get this error: Expected: "You can withdraw up to £100.00." Actual: "You can withdraw up to £100.00." The thing is that in the webpage and the source code it looks fine, so I am thinking that maybe PHPUnit is

Testing special characters with PHP Unit

十年热恋 提交于 2021-02-07 08:17:27
问题 I am testing my controller from Symfony2 with PHPUnit and the class WebTestCase return self::$client->request( 'POST', '/withdraw', array("amount" => 130), array(),array()); $this->assertEquals( "You can withdraw up to £100.00.", $crawler->filter("#error-notification")->text()); But I get this error: Expected: "You can withdraw up to £100.00." Actual: "You can withdraw up to £100.00." The thing is that in the webpage and the source code it looks fine, so I am thinking that maybe PHPUnit is

How to execute Stored Procedures with Symfony2, Doctrine2

♀尐吖头ヾ 提交于 2021-02-07 07:32:14
问题 I am using the following code: use Doctrine\ORM\Query\ResultSetMapping; ... ... ... ... $em = $this->get( 'doctrine.orm.entity_manager' ); $rsm = new ResultSetMapping(); $query = $em->createNativeQuery( 'CALL procedureName(:param1, :param2)', $rsm ) ->setParameters( array( 'param1' => 'foo', 'param2' => 'bar' ) ); $result = $query->getResult(); //$result = $query->execute(); // Also tried $em->flush(); die(var_dump($result)); I am not getting any thing in the $result parameter. Can anyone

How to use existing Symfony FormType in Sonata Admin Bundle configureFormFields?

…衆ロ難τιáo~ 提交于 2021-02-07 06:36:05
问题 SonataAdminBundle gives a method configureFormFields when you extend the Admin class. That method takes a FormMapper class. For the entity that I have created this class for, I have already built a FormType class in the typical Symfony fashion. How can I use that class instead of having to define the form properties again using the FormMapper ? 回答1: something like: public function configureFormFields(FormMapper $formMapper) { $form = new ReviewFormType(); $form->buildForm($formMapper-

Symfony - How to get username and IP address in authentication failure listener?

跟風遠走 提交于 2021-02-07 06:27:32
问题 I need to get: username ip address for each users that tries to log in to my website. There is no problem to get that information if user logged successfully but I don't know how to get IP address for failure attempts. Her's my code: app.listener.interactive_login_listener: class: AppBundle\EventListener\LogonListener arguments: ['@security.token_storage', '@doctrine.orm.entity_manager', '@security.authorization_checker', '@router', '@manager.settings'] tags: - { name: kernel.event_listener,

How to make a Twig date translatable

丶灬走出姿态 提交于 2021-02-07 06:12:38
问题 I am displaying a DateTime object in twig like this: <td>{{ transaction.getDate|date("F - d - Y") }}</td> Now I want the month to be translatable, For example April - 20 - 2012 should be displayed as: Avril - 20 - 2012 Can I do this? If so, how? I am working on Symfony2. 回答1: or use the The Intl Extension : {{ "now"|localizeddate('none', 'none', app.request.locale, "Europe/Paris", "cccc d MMMM Y") }} Will give you something like : jeudi 25 février 2016 To enable with symfony 2, add to

How to make a Twig date translatable

血红的双手。 提交于 2021-02-07 06:03:36
问题 I am displaying a DateTime object in twig like this: <td>{{ transaction.getDate|date("F - d - Y") }}</td> Now I want the month to be translatable, For example April - 20 - 2012 should be displayed as: Avril - 20 - 2012 Can I do this? If so, how? I am working on Symfony2. 回答1: or use the The Intl Extension : {{ "now"|localizeddate('none', 'none', app.request.locale, "Europe/Paris", "cccc d MMMM Y") }} Will give you something like : jeudi 25 février 2016 To enable with symfony 2, add to

Multiple files uploaded via Guzzle multipart/form-data request are not recognized by Symfony

不想你离开。 提交于 2021-02-07 03:39:59
问题 Environment: Guzzle 6 Symfony 2.3 Uploading multiple files via a Guzzle POST request should be done with a multipart request. So I configure my $options array like so: Array ( [multipart] => Array ( [0] => Array ( [name] => filename-0 [contents] => Resource id #440 [filename] => filename-0 ) [1] => Array ( [name] => filename-1 [contents] => Resource id #441 [filename] => filename-1 ) [2] => Array ( [name] => filename-2 [contents] => Resource id #442 [filename] => filename-2 ) ) [headers] =>

Multiple files uploaded via Guzzle multipart/form-data request are not recognized by Symfony

送分小仙女□ 提交于 2021-02-07 03:38:40
问题 Environment: Guzzle 6 Symfony 2.3 Uploading multiple files via a Guzzle POST request should be done with a multipart request. So I configure my $options array like so: Array ( [multipart] => Array ( [0] => Array ( [name] => filename-0 [contents] => Resource id #440 [filename] => filename-0 ) [1] => Array ( [name] => filename-1 [contents] => Resource id #441 [filename] => filename-1 ) [2] => Array ( [name] => filename-2 [contents] => Resource id #442 [filename] => filename-2 ) ) [headers] =>

How to dynamically add's collections within collections in Symfony2 form types

最后都变了- 提交于 2021-02-07 01:56:10
问题 I have 3 form types in symfony2 FaultType which is the parent of all next collections <?php namespace My\FaultBundle\Form; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilder; class FaultType extends AbstractType { public function buildForm(FormBuilder $builder, array $options) { $builder ->add('title') ->add('steps', 'collection', array( 'type' => new StepType(), 'allow_add' => true, 'prototype' => true, 'by_reference' => false, )) ->add('created') ->add('updated'