<commit_before><?php

namespace DelTesting\Console;

use DateTime;
use Del\Common\Config\DbCredentials;
use Del\Common\ContainerService;
use Del\Console\UserCommand;
use Del\Entity\User;
use Del\Person\Entity\Person;
use Del\Person\Service\PersonService;
use Del\Service\UserService;
use Del\UserPackage;
use Del\Value\User\State;

class UserCommandTest extends CommandTest
{

    /**
     * @var UserCommand
     */
    protected $command;

    protected function _before()
    {
        $this->command = new UserCommand();
    }

    protected function _after()
    {
        unset($this->command);
    }

    /**
     * @throws \Doctrine\ORM\ORMException
     * @throws \Doctrine\ORM\OptimisticLockException
     */
    public function testResetPass()
    {
        $container = ContainerService::getInstance()->getContainer();
        /** @var PersonService $personSvc */
        $personSvc = $container[PersonService::class];
        /** @var UserService $userSvc */
        $userSvc = $container[UserService::class];

        $person = new Person();
        $person->setFirstname('Derek');
        $person = $personSvc->savePerson($person);

        $user = new User();
        $user->setEmail('<EMAIL>');
        $user->setLastLogin(new DateTime());
        $user->setRegistrationDate(new DateTime());
        $user->setPerson($person);
        $user->setState(new State(State::STATE_ACTIVATED));

        $user = $userSvc->changePassword($user, '<PASSWORD>'); // This saves the user too

        $command = new UserCommand();
        $output = $this->runCommand($command,[
            'email' => '<EMAIL>',
            'newPassword' => '<PASSWORD>!'
        ]);

        $userSvc->deleteUser($user);
        $personSvc->deletePerson($person);

        $this->assertContains('Password changed for <EMAIL>', $output);
    }

    public function testNotFound()
    {
        $command = new UserCommand();
        $output = $this->runCommand($command,[
            'email' => '<EMAIL>',
            'newPassword' => 'irrelevant'
        ]);

        $this->assertContains('No User Found.', $output);
    }
}<commit_msg>inject service into command in test<commit_after><?php

namespace DelTesting\Console;

use DateTime;
use Del\Common\Config\DbCredentials;
use Del\Common\ContainerService;
use Del\Console\UserCommand;
use Del\Entity\User;
use Del\Person\Entity\Person;
use Del\Person\Service\PersonService;
use Del\Service\UserService;
use Del\UserPackage;
use Del\Value\User\State;

class UserCommandTest extends CommandTest
{

    /**
     * @var UserCommand
     */
    protected $command;

    protected function _before()
    {
        $this->command = new UserCommand();
    }

    protected function _after()
    {
        unset($this->command);
    }

    /**
     * @throws \Doctrine\ORM\ORMException
     * @throws \Doctrine\ORM\OptimisticLockException
     */
    public function testResetPass()
    {
        $container = ContainerService::getInstance()->getContainer();
        /** @var PersonService $personSvc */
        $personSvc = $container[PersonService::class];
        /** @var UserService $userSvc */
        $userSvc = $container[UserService::class];

        $person = new Person();
        $person->setFirstname('Derek');
        $person = $personSvc->savePerson($person);

        $user = new User();
        $user->setEmail('<EMAIL>');
        $user->setLastLogin(new DateTime());
        $user->setRegistrationDate(new DateTime());
        $user->setPerson($person);
        $user->setState(new State(State::STATE_ACTIVATED));

        $user = $userSvc->changePassword($user, 'changeme'); // This saves the user too

        $command = new UserCommand($userSvc);
        $output = $this->runCommand($command,[
            'email' => '<EMAIL>',
            'newPassword' => '<PASSWORD>!'
        ]);

        $userSvc->deleteUser($user);
        $personSvc->deletePerson($person);

        $this->assertContains('Password changed for <EMAIL>', $output);
    }

    public function testNotFound()
    {
        $command = new UserCommand();
        $output = $this->runCommand($command,[
            'email' => '<EMAIL>',
            'newPassword' => '<PASSWORD>'
        ]);

        $this->assertContains('No User Found.', $output);
    }
}
{'fraction_non_alphanumeric': 0.15184838558727187, 'fraction_numerical': 0.0, 'mean_word_length': 2.6917098445595853, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 57, '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': '3619893', 'n_tokens_mistral': 1229, 'n_tokens_neox': 1212, 'n_words': 239}