Skip to content

Commit

Permalink
Add test case for happy path
Browse files Browse the repository at this point in the history
  • Loading branch information
fredden committed Sep 20, 2023
1 parent 10027cd commit a957d87
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Magento2/Helpers/Commenting/PHPDocFormattingValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento2\Helpers\Commenting;

use PHP_CodeSniffer\Files\File;
Expand All @@ -18,6 +19,7 @@ class PHPDocFormattingValidator
*
* @param int $startPtr
* @param File $phpcsFile
*
* @return int
*/
public function findPHPDoc($startPtr, $phpcsFile)
Expand Down Expand Up @@ -53,6 +55,7 @@ public function findPHPDoc($startPtr, $phpcsFile)
* @param int $namePtr
* @param int $commentStartPtr
* @param array $tokens
*
* @return bool
*/
public function providesMeaning($namePtr, $commentStartPtr, $tokens)
Expand Down Expand Up @@ -113,6 +116,7 @@ public function providesMeaning($namePtr, $commentStartPtr, $tokens)
*
* @param int $commentStartPtr
* @param array $tokens
*
* @return bool
*/
public function hasDeprecatedWellFormatted($commentStartPtr, $tokens)
Expand All @@ -129,6 +133,7 @@ public function hasDeprecatedWellFormatted($commentStartPtr, $tokens)
)) {
return true;
}

return false;
}

Expand All @@ -141,6 +146,7 @@ public function hasDeprecatedWellFormatted($commentStartPtr, $tokens)
* @param string $tag
* @param int $commentStartPtr
* @param array $tokens
*
* @return int
*/
private function getTagPosition($tag, $commentStartPtr, $tokens)
Expand Down
20 changes: 20 additions & 0 deletions Magento2/Tests/Annotation/MethodAnnotationStructureUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,16 @@ class MethodAnnotationFixture
return false;
}

/**
* This deprecated function is correct even though it only contains the @deprecated tag.
*
* @deprecated This method will be removed in version 123.45.6789 without replacement
*/
public function correctBecauseOfKeywordPhraseLongVersion()
{
return false;
}

/**
* This deprecated function is correct even though it only contains the @deprecated tag.
*
Expand All @@ -389,4 +399,14 @@ class MethodAnnotationFixture
{
return false;
}

/**
* This deprecated function is correct even though it only contains the @deprecated tag.
*
* @deprecated WOW! This method will be removed in version 123.45.6789 without replacement
*/
public function alsoCorrectBecauseOfKeywordPhraseLongVersion()
{
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,14 @@ class DeprecatedButHandler

}

/**
* @deprecated This class will be removed in version 123.45.6789 without replacement
*/
class DeprecatedButHandlerLongVersion
{

}

/**
* @deprecated It's also deprecated - This class will be removed in version 1.0.0 without replacement
*/
Expand All @@ -179,3 +187,10 @@ class AlsoDeprecatedButHandler

}

/**
* @deprecated It's also deprecated - This class will be removed in version 123.45.6789 without replacement
*/
class AlsoDeprecatedButHandlerLongVersion
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,26 @@ interface DeprecatedButHandler

}

/**
* @deprecated This interface will be removed in version 123.45.6789 without replacement
*/
interface DeprecatedButHandlerLongVersion
{

}

/**
* @deprecated Yeah! This interface will be removed in version 1.0.0 without replacement
*/
interface AlsoDeprecatedButHandler
{

}

/**
* @deprecated Yeah! This interface will be removed in version 123.45.6789 without replacement
*/
interface AlsoDeprecatedButHandlerLongVersion
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ class correctlyFormattedClassMemberDocBlock
*/
protected string $deprecatedWithKeyword;

/**
* @var string
* @deprecated This property will be removed in version 123.45.6789 without replacement
*/
protected string $deprecatedWithKeywordLongVersion;

/**
* @var string
*/
Expand Down
10 changes: 10 additions & 0 deletions Magento2/Tests/Commenting/ConstantsPHPDocFormattingUnitTest.2.inc
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,18 @@ class Profiler
*/
const KEYWORD_PHRASE = false;

/**
* @deprecated This constant will be removed in version 123.45.6789 without replacement
*/
const KEYWORD_PHRASE_LONG_VERSION = false;

/**
* @deprecated It's awesome - This constant will be removed in version 1.0.0 without replacement
*/
const WITH_KEYWORD_PHRASE = false;

/**
* @deprecated It's awesome - This constant will be removed in version 123.45.6789 without replacement
*/
const WITH_KEYWORD_PHRASE_LONG_VERSION = false;
}

0 comments on commit a957d87

Please sign in to comment.