forked from FriendsOfSymfony/FOSUserBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix issue where unserialized objects do not work
- Loading branch information
Showing
3 changed files
with
62 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the FOSUserBundle package. | ||
* | ||
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace FOS\UserBundle\Propel; | ||
|
||
class UserTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
protected function setUp() | ||
{ | ||
if (!class_exists('Propel')) { | ||
$this->markTestSkipped('Propel not installed'); | ||
} | ||
} | ||
|
||
public function testSerialize() | ||
{ | ||
$group = new Group(); | ||
$group->setName('Developers'); | ||
|
||
$user = new User(); | ||
$user->setEmail('foobar@example.com'); | ||
$user->setPassword('123456'); | ||
$user->addGroup($group); | ||
$user->save(); | ||
|
||
$userId = $user->getId(); | ||
$this->assertInternalType('int', $userId); | ||
|
||
$serialized = serialize($user); | ||
UserPeer::clearInstancePool(); | ||
$this->assertCount(0, UserPeer::$instances); | ||
|
||
$unserialized = unserialize($serialized); | ||
$fetchedUser = UserQuery::create()->findOneById($userId); | ||
|
||
$this->assertInstanceOf('FOS\UserBundle\Propel\User', $unserialized); | ||
$this->assertCount(1, UserPeer::$instances); | ||
$this->assertTrue($fetchedUser->equals($unserialized)); | ||
|
||
$this->assertCount(1, $unserialized->getGroups()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters