Created
November 3, 2017 08:25
-
-
Save Cyberiaaxis/62dc11295ee3a1690105421b2c467026 to your computer and use it in GitHub Desktop.
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
<?php | |
use Rockwood\Entity\User; // add this line | |
use Rockwood\Service\UserService; | |
class UserServiceTest extends \Codeception\TestCase\Test | |
{ | |
/** | |
* @var \UnitTester | |
*/ | |
protected $tester; | |
protected $controller; | |
public function testArray() | |
{ | |
$userService = new UserService(); | |
$data = array( | |
'id' => 1, | |
'email' => 'a@b.com', | |
'password' => 'whatever', | |
'username' => 'nitin', | |
// put the other fields in here too | |
); | |
$user = $userService->createFromArray($data); | |
$this->assertInstanceOf(User::class, $user); //add this line | |
$user->setEmail($data['email']); | |
$this->assertEquals('a@b.com', $user->getEmail()); | |
$user->setPassword($data['password']); | |
$this->assertEquals('whatever', $user->getPassword()); | |
$user->setId($data['id']); | |
$this->assertEquals('1', $user->getId()); | |
$user->setUsername($data['username']); | |
$this->assertEquals('nitin', $user->getUsername()); | |
// check the other fields too | |
} | |
} | |
<?php | |
namespace Rockwood\Service; | |
use Rockwood\Entity\User; | |
class UserService | |
{ | |
public function createFromArray(array $data){ | |
return new User(); | |
} | |
public function toArray(User $user){ | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment