/** * @test * @group small * @group dev * @group library * * @expectedException \Cms\Dao\User\UserNotFoundException * @expectedExceptionCode 1002 */ public function test_getByIdsShouldThrowExceptionIfAtLeastOneUserNotExists() { // ARRANGE $expectedOwner = ConfigHelper::setOwner(); $dao = $this->getDao(); // ACT $actualUsers = $dao->getByIds(array($expectedOwner['id'], 'USER-NOT-EXISTS-ID')); }
/** * @test * @group small * @group dev * @group library * * @dataProvider test_getByEmailAndIgnoredIdShouldThrowExceptionIfExpectedUserNotExistsProvider * * @expectedException \Cms\Dao\User\UserNotFoundException * @expectedExceptionCode 1002 */ public function test_getByEmailAndIgnoredIdShouldThrowExceptionIfExpectedUserNotExists($ownerEmail, $ownerId, $email, $id) { // ARRANGE ConfigHelper::setOwner(array('id' => $ownerId, 'email' => $ownerEmail)); $dao = $this->getDao(); // ACT $dao->getByEmailAndIgnoredId($email, $id); }
/** * @test * @group small * @group dev * @group library * * @expectedException \Cms\Dao\User\UserIsReadOnlyException * @expactedExceptionCode 1006 */ public function test_deleteShouldThrowReadonlyException() { // ARRANGE $owner = ConfigHelper::setOwner(); $dao = $this->getDao(); // ACT $dao->delete($owner['id']); }
/** * @test * @group small * @group dev * @group library */ public function test_getByIdShouldReturnUserAsExpected() { // ARRANGE $expectedOwner = ConfigHelper::setOwner(); $dao = $this->getDao(); // ACT $actualUser = $dao->getById($expectedOwner['id']); // ASSERT $this->assertInstanceOf('\\Cms\\Data\\User', $actualUser); $this->assertEquals($expectedOwner['id'], $actualUser->getId()); }
/** * @test * @group small * @group dev * @group library */ public function test_getAllSuperusers_returnsOnlyOwnerIfNoConfigUsersExists() { // ARRANGE ConfigHelper::removeAllConfigUsers(); $expectedOwner = ConfigHelper::setOwner(); $dao = $this->getDao(); // ACT $actualAllSuperusers = $dao->getAllSuperusers(); // ASSERT $this->assertInternalType('array', $actualAllSuperusers); $this->assertCount(1, $actualAllSuperusers); $actualSuperuser = array_shift($actualAllSuperusers); $this->assertInstanceOf('\\Cms\\Data\\User', $actualSuperuser); $this->assertContains($actualSuperuser->getId(), $expectedOwner['id']); }
/** * @test * @group small * @group dev * @group library */ public function test_getAllReturnsOwnerAndConfigUsers() { // ARRANGE $expectedUsers = array(ConfigHelper::setOwner(), ConfigHelper::addConfigUser(), ConfigHelper::addConfigUser(), ConfigHelper::addConfigUser()); $expectedUserIds = array_column($expectedUsers, 'id'); $dao = $this->getDao(); // ACT $allUsers = $dao->getAll(); // ASSERT $this->assertInternalType('array', $allUsers); $this->assertCount(count($expectedUserIds), $allUsers); foreach ($allUsers as $nextUser) { $this->assertInstanceOf('\\Cms\\Data\\User', $nextUser); $this->assertContains($nextUser->getId(), $expectedUserIds); $this->assertTrue($nextUser->isReadonly()); } }
/** * @test * @group integration */ public function test_infoShouldRespondWithExpectedOwner() { // ARRANGE $ownerData = array('dashboardUrl' => 'https://dashboardUrl/', 'upgradeUrl' => 'https://upgradeUrl/'); $expectedOwner = ConfigHelper::setOwner($ownerData); $expectedUserInfo = array('id' => $expectedOwner['id'], 'lastname' => $expectedOwner['lastname'], 'firstname' => $expectedOwner['firstname'], 'email' => $expectedOwner['email'], 'language' => $expectedOwner['language'], 'superuser' => true, 'owner' => true, 'readonly' => true, 'dashboardUrl' => $expectedOwner['dashboardUrl'], 'upgradeUrl' => $expectedOwner['upgradeUrl'], 'gender' => null, 'groups' => array(), 'privilege' => array()); $this->assertSuccessfulLogin($expectedOwner['email'], '123'); // ACT $this->activateGroupCheck(); $infoRequest = '/user/info'; $this->dispatch($infoRequest); $this->deactivateGroupCheck(); // ASSERT $response = $this->getValidatedSuccessResponse(); $responseData = $response->getData(); $this->assertObjectHasAttribute('userInfo', $responseData); $actualUserInfo = get_object_vars($responseData->userInfo); ksort($expectedUserInfo); ksort($actualUserInfo); $this->assertSame($expectedUserInfo, $actualUserInfo); }
/** * @test * @group integration */ public function test_registerShouldSendOptinMailFromOwnerAdress() { // ARRANGE $expectedOwner = ConfigHelper::setOwner(); $expectedFromUser = array('email' => $expectedOwner['email'], 'name' => $expectedOwner['firstname'] . ' ' . $expectedOwner['lastname']); $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); }