Updated the tests due to the stats service changes.

pull/316/head
Ruslan Baidan 2020-07-14 11:23:52 +02:00
parent c4c1e2fc44
commit 48ef453db2
No known key found for this signature in database
GPG Key ID: 4B7724C136BF1D89
3 changed files with 78 additions and 99 deletions

122
composer.lock generated
View File

@ -497,16 +497,16 @@
}, },
{ {
"name": "doctrine/cache", "name": "doctrine/cache",
"version": "1.10.1", "version": "1.10.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/doctrine/cache.git", "url": "https://github.com/doctrine/cache.git",
"reference": "35a4a70cd94e09e2259dfae7488afc6b474ecbd3" "reference": "13e3381b25847283a91948d04640543941309727"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/doctrine/cache/zipball/35a4a70cd94e09e2259dfae7488afc6b474ecbd3", "url": "https://api.github.com/repos/doctrine/cache/zipball/13e3381b25847283a91948d04640543941309727",
"reference": "35a4a70cd94e09e2259dfae7488afc6b474ecbd3", "reference": "13e3381b25847283a91948d04640543941309727",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -589,20 +589,20 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2020-05-27T16:24:54+00:00" "time": "2020-07-07T18:54:01+00:00"
}, },
{ {
"name": "doctrine/collections", "name": "doctrine/collections",
"version": "1.6.5", "version": "1.6.6",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/doctrine/collections.git", "url": "https://github.com/doctrine/collections.git",
"reference": "fc0206348e17e530d09463fef07ba8968406cd6d" "reference": "5f0470363ff042d0057006ae7acabc5d7b5252d5"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/doctrine/collections/zipball/fc0206348e17e530d09463fef07ba8968406cd6d", "url": "https://api.github.com/repos/doctrine/collections/zipball/5f0470363ff042d0057006ae7acabc5d7b5252d5",
"reference": "fc0206348e17e530d09463fef07ba8968406cd6d", "reference": "5f0470363ff042d0057006ae7acabc5d7b5252d5",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -668,7 +668,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2020-05-25T19:24:35+00:00" "time": "2020-06-22T19:14:02+00:00"
}, },
{ {
"name": "doctrine/common", "name": "doctrine/common",
@ -4074,12 +4074,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/monarc-project/zm-client.git", "url": "https://github.com/monarc-project/zm-client.git",
"reference": "8990aadf0ceeb332cd53aa4a00c75f58a83868b2" "reference": "c1d370e2cb2ec768093ebc24321dce06d09f6dc4"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/monarc-project/zm-client/zipball/8990aadf0ceeb332cd53aa4a00c75f58a83868b2", "url": "https://api.github.com/repos/monarc-project/zm-client/zipball/c1d370e2cb2ec768093ebc24321dce06d09f6dc4",
"reference": "8990aadf0ceeb332cd53aa4a00c75f58a83868b2", "reference": "c1d370e2cb2ec768093ebc24321dce06d09f6dc4",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -4154,7 +4154,7 @@
} }
], ],
"description": "Frontoffice for monarc/monarc application", "description": "Frontoffice for monarc/monarc application",
"time": "2020-07-03T12:44:45+00:00" "time": "2020-07-14T09:04:57+00:00"
}, },
{ {
"name": "monarc/phpword", "name": "monarc/phpword",
@ -5200,16 +5200,16 @@
}, },
{ {
"name": "symfony/deprecation-contracts", "name": "symfony/deprecation-contracts",
"version": "v2.1.2", "version": "v2.1.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/deprecation-contracts.git", "url": "https://github.com/symfony/deprecation-contracts.git",
"reference": "dd99cb3a0aff6cadd2a8d7d7ed72c2161e218337" "reference": "5e20b83385a77593259c9f8beb2c43cd03b2ac14"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/dd99cb3a0aff6cadd2a8d7d7ed72c2161e218337", "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/5e20b83385a77593259c9f8beb2c43cd03b2ac14",
"reference": "dd99cb3a0aff6cadd2a8d7d7ed72c2161e218337", "reference": "5e20b83385a77593259c9f8beb2c43cd03b2ac14",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -5219,6 +5219,10 @@
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "2.1-dev" "dev-master": "2.1-dev"
},
"thanks": {
"name": "symfony/contracts",
"url": "https://github.com/symfony/contracts"
} }
}, },
"autoload": { "autoload": {
@ -5256,7 +5260,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2020-05-27T08:34:37+00:00" "time": "2020-06-06T08:49:21+00:00"
}, },
{ {
"name": "symfony/filesystem", "name": "symfony/filesystem",
@ -5941,16 +5945,16 @@
}, },
{ {
"name": "symfony/service-contracts", "name": "symfony/service-contracts",
"version": "v2.1.2", "version": "v2.1.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/service-contracts.git", "url": "https://github.com/symfony/service-contracts.git",
"reference": "66a8f0957a3ca54e4f724e49028ab19d75a8918b" "reference": "58c7475e5457c5492c26cc740cc0ad7464be9442"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/service-contracts/zipball/66a8f0957a3ca54e4f724e49028ab19d75a8918b", "url": "https://api.github.com/repos/symfony/service-contracts/zipball/58c7475e5457c5492c26cc740cc0ad7464be9442",
"reference": "66a8f0957a3ca54e4f724e49028ab19d75a8918b", "reference": "58c7475e5457c5492c26cc740cc0ad7464be9442",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -5964,6 +5968,10 @@
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "2.1-dev" "dev-master": "2.1-dev"
},
"thanks": {
"name": "symfony/contracts",
"url": "https://github.com/symfony/contracts"
} }
}, },
"autoload": { "autoload": {
@ -6009,7 +6017,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2020-05-20T17:43:50+00:00" "time": "2020-07-06T13:23:11+00:00"
}, },
{ {
"name": "symfony/string", "name": "symfony/string",
@ -6654,33 +6662,33 @@
}, },
{ {
"name": "phpspec/prophecy", "name": "phpspec/prophecy",
"version": "v1.10.3", "version": "1.11.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpspec/prophecy.git", "url": "https://github.com/phpspec/prophecy.git",
"reference": "451c3cd1418cf640de218914901e51b064abb093" "reference": "b20034be5efcdab4fb60ca3a29cba2949aead160"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/451c3cd1418cf640de218914901e51b064abb093", "url": "https://api.github.com/repos/phpspec/prophecy/zipball/b20034be5efcdab4fb60ca3a29cba2949aead160",
"reference": "451c3cd1418cf640de218914901e51b064abb093", "reference": "b20034be5efcdab4fb60ca3a29cba2949aead160",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"doctrine/instantiator": "^1.0.2", "doctrine/instantiator": "^1.2",
"php": "^5.3|^7.0", "php": "^7.2",
"phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0|^5.0", "phpdocumentor/reflection-docblock": "^5.0",
"sebastian/comparator": "^1.2.3|^2.0|^3.0|^4.0", "sebastian/comparator": "^3.0 || ^4.0",
"sebastian/recursion-context": "^1.0|^2.0|^3.0|^4.0" "sebastian/recursion-context": "^3.0 || ^4.0"
}, },
"require-dev": { "require-dev": {
"phpspec/phpspec": "^2.5 || ^3.2", "phpspec/phpspec": "^6.0",
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" "phpunit/phpunit": "^8.0"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.10.x-dev" "dev-master": "1.11.x-dev"
} }
}, },
"autoload": { "autoload": {
@ -6713,7 +6721,7 @@
"spy", "spy",
"stub" "stub"
], ],
"time": "2020-03-05T15:02:03+00:00" "time": "2020-07-08T12:44:21+00:00"
}, },
{ {
"name": "phpunit/php-code-coverage", "name": "phpunit/php-code-coverage",
@ -7066,12 +7074,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/Roave/SecurityAdvisories.git", "url": "https://github.com/Roave/SecurityAdvisories.git",
"reference": "9ec84501a85a3b0c7b260042ae81a8efb2f234ce" "reference": "881b9e4a8de3186c93904230bdf6344b685fe6a5"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/9ec84501a85a3b0c7b260042ae81a8efb2f234ce", "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/881b9e4a8de3186c93904230bdf6344b685fe6a5",
"reference": "9ec84501a85a3b0c7b260042ae81a8efb2f234ce", "reference": "881b9e4a8de3186c93904230bdf6344b685fe6a5",
"shasum": "" "shasum": ""
}, },
"conflict": { "conflict": {
@ -7140,6 +7148,7 @@
"friendsofsymfony/user-bundle": ">=1.2,<1.3.5", "friendsofsymfony/user-bundle": ">=1.2,<1.3.5",
"fuel/core": "<1.8.1", "fuel/core": "<1.8.1",
"getgrav/grav": "<1.7-beta.8", "getgrav/grav": "<1.7-beta.8",
"gos/web-socket-bundle": "<1.10.4|>=2,<2.6.1|>=3,<3.3",
"gree/jose": "<=2.2", "gree/jose": "<=2.2",
"gregwar/rst": "<1.0.3", "gregwar/rst": "<1.0.3",
"guzzlehttp/guzzle": ">=4-rc.2,<4.2.4|>=5,<5.3.1|>=6,<6.2.1", "guzzlehttp/guzzle": ">=4-rc.2,<4.2.4|>=5,<5.3.1|>=6,<6.2.1",
@ -7165,6 +7174,7 @@
"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",
"monolog/monolog": ">=1.8,<1.12", "monolog/monolog": ">=1.8,<1.12",
"namshi/jose": "<2.2", "namshi/jose": "<2.2",
"nystudio107/craft-seomatic": "<3.3",
"nzo/url-encryptor-bundle": ">=4,<4.3.2|>=5,<5.0.1", "nzo/url-encryptor-bundle": ">=4,<4.3.2|>=5,<5.0.1",
"october/october": ">=1.0.319,<1.0.467", "october/october": ">=1.0.319,<1.0.467",
"onelogin/php-saml": "<2.10.4", "onelogin/php-saml": "<2.10.4",
@ -7343,7 +7353,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2020-07-02T17:01:23+00:00" "time": "2020-07-11T19:04:25+00:00"
}, },
{ {
"name": "sebastian/code-unit-reverse-lookup", "name": "sebastian/code-unit-reverse-lookup",
@ -7962,23 +7972,23 @@
}, },
{ {
"name": "theseer/tokenizer", "name": "theseer/tokenizer",
"version": "1.1.3", "version": "1.2.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/theseer/tokenizer.git", "url": "https://github.com/theseer/tokenizer.git",
"reference": "11336f6f84e16a720dae9d8e6ed5019efa85a0f9" "reference": "75a63c33a8577608444246075ea0af0d052e452a"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/theseer/tokenizer/zipball/11336f6f84e16a720dae9d8e6ed5019efa85a0f9", "url": "https://api.github.com/repos/theseer/tokenizer/zipball/75a63c33a8577608444246075ea0af0d052e452a",
"reference": "11336f6f84e16a720dae9d8e6ed5019efa85a0f9", "reference": "75a63c33a8577608444246075ea0af0d052e452a",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"ext-dom": "*", "ext-dom": "*",
"ext-tokenizer": "*", "ext-tokenizer": "*",
"ext-xmlwriter": "*", "ext-xmlwriter": "*",
"php": "^7.0" "php": "^7.2 || ^8.0"
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
@ -7998,24 +8008,30 @@
} }
], ],
"description": "A small library for converting tokenized PHP source code into XML and potentially other formats", "description": "A small library for converting tokenized PHP source code into XML and potentially other formats",
"time": "2019-06-13T22:48:21+00:00" "funding": [
{
"url": "https://github.com/theseer",
"type": "github"
}
],
"time": "2020-07-12T23:59:07+00:00"
}, },
{ {
"name": "webmozart/assert", "name": "webmozart/assert",
"version": "1.9.0", "version": "1.9.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/webmozart/assert.git", "url": "https://github.com/webmozart/assert.git",
"reference": "9dc4f203e36f2b486149058bade43c851dd97451" "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/webmozart/assert/zipball/9dc4f203e36f2b486149058bade43c851dd97451", "url": "https://api.github.com/repos/webmozart/assert/zipball/bafc69caeb4d49c39fd0779086c03a3738cbb389",
"reference": "9dc4f203e36f2b486149058bade43c851dd97451", "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^5.3.3 || ^7.0", "php": "^5.3.3 || ^7.0 || ^8.0",
"symfony/polyfill-ctype": "^1.8" "symfony/polyfill-ctype": "^1.8"
}, },
"conflict": { "conflict": {
@ -8047,7 +8063,7 @@
"check", "check",
"validate" "validate"
], ],
"time": "2020-06-16T10:16:42+00:00" "time": "2020-07-08T17:02:28+00:00"
} }
], ],
"aliases": [ "aliases": [

View File

@ -30,8 +30,8 @@ class StatsAnrServiceTest extends AbstractIntegrationTestCase
/** @var MockHandler */ /** @var MockHandler */
private $statsApiMockHandler; private $statsApiMockHandler;
/** @var array */ /** @var string */
private $currentDateParams; private $currentDate;
/** @var StatsAnrService */ /** @var StatsAnrService */
private $statsAnrService; private $statsAnrService;
@ -50,7 +50,7 @@ class StatsAnrServiceTest extends AbstractIntegrationTestCase
{ {
parent::setUp(); parent::setUp();
$this->currentDateParams = $this->getCurrentDateParams(); $this->currentDate = (new DateTime())->format('Y-m-d');
$this->statsAnrService = $this->getApplicationServiceLocator()->get(StatsAnrService::class); $this->statsAnrService = $this->getApplicationServiceLocator()->get(StatsAnrService::class);
} }
@ -440,28 +440,11 @@ class StatsAnrServiceTest extends AbstractIntegrationTestCase
foreach ($anrUuids as $num => $anrUuid) { foreach ($anrUuids as $num => $anrUuid) {
foreach ($statsData as $data) { foreach ($statsData as $data) {
$data['anr'] = $anrUuid; $data['anr'] = $anrUuid;
$data['day'] = $this->currentDateParams['day']; $data['date'] = $this->currentDate;
$data['week'] = $this->currentDateParams['week'];
$data['month'] = $this->currentDateParams['month'];
$data['quarter'] = $this->currentDateParams['quarter'];
$data['year'] = $this->currentDateParams['year'];
$expectedStats[] = $data; $expectedStats[] = $data;
} }
} }
return json_encode($expectedStats); return json_encode($expectedStats);
} }
private function getCurrentDateParams(): array
{
$dateTime = new DateTime();
return [
'day' => (int)$dateTime->format('z') + 1,
'week' => (int)$dateTime->format('W'),
'month' => (int)$dateTime->format('m'),
'quarter' => (int)ceil($dateTime->format('m') / 3),
'year' => (int)$dateTime->format('Y'),
];
}
} }

View File

@ -2,11 +2,7 @@
{ {
"anr": "{{uuid}}", "anr": "{{uuid}}",
"type": "risk", "type": "risk",
"day": "{{day}}", "date": "{{date}}",
"week": "{{week}}",
"month": "{{month}}",
"quarter": "{{quarter}}",
"year": "{{year}}",
"data": { "data": {
"risks": { "risks": {
"current": { "current": {
@ -85,11 +81,7 @@
{ {
"anr": "{{uuid}}", "anr": "{{uuid}}",
"type": "threat", "type": "threat",
"day": "{{day}}", "date": "{{date}}",
"week": "{{week}}",
"month": "{{month}}",
"quarter": "{{quarter}}",
"year": "{{year}}",
"data": [ "data": [
{ {
"averageRate": "2.82", "averageRate": "2.82",
@ -316,11 +308,7 @@
{ {
"anr": "{{uuid}}", "anr": "{{uuid}}",
"type": "vulnerability", "type": "vulnerability",
"day": "{{day}}", "date": "{{date}}",
"week": "{{week}}",
"month": "{{month}}",
"quarter": "{{quarter}}",
"year": "{{year}}",
"data": [ "data": [
{ {
"averageRate": "4.00", "averageRate": "4.00",
@ -917,11 +905,7 @@
{ {
"anr": "{{uuid}}", "anr": "{{uuid}}",
"type": "cartography", "type": "cartography",
"day": "{{day}}", "date": "{{date}}",
"week": "{{week}}",
"month": "{{month}}",
"quarter": "{{quarter}}",
"year": "{{year}}",
"data": { "data": {
"risks": { "risks": {
"current": { "current": {
@ -1050,11 +1034,7 @@
{ {
"anr": "{{uuid}}", "anr": "{{uuid}}",
"type": "compliance", "type": "compliance",
"day": "{{day}}", "date": "{{date}}",
"week": "{{week}}",
"month": "{{month}}",
"quarter": "{{quarter}}",
"year": "{{year}}",
"data": [ "data": [
{ {
"current": [ "current": [