Fixed the collect stats script, starteds the tests fixes.

feature/internationalization
Ruslan Baidan 2020-11-24 10:34:26 +01:00
parent c2382b9910
commit a35fd122c0
No known key found for this signature in database
GPG Key ID: 4B7724C136BF1D89
3 changed files with 38 additions and 17 deletions

12
composer.lock generated
View File

@ -7673,12 +7673,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/Roave/SecurityAdvisories.git", "url": "https://github.com/Roave/SecurityAdvisories.git",
"reference": "4100ec7deab9f78b3b7685fedc6c9b82c15b5c76" "reference": "d005bbc89959d3f2ecfbdf2ea8125198c6f873f5"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/4100ec7deab9f78b3b7685fedc6c9b82c15b5c76", "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/d005bbc89959d3f2ecfbdf2ea8125198c6f873f5",
"reference": "4100ec7deab9f78b3b7685fedc6c9b82c15b5c76", "reference": "d005bbc89959d3f2ecfbdf2ea8125198c6f873f5",
"shasum": "" "shasum": ""
}, },
"conflict": { "conflict": {
@ -7778,7 +7778,7 @@
"magento/magento1ee": ">=1,<1.14.4.3", "magento/magento1ee": ">=1,<1.14.4.3",
"magento/product-community-edition": ">=2,<2.2.10|>=2.3,<2.3.2-p.2", "magento/product-community-edition": ">=2,<2.2.10|>=2.3,<2.3.2-p.2",
"marcwillmann/turn": "<0.3.3", "marcwillmann/turn": "<0.3.3",
"mediawiki/core": ">=1.31,<1.31.9|>=1.32,<1.32.4|>=1.33,<1.33.3|>=1.34,<1.34.3|>=1.34.99,<1.35", "mediawiki/core": ">=1.27,<1.27.6|>=1.29,<1.29.3|>=1.30,<1.30.2|>=1.31,<1.31.9|>=1.32,<1.32.6|>=1.32.99,<1.33.3|>=1.33.99,<1.34.3|>=1.34.99,<1.35",
"mittwald/typo3_forum": "<1.2.1", "mittwald/typo3_forum": "<1.2.1",
"monolog/monolog": ">=1.8,<1.12", "monolog/monolog": ">=1.8,<1.12",
"namshi/jose": "<2.2", "namshi/jose": "<2.2",
@ -7908,7 +7908,7 @@
"typo3/flow": ">=1,<1.0.4|>=1.1,<1.1.1|>=2,<2.0.1|>=2.3,<2.3.16|>=3,<3.0.10|>=3.1,<3.1.7|>=3.2,<3.2.7|>=3.3,<3.3.5", "typo3/flow": ">=1,<1.0.4|>=1.1,<1.1.1|>=2,<2.0.1|>=2.3,<2.3.16|>=3,<3.0.10|>=3.1,<3.1.7|>=3.2,<3.2.7|>=3.3,<3.3.5",
"typo3/neos": ">=1.1,<1.1.3|>=1.2,<1.2.13|>=2,<2.0.4", "typo3/neos": ">=1.1,<1.1.3|>=1.2,<1.2.13|>=2,<2.0.4",
"typo3/phar-stream-wrapper": ">=1,<2.1.1|>=3,<3.1.1", "typo3/phar-stream-wrapper": ">=1,<2.1.1|>=3,<3.1.1",
"typo3fluid/fluid": ">=2,<2.0.5|>=2.1,<2.1.4|>=2.2,<2.2.1|>=2.3,<2.3.5|>=2.4,<2.4.1|>=2.5,<2.5.5|>=2.6,<2.6.1", "typo3fluid/fluid": ">=2,<2.0.8|>=2.1,<2.1.7|>=2.2,<2.2.4|>=2.3,<2.3.7|>=2.4,<2.4.4|>=2.5,<2.5.11|>=2.6,<2.6.10",
"ua-parser/uap-php": "<3.8", "ua-parser/uap-php": "<3.8",
"usmanhalalit/pixie": "<1.0.3|>=2,<2.0.2", "usmanhalalit/pixie": "<1.0.3|>=2,<2.0.2",
"verot/class.upload.php": "<=1.0.3|>=2,<=2.0.4", "verot/class.upload.php": "<=1.0.3|>=2,<=2.0.4",
@ -7982,7 +7982,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2020-11-18T07:02:14+00:00" "time": "2020-11-19T06:02:10+00:00"
}, },
{ {
"name": "sebastian/code-unit-reverse-lookup", "name": "sebastian/code-unit-reverse-lookup",

View File

@ -5,15 +5,14 @@
for conf_file_path in /var/www/*/local.php for conf_file_path in /var/www/*/local.php
do do
config_path=$(dirname "$conf_file_path") export APP_CONF_DIR=$conf_file_path
export APP_CONF_DIR=$config_path
echo "[$(date)] Collecting stats for client: $config_path." echo "[$(date)] Collecting stats for client: $conf_file_path."
# local use: # local use:
#/home/vagrant/monarc/bin/console monarc:collect-stats >> "$config_path"/collect_stats.log #/home/vagrant/monarc/bin/console monarc:collect-stats >> "$conf_file_path"/collect_stats.log
/var/lib/monarc/fo/bin/console monarc:collect-stats >> "$config_path"/collect_stats.log /var/lib/monarc/fo/bin/console monarc:collect-stats >> "$conf_file_path"/data/collect_stats.log
echo "[$(date)] Finished." echo "[$(date)] Finished."
done done

View File

@ -17,7 +17,14 @@ use Monarc\FrontOffice\Exception\AccessForbiddenException;
use Monarc\FrontOffice\Exception\UserNotAuthorizedException; use Monarc\FrontOffice\Exception\UserNotAuthorizedException;
use Monarc\FrontOffice\Model\Entity\User; use Monarc\FrontOffice\Model\Entity\User;
use Monarc\FrontOffice\Model\Table\AnrTable; use Monarc\FrontOffice\Model\Table\AnrTable;
use Monarc\FrontOffice\Model\Table\InstanceRiskOpTable;
use Monarc\FrontOffice\Model\Table\InstanceRiskTable;
use Monarc\FrontOffice\Model\Table\ReferentialTable;
use Monarc\FrontOffice\Model\Table\ScaleTable;
use Monarc\FrontOffice\Model\Table\SettingTable; use Monarc\FrontOffice\Model\Table\SettingTable;
use Monarc\FrontOffice\Model\Table\SnapshotTable;
use Monarc\FrontOffice\Model\Table\SoaTable;
use Monarc\FrontOffice\Model\Table\UserTable;
use Monarc\FrontOffice\Stats\DataObject\StatsDataObject; use Monarc\FrontOffice\Stats\DataObject\StatsDataObject;
use Monarc\FrontOffice\Stats\Exception\StatsAlreadyCollectedException; use Monarc\FrontOffice\Stats\Exception\StatsAlreadyCollectedException;
use Monarc\FrontOffice\Stats\Provider\StatsApiProvider; use Monarc\FrontOffice\Stats\Provider\StatsApiProvider;
@ -58,17 +65,32 @@ class StatsAnrServiceTest extends AbstractIntegrationTestCase
{ {
$serviceManager->setAllowOverride(true); $serviceManager->setAllowOverride(true);
$serviceLocator = $this->getApplicationServiceLocator();
$config = ['statsApi' => ['baseUrl' => 'http://url.com', 'apiKey' => 'token12345']];
$this->statsApiMockHandler = new MockHandler(); $this->statsApiMockHandler = new MockHandler();
$statsApiProvider = new StatsApiProvider( $statsApiProvider = new StatsApiProvider($config, $this->statsApiMockHandler);
$serviceManager->get(SettingTable::class),
[],
$this->statsApiMockHandler
);
$serviceManager->setService(StatsApiProvider::class, $statsApiProvider); $serviceManager->setService(StatsApiProvider::class, $statsApiProvider);
$this->connectedUserService = $this->createMock(ConnectedUserService::class); $this->connectedUserService = $this->createMock(ConnectedUserService::class);
$serviceManager->setService(ConnectedUserService::class, $this->connectedUserService); $serviceManager->setService(ConnectedUserService::class, $this->connectedUserService);
$statsAnrService = new StatsAnrService(
$serviceLocator->get(AnrTable::class),
$serviceLocator->get(ScaleTable::class),
$serviceLocator->get(InstanceRiskTable::class),
$serviceLocator->get(InstanceRiskOpTable::class),
$serviceLocator->get(ReferentialTable::class),
$serviceLocator->get(SoaTable::class),
$serviceLocator->get(StatsApiProvider::class),
$this->connectedUserService,
$serviceLocator->get(UserTable::class),
$serviceLocator->get(SnapshotTable::class),
$serviceLocator->get(SettingTable::class),
$config
);
$serviceManager->setService(StatsAnrService::class, $statsAnrService);
$serviceManager->setAllowOverride(false); $serviceManager->setAllowOverride(false);
} }
@ -183,7 +205,7 @@ class StatsAnrServiceTest extends AbstractIntegrationTestCase
->method('getConnectedUser') ->method('getConnectedUser')
->willReturn($user); ->willReturn($user);
$this->statsAnrService->getStats(['type' => StatsDataObject::TYPE_CARTOGRAPHY]); $this->statsAnrService->getStats(['type' => StatsDataObject::TYPE_CARTOGRAPHY, 'anrs' => []]);
} }
public function testItThrowsLogicExceptionIfTypeIsNotPassed() public function testItThrowsLogicExceptionIfTypeIsNotPassed()