PHPUnit assertSame, assertEquals on not equals strings give Error " Uncaught PHP Exception Exception: "Serialization of ‘Closure’ is not allowed""

public function testTest(){
    $this->assertEquals("1", "2");   
}

This code give error

PHPUnit 9.3.10 by Sebastian Bergmann and contributors.

E                                                                   1 / 1 (100%)

Time: 00:01.793, Memory: 8.00 MB

There was 1 error:

1) MbArticleBundleTestsControllerArticleControllerAdminTest::testTest
PHPUnitFrameworkException: 2020-09-25T13:18:08+02:00 [critical] Uncaught PHP Exception Exception: "Serialization of 'Closure' is not allowed" at C:UsersUSERAppDataLocalTempPHP7D5C.tmp line 275
2020-09-25T13:18:08+02:00 [critical] Exception thrown when handling an exception (SymfonyComponentDependencyInjectionExceptionServiceNotFoundException: The "kernel" service is synthetic, it needs to be set at boot time before it can be used. at D:MY_WEBSITEvendorsymfonysymfonysrcSymfonyComponentDependencyInjectionContainer.php line 334)
PHP Fatal error:  Uncaught Exception: Serialization of 'Closure' is not allowed in C:UsersUSERAppDataLocalTempPHP7D5C.tmp:275
Stack trace:
#0 C:UsersUSERAppDataLocalTempPHP7D5C.tmp(275): serialize(Array)
#1 C:UsersUSERAppDataLocalTempPHP7D5C.tmp(740): __phpunit_run_isolated_test()
#2 {main}

Next SymfonyComponentDependencyInjectionExceptionServiceNotFoundException: The "kernel" service is synthetic, it needs to be set at boot time before it can be used. in D:MY_WEBSITEvendorsymfonysymfonysrcSymfonyComponentDependencyInjectionContainer.php:334
Stack trace:
#0 D:MY_WEBSITEvarcachetestContainerFhj8wpsappTestProjectContainer.php(4022): SymfonyComponentDependencyInjectionContainer->get('kernel', 1)
#1 D:MY_WEBSITEvarcachetestContainerFhj8wpsappTestProjectContainer.php(4125): ContainerFhj8wpsappTestProjectContainer->getTemplating_LocatorService()
#2 D:MY_WEBSITEvarcachetestContainerFhj8wpsappTestProjectContai in D:MY_WEBSITEvendorsymfonysymfonysrcSymfonyComponentDependencyInjectionContainer.php on line 334
Fatal error: Uncaught Exception: Serialization of 'Closure' is not allowed in C:UsersUSERAppDataLocalTempPHP7D5C.tmp:275
Stack trace:
#0 C:UsersUSERAppDataLocalTempPHP7D5C.tmp(275): serialize(Array)
#1 C:UsersUSERAppDataLocalTempPHP7D5C.tmp(740): __phpunit_run_isolated_test()
#2 {main}

Next SymfonyComponentDependencyInjectionExceptionServiceNotFoundException: The "kernel" service is synthetic, it needs to be set at boot time before it can be used. in D:MY_WEBSITEvendorsymfonysymfonysrcSymfonyComponentDependencyInjectionContainer.php:334
Stack trace:
#0 D:MY_WEBSITEvarcachetestContainerFhj8wpsappTestProjectContainer.php(4022): SymfonyComponentDependencyInjectionContainer->get('kernel', 1)
#1 D:MY_WEBSITEvarcachetestContainerFhj8wpsappTestProjectContainer.php(4125): ContainerFhj8wpsappTestProjectContainer->getTemplating_LocatorService()
#2 D:MY_WEBSITEvarcachetestContainerFhj8wpsappTestProjectContai in D:MY_WEBSITEvendorsymfonysymfonysrcSymfonyComponentDependencyInjectionContainer.php on line 334

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.

When strings are not equals, test give this error. But when strings are equals it pass. Only when i want to comprare strings which are not equals i get this error.
When i comprare different integers, test show failed result but without error.
Any help?

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *