Пример #1
0
 /**
  * @test
  * @group library
  * @expectedException \Cms\Exception
  * @expectedExceptionCode 2302
  */
 public function test_exportTemplatesnippetShouldThrowQuotaExceptionAsExpected()
 {
     // ARRANGE
     ConfigHelper::mergeIntoConfig(array('quota' => array('exportAllowed' => false)));
     // ACT
     $this->business->export(ExportBusiness::EXPORT_MODE_TEMPLATESNIPPET, 'WEBSITE-ID', array());
 }
Пример #2
0
 /**
  * @test
  * @group small
  * @group library
  *
  * @dataProvider test_publishShouldCallUrlsAsExpectedProvider
  */
 public function test_publishShouldCallUrlsAsExpected($websiteId, $publishingId, $publishingFilePath, $publishConfig, $serviceUrls, $expectedToken)
 {
     // ARRANGE
     $expectedHost = 'TEST_PUBLISHER_HOST';
     $expectedEndpoints = array('publish' => array('url' => '/THIS/IS/THE/PUBLISHER/ADD/URL/', 'timeout' => 11, 'maxRedirects' => 11), 'status' => array('url' => '/THIS/IS/THE/PUBLISHER/STATUS/URL/', 'timeout' => 22, 'maxRedirects' => 22));
     ConfigHelper::removeValue(array('publisher', 'externalrukzukservice', 'hosts'));
     ConfigHelper::mergeIntoConfig(array('publisher' => array('externalrukzukservice' => array('hosts' => array($expectedHost), 'endpoint' => $expectedEndpoints))));
     $httpClientMock = $this->getHttpClientMock();
     $httpClientMock->mock_addMethodReturn('callUrl', 200, array());
     $httpClientMock->mock_addMethodReturn('callUrl', 200, array());
     $publisherMock = $this->getPublisherMock($httpClientMock);
     $publisherVersion = $publisherMock::VERSION;
     // ACT
     $actualPublishedStatus = $publisherMock->publish($websiteId, $publishingId, $publishingFilePath, $publishConfig, $serviceUrls);
     // ASSERT
     $methodCalls = $httpClientMock->mock_getMethodCalls();
     $this->assertCount(2, $methodCalls);
     // assert publish call
     $publishRequest = $expectedEndpoints['publish'];
     $publishRequest['params'] = array('data' => json_encode($publishConfig), 'client_version' => $publisherVersion, 'token' => $expectedToken, 'download_url' => $serviceUrls['download'], 'status_url' => $serviceUrls['status']);
     $this->assertHttpClientCall($methodCalls[0], array('host' => $expectedHost, 'request' => $publishRequest));
     // assert status call
     $statusRequest = $expectedEndpoints['status'];
     $statusRequest['params'] = array('client_version' => $publisherVersion, 'token' => $expectedToken, 'download_url' => $serviceUrls['download'], 'status_url' => $serviceUrls['status']);
     $this->assertHttpClientCall($methodCalls[1], array('host' => $expectedHost, 'request' => $statusRequest));
 }
Пример #3
0
 /**
  * @test
  * @group library
  */
 public function test_initSystemSuccess()
 {
     ConfigHelper::removeOwner();
     $this->getCliBusiness()->initSystem();
     $this->assertNoUsersExists();
     $this->assertNoGroupsExists();
     $this->assertMigrationsCreated();
 }
Пример #4
0
 protected function setUp()
 {
     MockManager::activateWebsiteMock();
     MockManager::activatePageMock();
     parent::setUp();
     FS::createDirIfNotExists($this->getWorkingDirectory());
     ConfigHelper::disableDefaultPageType();
 }
Пример #5
0
 /**
  * @return array
  */
 protected function setDefaultPublishDataIntoConfig()
 {
     $type = __CLASS__ . '::' . __METHOD__ . '::' . microtime();
     $defaultConfig = array('foo' => 'bar', 'bar' => 'foo', 'test' => array('active' => true));
     ConfigHelper::mergeIntoConfig(array('publisher' => array('defaultPublish' => array('type' => $type, 'config' => array($type => $defaultConfig)))));
     $defaultConfig['type'] = $type;
     return $defaultConfig;
 }
Пример #6
0
 /**
  * @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'));
 }
Пример #7
0
 /**
  * @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();
 }
Пример #8
0
 protected function _initOriginalConfig()
 {
     $this->bootstrap('config');
     // at first call, set the original config
     if (!ConfigHelper::hasOriginalConfig()) {
         ConfigHelper::setOriginalConfig(Registry::getConfig());
     }
 }
Пример #9
0
 /**
  * @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);
 }
Пример #10
0
 /**
  * @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']);
 }
Пример #11
0
 protected function setUp()
 {
     parent::setUp();
     $this->testService = new WebhostingQuotaTestWebsiteService('Website');
     // reset calls and set website count
     $this->testService->resetPhpunitTestCalls();
     // set webhosting max count quota
     ConfigHelper::mergeIntoConfig(array('quota' => array('webhosting' => array('maxCount' => $this->testWebhostingMaxCount))));
 }
Пример #12
0
 /**
  * @test
  * @group library
  */
 public function test_createUserShouldSendRegisterMailAsExpected()
 {
     ConfigHelper::mergeIntoConfig(array('user' => array('mail' => array('optin' => array('from' => array('adress' => '*****@*****.**', 'name' => 'rukzuk-testrun-init-system'))))));
     $userCreateValues = array('email' => '*****@*****.**', 'lastname' => 'phpunit_2', 'firstname' => 'test_2', 'isSuperuser' => true, 'isDeletable' => false);
     $user = $this->business->createUser($userCreateValues, true);
     $this->assertUserCreatedSuccessfully($userCreateValues, $user);
     $this->asserUserExists($user->getId(), $userCreateValues);
     $this->assertRegisterMailSend($user);
 }
Пример #13
0
 protected function setUp()
 {
     // Parent aufrufen
     parent::setUp();
     $this->config = ConfigHelper::getWritableConfig(Registry::getConfig()->screens);
     $this->config->activ = 'yes';
     $this->config->type = 'Phpimagegrabwindow';
     $this->screenshotTypeHandler = new Screenshot\Type\Phpimagegrabwindow($this->config->toArray());
 }
Пример #14
0
 protected function setUp()
 {
     parent::setUp();
     $this->testService = new WebsiteTestService('Website');
     // reset calls and set website count
     $this->testService->restPhpunitTestCalls();
     $this->testService->setPhpunitTestWebsiteCount(5);
     // set quota in config
     ConfigHelper::mergeIntoConfig(array('quota' => array('website' => array('maxCount' => 5))));
 }
Пример #15
0
 protected function setUp()
 {
     // Parent aufrufen
     parent::setUp();
     $this->screenConfig = ConfigHelper::getWritableConfig(Registry::getConfig()->screens);
     $this->screenConfig->activ = 'yes';
     // positiv Test mit gueltiger Konfiguration
     $validBase = new Screenshot\Base($this->screenConfig->toArray());
     $this->assertInstanceOf('Seitenbau\\Screenshot\\Base', $validBase);
 }
Пример #16
0
 /**
  * @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());
 }
Пример #17
0
 protected function setUp()
 {
     // Parent aufrufen
     parent::setUp();
     $this->config = ConfigHelper::getWritableConfig(Registry::getConfig()->screens);
     $this->config->activ = 'yes';
     $this->config->type = 'Systemcallwkhtmltoimage';
     $this->screenOutput = $this->config->directory . DIRECTORY_SEPARATOR . $this->screenOutputDir;
     if (!is_dir($this->screenOutput)) {
         mkdir($this->screenOutput);
     }
 }
Пример #18
0
 protected function setUp()
 {
     // Parent aufrufen
     parent::setUp();
     $this->config = ConfigHelper::getWritableConfig(Registry::getConfig()->screens);
     $this->config->externalrukzukservice->hosts = array(self::DUMMY_SERVICE_HOST);
     $this->config->externalrukzukservice->endpoint = array('status' => array('url' => self::DUMMY_ENPOINT_STATUS, 'timeout' => 100, 'maxRedirects' => 100), 'trigger' => array('url' => self::DUMMY_ENPOINT_TRIGGER, 'timeout' => 100, 'maxRedirects' => 100));
     $this->config->externalrukzukservice->options = array('status' => array('foo' => 'status'), 'trigger' => array('foo' => 'trigger'));
     $this->config->activ = 'yes';
     $this->config->type = 'Externalrukzukservice';
     $this->screenOutput = $this->config->directory . DIRECTORY_SEPARATOR . $this->screenOutputDir;
     if (!is_dir($this->screenOutput)) {
         mkdir($this->screenOutput);
     }
     ExternalrukzukserviceMock::setTestToken(self::DUMMY_TOKEN);
 }
Пример #19
0
 /**
  * @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());
     }
 }
Пример #20
0
 /**
  * @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);
     }
 }
Пример #21
0
 /**
  * @test
  * @group small
  * @group library
  */
 public function test_publish_shouldPublishAsExpected()
 {
     // ARRANGE
     ConfigHelper::mergeIntoConfig(array('publisher' => array('type' => 'standalone')));
     $websiteId = 'INTERNAL_THIS_IS_THE_WEBSITE_ID';
     $shortId = 'THIS_IS_THE_SHORT_ID';
     $publishingId = 'INTERNAL_THIS_IS_THE_PUBLISHING_ID';
     $cname = 'internal.my.live.domain.intern';
     $publishingFilePath = FS::joinPath($this->getTestFileDirectory(), 'publishing_file.zip');
     $publishConfig = array('type' => 'internal', 'cname' => $cname, 'shortId' => $shortId);
     $serviceUrls = array('download' => '/INTERNAL/service/endpoint/for/download/website/zip', 'status' => '/INTERNAL/service/endpoint/for/status/request');
     $expectedFilePathname = FS::joinPath($this->getTestFileDirectory(), 'expected_live_tree.json');
     $expectedFileTree = json_decode(FS::readContentFromFile($expectedFilePathname), true);
     $outputLiveDirectory = $this->getOutputDirectoryForShortId($shortId);
     // ACT
     $actualPublishedStatus = $this->getPublisher()->publish($websiteId, $publishingId, $publishingFilePath, $publishConfig, $serviceUrls);
     // ASSERT
     $this->assertInstanceOf('\\Cms\\Data\\PublisherStatus', $actualPublishedStatus);
     $this->assertSame($actualPublishedStatus::STATUS_FINISHED, $actualPublishedStatus->getStatus());
     $actualFileTreeAsJson = DirectoryHelper::getRecursive($outputLiveDirectory);
     $this->assertEquals($expectedFileTree, $actualFileTreeAsJson);
     $this->assertCnameLinksExists($this->getOutputDirectory(), $cname, $outputLiveDirectory);
     $this->assertDirectoryIsEmpty($this->getTempDirectory());
 }
