<commit_before><?php

namespace Blog\DomainBundle\Tests\Service;

use Blog\DomainBundle\Service\UserService;
use Blog\DomainBundle\Tests\BaseTestCase;
use Blog\DomainBundle\Tests\Fakes\FakeUnitOfWork;
use Blog\DomainBundle\Tests\Fakes\Repository\FakeUserRepository;

class UserServiceTest extends BaseTestCase
{
	/**
	 * @var UserService
	 */
	private $service;

	protected function setUp()
	{
		$this->service = new UserService(new FakeUnitOfWork(), new FakeUserRepository());
	}

	public function testRegisterNewUserShouldBeSuccess()
	{
		$user = $this->service->register('NewUser', 'NewPassword');

		$this->assertInstanceOf('Blog\DomainBundle\Entity\User', $user);
		$this->assertGreaterThan(0, $user->getId());
	}

	public function testRegisterExistsUserShouldBeFailed()
	{
		$this->setExpectedException('Blog\DomainBundle\Exception\UserAlreadyExistsException');

		$this->service->register('login 1', 'password 1');
	}
}<commit_msg>Refactor test of UserService<commit_after><?php

namespace Blog\DomainBundle\Tests\Service;

use Blog\DomainBundle\Service\UserService;
use Blog\DomainBundle\Tests\BaseTestCase;
use Blog\DomainBundle\Tests\Fakes\FakeUnitOfWork;
use Blog\DomainBundle\Tests\Fakes\Repository\FakeUserRepository;

class UserServiceTest extends BaseTestCase
{
	/**
	 * @var UserService
	 */
	private $service;

	protected function setUp()
	{
		$this->service = new UserService(new FakeUnitOfWork(), new FakeUserRepository());
	}

	public function testRegisterNewUserShouldBeSuccess()
	{
		// act
		$user = $this->service->register('NewUser', 'NewPassword');

		// assert
		$this->assertInstanceOf('Blog\DomainBundle\Entity\User', $user);
	}

	public function testRegisterExistsUserShouldBeFailed()
	{
		// arrange
		$this->setExpectedException('Blog\DomainBundle\Exception\UserAlreadyExistsException');

		// act
		$this->service->register('login 1', 'password 1');
	}
}
{'fraction_non_alphanumeric': 0.13248542660307366, 'fraction_numerical': 0.002649708532061473, 'mean_word_length': 5.7913669064748206, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6436231', 'n_tokens_mistral': 600, 'n_tokens_neox': 562, 'n_words': 97}