Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check that the old and new webtools_maps contexts are identical. #113

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ pipeline:
commands:
- ./vendor/bin/behat --strict
- ./vendor/bin/behat --strict --profile=static
# Check that the deprecated subcontext in webtools_maps is identical to the new context.
- ./tests/scripts/validate-subcontext-integrity.sh

debug:
image: fpfis/httpd-php-ci:7.1
Expand Down
2 changes: 1 addition & 1 deletion modules/oe_webtools_maps/oe_webtools_maps.behat.inc
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class OeWebtoolsMapsSubContext extends DrupalSubContextBase {
Assert::assertCount($count, $maps);
}
else {
Assert::assertNotEmpty($this->getWebtoolsMaps());
Assert::assertNotEmpty($maps);
}
}

Expand Down
18 changes: 18 additions & 0 deletions tests/scripts/validate-subcontext-integrity.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
#
# Ensures that the code of the deprecated subcontext of the Webtools Maps module
# is identical to the WebtoolsMapsContext.

# The new, shiny context.
SOURCE_FILE=./tests/Behat/WebtoolsMapsContext.php
# The old, deprecated subcontext.
TARGET_FILE=./modules/oe_webtools_maps/oe_webtools_maps.behat.inc

# Calculate the lines to test. We ignore everything up to the class definition
# since both files have different namespaces and class documentation.
LINE_COUNT=$(($(wc -l $SOURCE_FILE | cut -d ' ' -f1) - $(grep -n '^class WebtoolsMapsContext' $SOURCE_FILE | cut -d : -f1)))

# Check that the code inside the class is identical.
diff <(tail -n $LINE_COUNT $SOURCE_FILE) <(tail -n $LINE_COUNT $TARGET_FILE)

exit $?