Пример #22
0
 /**
  * @test
  * @group library
  * @expectedException \Cms\Mail\Exception
  */
 public function constructShouldReturnExceptionOnInvalidTransport()
 {
     ConfigHelper::mergeIntoConfig(array('mail' => array('transport' => 'gibtEsNicht')));
     $mail = new Mail();
 }
Пример #23
0
 /**
  * angegebener Adapter in der Config kann nicht initialisiert werden
  *
  * @test
  * @group library
  * @expectedException \Cms\Feedback\Exception
  */
 public function constructInitAdapterFailed()
 {
     ConfigHelper::mergeIntoConfig(array('feedback' => array('adapter' => 'gibtesnicht123')));
     $feedback = new Feedback(Registry::getConfig()->feedback);
 }
Пример #24
0
 protected function enableAnalytics($trackingId)
 {
     ConfigHelper::mergeIntoConfig(array('stats' => array('segmentio' => array('enabled' => 1)), 'owner' => array('trackingId' => $trackingId)));
 }
Пример #25
0
 /**
  * @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);
 }
Пример #26
0
 /**
  * disables global sets support
  */
 protected function disableGlobalSets()
 {
     ConfigHelper::disableGlobalSets();
 }
Пример #27
0
 /**
  * @param  string  $mode
  * @param  integer $value
  * @return mixed
  */
 public static function changeConfiguredLifetime($mode, $value)
 {
     $formerLifetime = Registry::getConfig()->optin->lifetime->{$mode};
     ConfigHelper::mergeIntoConfig(array('optin' => array('lifetime' => array($mode => $value))));
     \PHPUnit_Framework_Assert::assertEquals($value, Registry::getConfig()->optin->lifetime->{$mode});
     return $formerLifetime;
 }
Пример #28
0
 /**
  * @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);
 }
Пример #29
0
 /**
  * @test
  *
  * @group quota
  * @group small
  * @group dev
  */
 public function test_getDefaultMediaQuotaSuccess()
 {
     // ARRANGE
     $expectedMaxFileSize = 0;
     $expectedMaxSizePerWebsite = 0;
     ConfigHelper::removeValue(array('quota'));
     // ACT
     $quota = new Quota();
     $actualMediaQuota = $quota->getMediaQuota();
     // ASSERT
     $actualMaxFileSize = $actualMediaQuota->getMaxFileSize();
     $this->assertEquals($expectedMaxFileSize, $actualMaxFileSize);
     $actualMaxSizePerWebsite = $actualMediaQuota->getMaxSizePerWebsite();
     $this->assertEquals($expectedMaxSizePerWebsite, $actualMaxSizePerWebsite);
 }
Пример #30
0
 protected function updateConfigModuleEnableDev($enable)
 {
     // set quota in config
     ConfigHelper::mergeIntoConfig(array('quota' => array('module' => array('enableDev' => $enable))));
 }