/** * @test * @group library */ public function test_initSystemSuccess() { ConfigHelper::removeOwner(); $this->getCliBusiness()->initSystem(); $this->assertNoUsersExists(); $this->assertNoGroupsExists(); $this->assertMigrationsCreated(); }
/** * @test * @group small * @group dev * @group library * * @expectedException \Cms\Dao\User\UserNotFoundException * @expectedExceptionCode 1002 */ public function test_getOwnerShouldThrowExceptionIfOwnerNotExists() { // ARRANGE ConfigHelper::removeOwner(); $dao = $this->getDao(); // ACT $dao->getOwner(); }
/** * @test * @group small * @group dev * @group library */ public function test_getAllReturnsEmptyArrayIfOwnerNotExists() { // ARRANGE ConfigHelper::removeOwner(); $dao = $this->getDao(); // ACT $allUsers = $dao->getAll(); // ASSERT $this->assertInternalType('array', $allUsers); $this->assertEmpty($allUsers); }
/** * @test * @group small * @group dev * @group library */ public function test_getAllSuperusers_returnsOnlyConfigUsersIfOwnerNotExists() { // ARRANGE ConfigHelper::removeAllConfigUsers(); ConfigHelper::removeOwner(); $expectedSuperusers = array(ConfigHelper::addConfigUser(), ConfigHelper::addConfigUser(), ConfigHelper::addConfigUser()); $expectedSuperuserIds = array_column($expectedSuperusers, 'id'); $dao = $this->getDao(); // ACT $actualSuperusers = $dao->getAllSuperusers(); // ASSERT $this->assertInternalType('array', $actualSuperusers); $this->assertCount(count($expectedSuperusers), $actualSuperusers); foreach ($actualSuperusers as $nextUser) { $this->assertInstanceOf('\\Cms\\Data\\User', $nextUser); $this->assertContains($nextUser->getId(), $expectedSuperuserIds); } }
/** * @test * @group integration */ public function registerShouldSendOptinMailWithExpectedContent() { // ARRANGE ConfigHelper::removeOwner(); $config = Registry::getConfig(); $expectedFromUser = array('email' => $config->user->mail->optin->from->address, 'name' => $config->user->mail->optin->from->name); $userId = 'USER-reg00gc0-b7a3-4599-b396-94c8bb6c10d9-USER'; // ACT $this->dispatchWithParams('user/register', array('ids' => array($userId))); // ASSERT $this->getValidatedSuccessResponse(); $this->assertEquals(1, OptinTestHelper::getMailsCount($this->mailsFromFileTransportDirectory)); $mailsContent = OptinTestHelper::getFileMailsContent($this->mailsFromFileTransportDirectory); $actualMailContent = $mailsContent[0]; $actualOptinCode = OptinTestHelper::getOptinCodeFromMailContent($actualMailContent); $optinService = new \Cms\Service\Optin('Optin'); $optin = $optinService->getDao()->getByCode($actualOptinCode); $this->assertRegisterMailSendSuccessfully($optin, $optin->getUser(), $expectedFromUser, $actualMailContent); }
/** * @test * @group integration */ public function renewPasswordShouldSendRenewMailWithExpectedContent() { // ARRANGE ConfigHelper::removeOwner(); $config = Registry::getConfig(); $expectedFromUser = array('email' => $config->user->mail->renew->password->from->address, 'name' => $config->user->mail->renew->password->from->name); $userId = 'USER-ren00gc0-b7a3-4599-b396-94c8bb6c10d9-USER'; $userBusiness = new \Cms\Business\User('User'); $user = $userBusiness->getById($userId); $renewRequest = sprintf('/user/renewpassword/params/{"email":"%s"}', $user->getEmail()); // ACT $this->dispatch($renewRequest); // ASSERT $this->getValidatedSuccessResponse(); $this->assertEquals(1, OptinTestHelper::getMailsCount($this->mailsFromFileTransportDirectory)); $mailsContent = OptinTestHelper::getFileMailsContent($this->mailsFromFileTransportDirectory); $actualMailContent = $mailsContent[0]; $actualRenewCode = OptinTestHelper::getRenewCodeFromMailContent($actualMailContent); $optinService = new \Cms\Service\Optin('Optin'); $optin = $optinService->getDao()->getByCode($actualRenewCode); $this->assertOptinMailSendSuccessfully($optin, $user, $expectedFromUser, $actualMailContent); }