Spaces:
No application file
No application file
File size: 1,778 Bytes
d2897cd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
<?php
namespace Mautic\CoreBundle\Tests\Unit;
use Mautic\CoreBundle\Loader\ParameterLoader;
use PHPUnit\Framework\TestCase;
class RememberMeTest extends TestCase
{
public function testPersistentRemembermeKey(): void
{
// Ensure the defaultParameters are not statically cached.
$p1 = new ParameterLoader();
$reflectedClass = new \ReflectionClass($p1);
$reflectedClass->setStaticPropertyValue('defaultParameters', []);
// Create a kernel and set the parameterLoader to the one created above.
$k1 = new \AppKernel('test', false);
$reflectedClass = new \ReflectionClass($k1);
$prop = $reflectedClass->getProperty('parameterLoader');
$prop->setAccessible(true);
$prop->setValue($k1, $p1);
// Boot the kernel and get the value of the rememberme_key value.
$k1->boot();
$v1 = $k1->getContainer()->getParameter('mautic.rememberme_key');
// Ensure the defaultParameters are not statically cached.
$p2 = new ParameterLoader();
$reflectedClass = new \ReflectionClass($p2);
$reflectedClass->setStaticPropertyValue('defaultParameters', []);
// Create a kernel and set the parameterLoader to the one created above.
$k2 = new \AppKernel('test', false);
$reflectedClass = new \ReflectionClass($k2);
$prop = $reflectedClass->getProperty('parameterLoader');
$prop->setAccessible(true);
$prop->setValue($k2, $p2);
// Boot the kernel and get the value of the rememberme_key value.
$k2->boot();
$v2 = $k2->getContainer()->getParameter('mautic.rememberme_key');
$this->assertSame($v1, $v2);
}
}
|