PHP 클래스 VersionPress\Tests\Utils\CommitAsserter

Can be used from any type of tests (Selenium, WP-CLI, ...).
파일 보기 프로젝트 열기: versionpress/versionpress

공개 메소드들

메소드 설명
__construct ( GitRepository $gitRepository, DbSchemaInfo $dbSchema, ActionsInfoProvider $actionsInfoProvider, string[] $pathPlaceholders = [] ) Create CommitAsserter to start tracking the git repo for future asserts. Should generally be called after a test setup (if there is any) and before all the actual work. Asserts follow after it.
assertBulkAction ( string $expectedAction, integer $expectedCountOfGroupedActions ) Asserts that commit is a bulk action. Asserts the action and number of grouped change info objects.
assertCleanWorkingDirectory ( )
assertCommitAction ( string $expectedAction, integer $whichCommit, boolean $regardlessOfPriority = false ) Asserts that the recorded commit if of certain type, e.g. "post/edit". By default inspects the most recent commit; if this asserter captured more commits $whichCommit specifies which commit to assert against.
assertCommitPath ( string $type, string $path, integer $whichCommit ) Asserts that commit affected some path. Paths support wildcards and two placeholders:
assertCommitPaths ( $changes, integer $whichCommit ) Calls {@link assertCommitPath} for every item of given array.
assertCommitTag ( $tagKey, $tagValue )
assertCommitsAreEquivalent ( integer $whichCommit, integer $referenceCommit ) Asserts that two commits are "equivalent". Equivalent means that they both captured the same action over the same entity and that the captured VP tags are the same set (values may differ).
assertCountOfAffectedFiles ( integer $count, integer $whichCommit ) Asserts that commit affected exact number of files (no matter the type).
assertCountOfUntrackedFiles ( $count )
assertNumCommits ( integer $numExpectedCommits ) Asserts that the number of commits made since the constructor matches the given number.
ignoreCommits ( string | string[] $action ) Ignores commits of given action(s)
reset ( )

보호된 메소드들

메소드 설명
getChangeInfo ( Commit $commit ) : ChangeInfoEnvelope | UntrackedChangeInfo

비공개 메소드들

메소드 설명
expandPath ( $path, $whichCommit ) : mixed
getCommit ( integer $whichCommit ) : Commit
getNonIgnoredCommits ( ) : Commit[] Use this to fetch all the commits since $startCommit that are not ignored.
getRevRange ( integer $whichCommit ) : string Converts $whichCommit (int) to a Git rev range

메소드 상세

__construct() 공개 메소드

Create CommitAsserter to start tracking the git repo for future asserts. Should generally be called after a test setup (if there is any) and before all the actual work. Asserts follow after it.
public __construct ( GitRepository $gitRepository, DbSchemaInfo $dbSchema, ActionsInfoProvider $actionsInfoProvider, string[] $pathPlaceholders = [] )
$gitRepository VersionPress\Git\GitRepository
$dbSchema VersionPress\Database\DbSchemaInfo
$actionsInfoProvider VersionPress\Actions\ActionsInfoProvider
$pathPlaceholders string[]

assertBulkAction() 공개 메소드

Asserts that commit is a bulk action. Asserts the action and number of grouped change info objects.
public assertBulkAction ( string $expectedAction, integer $expectedCountOfGroupedActions )
$expectedAction string Expected action, e.g., "post/edit" or "plugin/activate".
$expectedCountOfGroupedActions integer

assertCleanWorkingDirectory() 공개 메소드

assertCommitAction() 공개 메소드

Asserts that the recorded commit if of certain type, e.g. "post/edit". By default inspects the most recent commit; if this asserter captured more commits $whichCommit specifies which commit to assert against.
public assertCommitAction ( string $expectedAction, integer $whichCommit, boolean $regardlessOfPriority = false )
$expectedAction string Expected action, e.g., "post/edit" or "wordpress/update".
$whichCommit integer See $whichCommitParameter documentation. "HEAD" by default.
$regardlessOfPriority boolean By default, commit action must be the "main" one in the envelope (with the highest priority). If this param is set to true the whole envelope is searched for the given action.

assertCommitPath() 공개 메소드

- %vpdb% expands to "wp-content/vpdb" - %VPID% expands to the VPID of the committed entity - %VPID(TAG_NAME)% expands to VPID stored in given TAG_NAME Placeholders are case sensitive.
public assertCommitPath ( string $type, string $path, integer $whichCommit )
$type string Standard git "M" (modified), "A" (added), "D" (deleted) etc. or array of actions for more possibilities.
$path string Path relative to repo root. Supports wildcards, e.g. "wp-content/uploads/*", and placeholders, e.g., "%vpdb%/posts/%VPID%.ini"
$whichCommit integer See $whichCommitParameter documentation. "HEAD" by default.

assertCommitPaths() 공개 메소드

The first item in the nested array equals the type of change, the second one is the changed path.
public assertCommitPaths ( $changes, integer $whichCommit )
$changes
$whichCommit integer See $whichCommitParameter documentation. "HEAD" by default.

assertCommitTag() 공개 메소드

public assertCommitTag ( $tagKey, $tagValue )

assertCommitsAreEquivalent() 공개 메소드

When called without parameters, compares HEAD and the next most recent commit.
public assertCommitsAreEquivalent ( integer $whichCommit, integer $referenceCommit )
$whichCommit integer See $whichCommitParameter documentation. "HEAD" by default.
$referenceCommit integer See $whichCommitParameter documentation. "HEAD^" by default.

assertCountOfAffectedFiles() 공개 메소드

Asserts that commit affected exact number of files (no matter the type).
public assertCountOfAffectedFiles ( integer $count, integer $whichCommit )
$count integer Expected count of affected files.
$whichCommit integer See $whichCommitParameter documentation. "HEAD" by default.

assertCountOfUntrackedFiles() 공개 메소드

public assertCountOfUntrackedFiles ( $count )

assertNumCommits() 공개 메소드

Asserts that the number of commits made since the constructor matches the given number.
public assertNumCommits ( integer $numExpectedCommits )
$numExpectedCommits integer

getChangeInfo() 보호된 메소드

protected getChangeInfo ( Commit $commit ) : ChangeInfoEnvelope | UntrackedChangeInfo
$commit VersionPress\Git\Commit
리턴 VersionPress\ChangeInfos\ChangeInfoEnvelope | VersionPress\ChangeInfos\UntrackedChangeInfo

ignoreCommits() 공개 메소드

This is useful in tests where different number of commits might be created in different circumstances. For example, file upload will create two commits on first attempted upload ('post/create' and 'usermeta/edit') while it will only generate a single commit ('post/create') for repeated runs. In such case, if we only care about the 'post/create' action, 'usermeta/edit' can be set as ignored using this method.
public ignoreCommits ( string | string[] $action )
$action string | string[] An action like "usermeta/edit", or an array of them

reset() 공개 메소드

public reset ( )