{"action":"created","comment":{"url":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/comments/28064385","id":28064385,"diff_hunk":"@@ -0,0 +1,285 @@\n+<?php\n+\n+namespace spec\\Pim\\Bundle\\CatalogBundle\\Validator\\Constraints;\n+\n+use PhpSpec\\ObjectBehavior;\n+use Pim\\Bundle\\CatalogBundle\\Repository\\ProductRepositoryInterface;\n+use Pim\\Bundle\\CatalogBundle\\Validator\\Constraints\\UniqueVariantAxis;\n+use Prophecy\\Argument;\n+use Pim\\Bundle\\CatalogBundle\\Model\\ProductInterface;\n+use Pim\\Bundle\\CatalogBundle\\Manager\\ProductManager;\n+use Symfony\\Component\\Validator\\ExecutionContextInterface;\n+use Pim\\Bundle\\CatalogBundle\\Model\\GroupInterface;\n+use Pim\\Bundle\\CatalogBundle\\Model\\GroupTypeInterface;\n+use Pim\\Bundle\\CatalogBundle\\Model\\AttributeInterface;\n+use Pim\\Bundle\\CatalogBundle\\Model\\ProductValueInterface;\n+\n+class UniqueVariantAxisValidatorSpec extends ObjectBehavior\n+{\n+    function let(ProductManager $productManager, ExecutionContextInterface $context)\n+    {\n+        $this->beConstructedWith($productManager);\n+        $this->initialize($context);\n+    }\n+\n+\n+    function it_is_initializable()\n+    {\n+        $this->shouldHaveType('Pim\\Bundle\\CatalogBundle\\Validator\\Constraints\\UniqueVariantAxisValidator');\n+    }\n+\n+    function it_validates_product_with_no_groups(\n+        $context,\n+        ProductInterface $product,\n+        UniqueVariantAxis $uniqueVariantAxisConstraint\n+    ) {\n+        $product->getGroups()->willReturn(null);\n+        $context->addViolation(Argument::any(), Argument::any())\n+            ->shouldNotBeCalled();\n+\n+        $this->validate($product, $uniqueVariantAxisConstraint);\n+    }\n+\n+    function it_validates_not_variant_group(\n+        $context,\n+        GroupInterface $notVariantGroup,\n+        GroupTypeInterface $groupTypeInterface,\n+        UniqueVariantAxis $uniqueVariantAxisConstraint\n+    ) {\n+        $notVariantGroup->getType()->willReturn($groupTypeInterface);\n+        $groupTypeInterface->isVariant()->willReturn(false);\n+        $context->addViolation(Argument::any(), Argument::any())\n+            ->shouldNotBeCalled();\n+\n+        $this->validate($notVariantGroup, $uniqueVariantAxisConstraint);\n+\n+    }\n+\n+    function it_does_not_add_violation_when_validate_group_with_products_with_unique_combination_of_axis_attributes(\n+        $context,\n+        GroupInterface $tShirtVariantGroup,\n+        GroupTypeInterface $tShirtGroupType,\n+        ProductInterface $tShirt1,\n+        ProductInterface $tShirt2,\n+        AttributeInterface $sizeAttribute,\n+        AttributeInterface $colorAttribute,\n+        ProductValueInterface $sizeValue1,\n+        ProductValueInterface $sizeValue2,\n+        ProductValueInterface $colorValue1,\n+        ProductValueInterface $colorValue2,\n+        UniqueVariantAxis $uniqueVariantAxisConstraint\n+    ) {\n+        $tShirtVariantGroup->getType()->willReturn($tShirtGroupType);\n+        $tShirtGroupType->isVariant()->willReturn(true);\n+        $tShirtVariantGroup->getProducts()->willReturn([$tShirt1, $tShirt2]);\n+        $tShirtVariantGroup->getAxisAttributes()->willReturn([$sizeAttribute, $colorAttribute]);\n+        $sizeAttribute->getCode()->willReturn('size');\n+        $colorAttribute->getCode()->willReturn('color');\n+\n+        $tShirt1->getValue('size')->willReturn($sizeValue1);\n+        $tShirt1->getValue('color')->willReturn($colorValue1);\n+        $tShirt2->getValue('size')->willReturn($sizeValue2);\n+        $tShirt2->getValue('color')->willReturn($colorValue2);\n+        $sizeValue1->getOption()->willReturn('XL');\n+        $colorValue1->getOption()->willReturn('Red');\n+        $sizeValue2->getOption()->willReturn('XL');\n+        $colorValue2->getOption()->willReturn('Pink');\n+\n+        $tShirtVariantGroup->getLabel()->willReturn('Groupe TShirt');\n+\n+        $context->addViolation(Argument::any(), Argument::any())->shouldNotBeCalled();\n+\n+        $this->validate($tShirtVariantGroup, $uniqueVariantAxisConstraint);\n+\n+    }\n+\n+    function it_adds_violation_when_validating_group_containing_products_with_non_unique_combination_of_axis_attributes(\n+        $context,\n+        GroupInterface $tShirtVariantGroup,\n+        GroupTypeInterface $tShirtGroupType,\n+        ProductInterface $tShirt1,\n+        ProductInterface $tShirt2,\n+        AttributeInterface $sizeAttribute,\n+        AttributeInterface $colorAttribute,\n+        ProductValueInterface $sizeValue,\n+        ProductValueInterface $colorValue,\n+        UniqueVariantAxis $uniqueVariantAxisConstraint\n+    ) {\n+        $tShirtVariantGroup->getType()->willReturn($tShirtGroupType);\n+        $tShirtGroupType->isVariant()->willReturn(true);\n+        $tShirtVariantGroup->getProducts()->willReturn([$tShirt1, $tShirt2]);\n+        $tShirtVariantGroup->getAxisAttributes()->willReturn([$sizeAttribute, $colorAttribute]);\n+        $sizeAttribute->getCode()->willReturn('size');\n+        $colorAttribute->getCode()->willReturn('color');\n+\n+        $tShirt1->getValue('size')->willReturn($sizeValue);\n+        $tShirt1->getValue('color')->willReturn($colorValue);\n+        $tShirt2->getValue('size')->willReturn($sizeValue);\n+        $tShirt2->getValue('color')->willReturn($colorValue);\n+        $sizeValue->getOption()->willReturn('XL');\n+        $colorValue->getOption()->willReturn('Red');\n+\n+        $tShirtVariantGroup->getLabel()->willReturn('Groupe TShirt');\n+\n+        $context->addViolation(\n+            'Group \"%variant group%\" already contains another product with values \"%values%\"',\n+            array(\n+                '%variant group%' => 'Groupe TShirt',\n+                '%values%' => 'size: XL, color: Red',\n+            )\n+        )->shouldBeCalled();\n+\n+        $this->validate($tShirtVariantGroup, $uniqueVariantAxisConstraint);\n+","path":"spec/Pim/Bundle/CatalogBundle/Validator/Constraints/UniqueVariantAxisValidatorSpec.php","position":133,"original_position":133,"commit_id":"22027ae1723e4e3a9a897afd3408477321a772b8","original_commit_id":"22027ae1723e4e3a9a897afd3408477321a772b8","user":{"login":"willy-ahva","id":7206368,"avatar_url":"https://avatars.githubusercontent.com/u/7206368?v=3","gravatar_id":"","url":"https://api.github.com/users/willy-ahva","html_url":"https://github.com/willy-ahva","followers_url":"https://api.github.com/users/willy-ahva/followers","following_url":"https://api.github.com/users/willy-ahva/following{/other_user}","gists_url":"https://api.github.com/users/willy-ahva/gists{/gist_id}","starred_url":"https://api.github.com/users/willy-ahva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/willy-ahva/subscriptions","organizations_url":"https://api.github.com/users/willy-ahva/orgs","repos_url":"https://api.github.com/users/willy-ahva/repos","events_url":"https://api.github.com/users/willy-ahva/events{/privacy}","received_events_url":"https://api.github.com/users/willy-ahva/received_events","type":"User","site_admin":false},"body":"this one too","created_at":"2015-04-09T14:12:28Z","updated_at":"2015-04-09T14:12:28Z","html_url":"https://github.com/akeneo/pim-community-dev/pull/2485#discussion_r28064385","pull_request_url":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/2485","_links":{"self":{"href":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/comments/28064385"},"html":{"href":"https://github.com/akeneo/pim-community-dev/pull/2485#discussion_r28064385"},"pull_request":{"href":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/2485"}}},"pull_request":{"url":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/2485","id":32950495,"html_url":"https://github.com/akeneo/pim-community-dev/pull/2485","diff_url":"https://github.com/akeneo/pim-community-dev/pull/2485.diff","patch_url":"https://github.com/akeneo/pim-community-dev/pull/2485.patch","issue_url":"https://api.github.com/repos/akeneo/pim-community-dev/issues/2485","number":2485,"state":"open","locked":false,"title":"PIM-4037: add specs for Validator Constraints","user":{"login":"nsarradin","id":9743935,"avatar_url":"https://avatars.githubusercontent.com/u/9743935?v=3","gravatar_id":"","url":"https://api.github.com/users/nsarradin","html_url":"https://github.com/nsarradin","followers_url":"https://api.github.com/users/nsarradin/followers","following_url":"https://api.github.com/users/nsarradin/following{/other_user}","gists_url":"https://api.github.com/users/nsarradin/gists{/gist_id}","starred_url":"https://api.github.com/users/nsarradin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nsarradin/subscriptions","organizations_url":"https://api.github.com/users/nsarradin/orgs","repos_url":"https://api.github.com/users/nsarradin/repos","events_url":"https://api.github.com/users/nsarradin/events{/privacy}","received_events_url":"https://api.github.com/users/nsarradin/received_events","type":"User","site_admin":false},"body":"| Q                    | A\r\n| -------------------- | ---\r\n| Bug fix?             | N\r\n| New feature?         | N\r\n| BC breaks?           | N\r\n| CI currently passes? |\r\n| Tests pass?          | Y\r\n| Scenarios pass?      |\r\n| Checkstyle issues?*  | N\r\n| PMD issues?**        | N\r\n| Changelog updated?   | N\r\n| Fixed tickets        | PIM-4037\r\n| DB schema updated?   | N\r\n| Migration script?    | N\r\n| Doc PR               | N","created_at":"2015-04-09T12:24:27Z","updated_at":"2015-04-09T14:12:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"18ba82807c2bc76c149202a95fa0f9e252e7de7a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/2485/commits","review_comments_url":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/2485/comments","review_comment_url":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/comments{/number}","comments_url":"https://api.github.com/repos/akeneo/pim-community-dev/issues/2485/comments","statuses_url":"https://api.github.com/repos/akeneo/pim-community-dev/statuses/22027ae1723e4e3a9a897afd3408477321a772b8","head":{"label":"nsarradin:add_phpspec","ref":"add_phpspec","sha":"22027ae1723e4e3a9a897afd3408477321a772b8","user":{"login":"nsarradin","id":9743935,"avatar_url":"https://avatars.githubusercontent.com/u/9743935?v=3","gravatar_id":"","url":"https://api.github.com/users/nsarradin","html_url":"https://github.com/nsarradin","followers_url":"https://api.github.com/users/nsarradin/followers","following_url":"https://api.github.com/users/nsarradin/following{/other_user}","gists_url":"https://api.github.com/users/nsarradin/gists{/gist_id}","starred_url":"https://api.github.com/users/nsarradin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nsarradin/subscriptions","organizations_url":"https://api.github.com/users/nsarradin/orgs","repos_url":"https://api.github.com/users/nsarradin/repos","events_url":"https://api.github.com/users/nsarradin/events{/privacy}","received_events_url":"https://api.github.com/users/nsarradin/received_events","type":"User","site_admin":false},"repo":{"id":33532386,"name":"pim-community-dev","full_name":"nsarradin/pim-community-dev","owner":{"login":"nsarradin","id":9743935,"avatar_url":"https://avatars.githubusercontent.com/u/9743935?v=3","gravatar_id":"","url":"https://api.github.com/users/nsarradin","html_url":"https://github.com/nsarradin","followers_url":"https://api.github.com/users/nsarradin/followers","following_url":"https://api.github.com/users/nsarradin/following{/other_user}","gists_url":"https://api.github.com/users/nsarradin/gists{/gist_id}","starred_url":"https://api.github.com/users/nsarradin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nsarradin/subscriptions","organizations_url":"https://api.github.com/users/nsarradin/orgs","repos_url":"https://api.github.com/users/nsarradin/repos","events_url":"https://api.github.com/users/nsarradin/events{/privacy}","received_events_url":"https://api.github.com/users/nsarradin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nsarradin/pim-community-dev","description":"Akeneo PIM development repository","fork":true,"url":"https://api.github.com/repos/nsarradin/pim-community-dev","forks_url":"https://api.github.com/repos/nsarradin/pim-community-dev/forks","keys_url":"https://api.github.com/repos/nsarradin/pim-community-dev/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nsarradin/pim-community-dev/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nsarradin/pim-community-dev/teams","hooks_url":"https://api.github.com/repos/nsarradin/pim-community-dev/hooks","issue_events_url":"https://api.github.com/repos/nsarradin/pim-community-dev/issues/events{/number}","events_url":"https://api.github.com/repos/nsarradin/pim-community-dev/events","assignees_url":"https://api.github.com/repos/nsarradin/pim-community-dev/assignees{/user}","branches_url":"https://api.github.com/repos/nsarradin/pim-community-dev/branches{/branch}","tags_url":"https://api.github.com/repos/nsarradin/pim-community-dev/tags","blobs_url":"https://api.github.com/repos/nsarradin/pim-community-dev/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nsarradin/pim-community-dev/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nsarradin/pim-community-dev/git/refs{/sha}","trees_url":"https://api.github.com/repos/nsarradin/pim-community-dev/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nsarradin/pim-community-dev/statuses/{sha}","languages_url":"https://api.github.com/repos/nsarradin/pim-community-dev/languages","stargazers_url":"https://api.github.com/repos/nsarradin/pim-community-dev/stargazers","contributors_url":"https://api.github.com/repos/nsarradin/pim-community-dev/contributors","subscribers_url":"https://api.github.com/repos/nsarradin/pim-community-dev/subscribers","subscription_url":"https://api.github.com/repos/nsarradin/pim-community-dev/subscription","commits_url":"https://api.github.com/repos/nsarradin/pim-community-dev/commits{/sha}","git_commits_url":"https://api.github.com/repos/nsarradin/pim-community-dev/git/commits{/sha}","comments_url":"https://api.github.com/repos/nsarradin/pim-community-dev/comments{/number}","issue_comment_url":"https://api.github.com/repos/nsarradin/pim-community-dev/issues/comments{/number}","contents_url":"https://api.github.com/repos/nsarradin/pim-community-dev/contents/{+path}","compare_url":"https://api.github.com/repos/nsarradin/pim-community-dev/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nsarradin/pim-community-dev/merges","archive_url":"https://api.github.com/repos/nsarradin/pim-community-dev/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nsarradin/pim-community-dev/downloads","issues_url":"https://api.github.com/repos/nsarradin/pim-community-dev/issues{/number}","pulls_url":"https://api.github.com/repos/nsarradin/pim-community-dev/pulls{/number}","milestones_url":"https://api.github.com/repos/nsarradin/pim-community-dev/milestones{/number}","notifications_url":"https://api.github.com/repos/nsarradin/pim-community-dev/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nsarradin/pim-community-dev/labels{/name}","releases_url":"https://api.github.com/repos/nsarradin/pim-community-dev/releases{/id}","created_at":"2015-04-07T08:51:56Z","updated_at":"2015-04-07T08:52:03Z","pushed_at":"2015-04-09T14:00:14Z","git_url":"git://github.com/nsarradin/pim-community-dev.git","ssh_url":"git@github.com:nsarradin/pim-community-dev.git","clone_url":"https://github.com/nsarradin/pim-community-dev.git","svn_url":"https://github.com/nsarradin/pim-community-dev","homepage":"http://akeneo.com","size":64578,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"akeneo:master","ref":"master","sha":"768080e5ece5aaa7c1b3258b98108eb2506646ab","user":{"login":"akeneo","id":2510186,"avatar_url":"https://avatars.githubusercontent.com/u/2510186?v=3","gravatar_id":"","url":"https://api.github.com/users/akeneo","html_url":"https://github.com/akeneo","followers_url":"https://api.github.com/users/akeneo/followers","following_url":"https://api.github.com/users/akeneo/following{/other_user}","gists_url":"https://api.github.com/users/akeneo/gists{/gist_id}","starred_url":"https://api.github.com/users/akeneo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akeneo/subscriptions","organizations_url":"https://api.github.com/users/akeneo/orgs","repos_url":"https://api.github.com/users/akeneo/repos","events_url":"https://api.github.com/users/akeneo/events{/privacy}","received_events_url":"https://api.github.com/users/akeneo/received_events","type":"Organization","site_admin":false},"repo":{"id":5367323,"name":"pim-community-dev","full_name":"akeneo/pim-community-dev","owner":{"login":"akeneo","id":2510186,"avatar_url":"https://avatars.githubusercontent.com/u/2510186?v=3","gravatar_id":"","url":"https://api.github.com/users/akeneo","html_url":"https://github.com/akeneo","followers_url":"https://api.github.com/users/akeneo/followers","following_url":"https://api.github.com/users/akeneo/following{/other_user}","gists_url":"https://api.github.com/users/akeneo/gists{/gist_id}","starred_url":"https://api.github.com/users/akeneo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akeneo/subscriptions","organizations_url":"https://api.github.com/users/akeneo/orgs","repos_url":"https://api.github.com/users/akeneo/repos","events_url":"https://api.github.com/users/akeneo/events{/privacy}","received_events_url":"https://api.github.com/users/akeneo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/akeneo/pim-community-dev","description":"Akeneo PIM development repository","fork":false,"url":"https://api.github.com/repos/akeneo/pim-community-dev","forks_url":"https://api.github.com/repos/akeneo/pim-community-dev/forks","keys_url":"https://api.github.com/repos/akeneo/pim-community-dev/keys{/key_id}","collaborators_url":"https://api.github.com/repos/akeneo/pim-community-dev/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/akeneo/pim-community-dev/teams","hooks_url":"https://api.github.com/repos/akeneo/pim-community-dev/hooks","issue_events_url":"https://api.github.com/repos/akeneo/pim-community-dev/issues/events{/number}","events_url":"https://api.github.com/repos/akeneo/pim-community-dev/events","assignees_url":"https://api.github.com/repos/akeneo/pim-community-dev/assignees{/user}","branches_url":"https://api.github.com/repos/akeneo/pim-community-dev/branches{/branch}","tags_url":"https://api.github.com/repos/akeneo/pim-community-dev/tags","blobs_url":"https://api.github.com/repos/akeneo/pim-community-dev/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/akeneo/pim-community-dev/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/akeneo/pim-community-dev/git/refs{/sha}","trees_url":"https://api.github.com/repos/akeneo/pim-community-dev/git/trees{/sha}","statuses_url":"https://api.github.com/repos/akeneo/pim-community-dev/statuses/{sha}","languages_url":"https://api.github.com/repos/akeneo/pim-community-dev/languages","stargazers_url":"https://api.github.com/repos/akeneo/pim-community-dev/stargazers","contributors_url":"https://api.github.com/repos/akeneo/pim-community-dev/contributors","subscribers_url":"https://api.github.com/repos/akeneo/pim-community-dev/subscribers","subscription_url":"https://api.github.com/repos/akeneo/pim-community-dev/subscription","commits_url":"https://api.github.com/repos/akeneo/pim-community-dev/commits{/sha}","git_commits_url":"https://api.github.com/repos/akeneo/pim-community-dev/git/commits{/sha}","comments_url":"https://api.github.com/repos/akeneo/pim-community-dev/comments{/number}","issue_comment_url":"https://api.github.com/repos/akeneo/pim-community-dev/issues/comments{/number}","contents_url":"https://api.github.com/repos/akeneo/pim-community-dev/contents/{+path}","compare_url":"https://api.github.com/repos/akeneo/pim-community-dev/compare/{base}...{head}","merges_url":"https://api.github.com/repos/akeneo/pim-community-dev/merges","archive_url":"https://api.github.com/repos/akeneo/pim-community-dev/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/akeneo/pim-community-dev/downloads","issues_url":"https://api.github.com/repos/akeneo/pim-community-dev/issues{/number}","pulls_url":"https://api.github.com/repos/akeneo/pim-community-dev/pulls{/number}","milestones_url":"https://api.github.com/repos/akeneo/pim-community-dev/milestones{/number}","notifications_url":"https://api.github.com/repos/akeneo/pim-community-dev/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/akeneo/pim-community-dev/labels{/name}","releases_url":"https://api.github.com/repos/akeneo/pim-community-dev/releases{/id}","created_at":"2012-08-10T09:27:26Z","updated_at":"2015-04-09T12:25:30Z","pushed_at":"2015-04-09T14:08:50Z","git_url":"git://github.com/akeneo/pim-community-dev.git","ssh_url":"git@github.com:akeneo/pim-community-dev.git","clone_url":"https://github.com/akeneo/pim-community-dev.git","svn_url":"https://github.com/akeneo/pim-community-dev","homepage":"http://akeneo.com","size":159302,"stargazers_count":215,"watchers_count":215,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":102,"mirror_url":null,"open_issues_count":58,"forks":102,"open_issues":58,"watchers":215,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/2485"},"html":{"href":"https://github.com/akeneo/pim-community-dev/pull/2485"},"issue":{"href":"https://api.github.com/repos/akeneo/pim-community-dev/issues/2485"},"comments":{"href":"https://api.github.com/repos/akeneo/pim-community-dev/issues/2485/comments"},"review_comments":{"href":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/2485/comments"},"review_comment":{"href":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/2485/commits"},"statuses":{"href":"https://api.github.com/repos/akeneo/pim-community-dev/statuses/22027ae1723e4e3a9a897afd3408477321a772b8"}}}}