|
| 1 | +/* |
| 2 | + * Copyright © Magento, Inc. All rights reserved. |
| 3 | + * See COPYING.txt for license details. |
| 4 | + */ |
| 5 | + |
| 6 | +package com.magento.idea.magento2plugin.completion.xml; |
| 7 | + |
| 8 | +import com.magento.idea.magento2plugin.magento.files.CrontabXmlTemplate; |
| 9 | + |
| 10 | +public class CrontabCompletionRegistrarTest extends CompletionXmlFixtureTestCase { |
| 11 | + private static final String EXPECTED_INSTANCE = "Magento\\Catalog\\Cron\\RefreshSpecialPrices"; |
| 12 | + private static final String EXPECTED_METHOD = "execute"; |
| 13 | + private static final String WRONG_FILE_NAME = "wrong_named_crontab.xml"; |
| 14 | + |
| 15 | + /** |
| 16 | + * The `instance` attribute of the `job` tag in crontab.xml must |
| 17 | + * have completion based on PHP classes index. |
| 18 | + */ |
| 19 | + public void testCronJobInstanceMustHaveCompletion() { |
| 20 | + final String filePath = this.getFixturePath(CrontabXmlTemplate.FILE_NAME); |
| 21 | + assertCompletionContains(filePath, EXPECTED_INSTANCE); |
| 22 | + } |
| 23 | + |
| 24 | + /** |
| 25 | + * The `instance` attribute of the `job` tag in the |
| 26 | + * non crontab.xml file must not have completion. |
| 27 | + */ |
| 28 | + public void testNotCrontabXmlMustHaveNotCompletion() { |
| 29 | + final String filePath = this.getFixturePath(WRONG_FILE_NAME); |
| 30 | + assertCompletionNotShowing(filePath); |
| 31 | + } |
| 32 | + |
| 33 | + /** |
| 34 | + * The non `instance` attribute of the `job` tag in crontab.xml must |
| 35 | + * not have completion. |
| 36 | + */ |
| 37 | + public void testNotInstanceAttrMustHaveNotCompletion() { |
| 38 | + final String filePath = this.getFixturePath(CrontabXmlTemplate.FILE_NAME); |
| 39 | + assertCompletionNotShowing(filePath); |
| 40 | + } |
| 41 | + |
| 42 | + /** |
| 43 | + * The `instance` attribute that isn't in the `job` tag in crontab.xml must |
| 44 | + * not have completion. |
| 45 | + */ |
| 46 | + public void testNotJobTagMustHaveNotCompletion() { |
| 47 | + final String filePath = this.getFixturePath(CrontabXmlTemplate.FILE_NAME); |
| 48 | + assertCompletionNotShowing(filePath); |
| 49 | + } |
| 50 | + |
| 51 | + /** |
| 52 | + * The `method` attribute of the `job` tag in crontab.xml must |
| 53 | + * have completion based on PHP Job method completion provider. |
| 54 | + */ |
| 55 | + public void testCronJobMethodMustHaveCompletion() { |
| 56 | + final String filePath = this.getFixturePath(CrontabXmlTemplate.FILE_NAME); |
| 57 | + assertCompletionContains(filePath, EXPECTED_METHOD); |
| 58 | + } |
| 59 | + |
| 60 | + /** |
| 61 | + * The `method` attribute must not have completion |
| 62 | + * if it isn`t in the crontab.xml file. |
| 63 | + */ |
| 64 | + public void testNotCrontabXmlMethodMustHaveNotCompletion() { |
| 65 | + final String filePath = this.getFixturePath(WRONG_FILE_NAME); |
| 66 | + assertCompletionNotShowing(filePath); |
| 67 | + } |
| 68 | +} |
0 commit comments