Skip to content

Commit

Permalink
Adding in submodules and corresponding scripts. (#354)
Browse files Browse the repository at this point in the history
* Adding in submodules and corresponding scripts.

* Adding CI style fixer

* Removing spaces
  • Loading branch information
BKorenek authored Jul 15, 2020
1 parent c01aade commit 87a92e2
Show file tree
Hide file tree
Showing 25 changed files with 85 additions and 66 deletions.
6 changes: 6 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ commands:
description: "Build the project."
steps:
- pull-merge
- run:
name: Add in submodules
command: git submodule update --init
- run:
name: Run style fixer
command: bin/ci-style-fixer
- run:
name: Initialize docker .env
command: bin/init/init_docker_env.sh
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "submodules"]
path = submodules
url = [email protected]:Medology/submodules.git
25 changes: 0 additions & 25 deletions .php_cs.dist

This file was deleted.

1 change: 1 addition & 0 deletions .php_cs.dist
1 change: 1 addition & 0 deletions bin/ci-style-fixer
1 change: 1 addition & 0 deletions bin/get_colors
1 change: 1 addition & 0 deletions bin/get_images
1 change: 1 addition & 0 deletions bin/get_local_user
1 change: 1 addition & 0 deletions bin/get_tty
1 change: 1 addition & 0 deletions bin/gherkin-cs-fixer
1 change: 1 addition & 0 deletions bin/init_git_hooks
8 changes: 8 additions & 0 deletions bin/init_project
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,11 @@ echo "Installing Composer..."

echo "Installing Composer dependencies with out dev..."
composer install --no-interaction --no-suggest

if [[ ! "$CI" == 'true' ]]; then
echo "Initializing git hooks..."
"$ROOT"/bin/init_git_hooks

echo "Initializing submodules..."
git submodule update --init
fi
1 change: 1 addition & 0 deletions bin/php-cs-fixer
1 change: 1 addition & 0 deletions bin/prettier-eslint
1 change: 1 addition & 0 deletions bin/style-fixer
1 change: 1 addition & 0 deletions hooks/pre-commit
18 changes: 10 additions & 8 deletions src/Medology/Behat/CsvContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,11 @@ public function assertThingIsCSVWithRows($key, TableNode $table)
/**
* Asserts that required CSV headers are present.
*
* @param string[] $required the headers that are required to be present.
* @param string[] $actual the headers that are actually present.
* @param string $csvName The name of the CSV (for the exception message).
* @throws Exception if any of the required headers are not present.
* @param string[] $required the headers that are required to be present
* @param string[] $actual the headers that are actually present
* @param string $csvName the name of the CSV (for the exception message)
*
* @throws Exception if any of the required headers are not present
*/
private function assertHeadersArePresent(array $required, array $actual, $csvName)
{
Expand All @@ -105,10 +106,11 @@ private function assertHeadersArePresent(array $required, array $actual, $csvNam
/**
* Asserts that no additional CSV headers are present.
*
* @param string[] $required the headers that are required to be present.
* @param string[] $actual the headers that are actually present.
* @param string $csvName The name of the CSV (for the exception message).
* @throws Exception if any additional headers are present.
* @param string[] $required the headers that are required to be present
* @param string[] $actual the headers that are actually present
* @param string $csvName the name of the CSV (for the exception message)
*
* @throws Exception if any additional headers are present
*/
private function assertNoAdditionalHeaders(array $required, array $actual, $csvName)
{
Expand Down
12 changes: 6 additions & 6 deletions src/Medology/Behat/Mink/FlexibleContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function __construct()
*
* Overrides the base method to support injecting stored values and matching URLs that include hostname.
*
* @param string $page the page to assert we are on.
* @param string $page the page to assert we are on
*
* @throws DriverException if the driver failed to perform the action
* @throws ExpectationException If the current page is not the expected page.
Expand Down Expand Up @@ -623,7 +623,7 @@ public function scrollToButton($locator, TraversableElement $context = null)
{
$locator = $this->fixStepArgument($locator);

/** @noinspection PhpUnhandledExceptionInspection */
/* @noinspection PhpUnhandledExceptionInspection */
return Spinner::waitFor(function () use ($locator, $context) {
$context = $context ? $context : $this->getSession()->getPage();
$buttons = $context->findAll('named', ['button', $locator]);
Expand Down Expand Up @@ -681,7 +681,7 @@ public function assertVisibleLink($locator)
*/
public function scrollToLink($locator)
{
/** @noinspection PhpUnhandledExceptionInspection */
/* @noinspection PhpUnhandledExceptionInspection */
return Spinner::waitFor(function () use ($locator) {
$links = $this->getLinks($locator);

Expand Down Expand Up @@ -765,7 +765,7 @@ public function scrollToOption($locator)
{
$locator = $this->fixStepArgument($locator);

/** @noinspection PhpUnhandledExceptionInspection */
/* @noinspection PhpUnhandledExceptionInspection */
return Spinner::waitFor(function () use ($locator) {
$options = $this->getSession()->getPage()->findAll('named', ['field', $locator]);

Expand Down Expand Up @@ -819,7 +819,7 @@ public function assertFieldExists($fieldName, TraversableElement $context = null
*/
public function scrollToField($fieldName, TraversableElement $context = null)
{
/** @noinspection PhpUnhandledExceptionInspection */
/* @noinspection PhpUnhandledExceptionInspection */
return Spinner::waitFor(function () use ($fieldName, $context) {
$context = $context ?: $this->getSession()->getPage();

Expand Down Expand Up @@ -2032,7 +2032,7 @@ public function findRadioButton($label)
/**
* Returns all ancestors of the specified node element.
*
* @param NodeElement $node the node element to fetch ancestors for.
* @param NodeElement $node the node element to fetch ancestors for
* @param string|null $stopAt html tag to stop at. This node will NOT be included in the returned list.
*
* @return NodeElement[]
Expand Down
5 changes: 3 additions & 2 deletions src/Medology/Behat/Mink/TableContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -537,8 +537,9 @@ private function buildTableFromHtml($table, $keyName = '')
/**
* Anonymous function to retrieve cell values from an array of row nodes. Does not support row or colspan!
*
* @param NodeElement[] $rows The rows to parse
* @return array The cell values for the rows numerically indexed as [row][col]
* @param NodeElement[] $rows The rows to parse
*
* @return array The cell values for the rows numerically indexed as [row][col]
*/
$parser = function (array $rows) {
$data = [];
Expand Down
8 changes: 5 additions & 3 deletions src/Medology/Behat/Mink/WebDownloadContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,12 @@ public function download($file, $key = 'Download', $headersString = '')
/**
* This method checks if the image for an <img> tag actually loaded.
*
* @param string $xpath The xpath of the <img> tag to check
* @param string|null $src The src value.
* @param string $xpath The xpath of the <img> tag to check
* @param string|null $src the src value
*
* @throws Exception
* @return bool True if image loaded, false otherwise
*
* @return bool True if image loaded, false otherwise
*/
public function checkImageLoaded($xpath, $src = null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Medology/Behat/TypeCaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function castStringToInt($string)
*/
public function castStringToFloat($string)
{
/** @todo Add PHP_FLOAT_MAX check when we move all our projects to at least php 7.2 */
/* @todo Add PHP_FLOAT_MAX check when we move all our projects to at least php 7.2 */
return floatval($string);
}

Expand Down
1 change: 1 addition & 0 deletions submodules
Submodule submodules added at 0e848d
31 changes: 18 additions & 13 deletions tests/Medology/Behat/Mink/FlexibleContext/GetAncestorsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@
class GetAncestorsTest extends FlexibleContextTest
{
private $body;

private $div;

private $list;

private $listItem;

private $button;

public function setUp()
Expand All @@ -33,6 +37,17 @@ public function setUp()
$this->button = $this->mockNode('button', $this->listItem);
}

public function tearDown()
{
$this->body = null;
$this->div = null;
$this->list = null;
$this->listItem = null;
$this->button = null;

parent::tearDown();
}

public function testAllAncestorsAreReturned()
{
// When I pass the button to allAncestors()
Expand Down Expand Up @@ -61,8 +76,9 @@ public function testStopAtIsNotReturned()
/**
* Creates a mocked NodeElement with an optional parent.
*
* @param string $tagName the type of node element to mock
* @param NodeElement|null $parent the optional parent for the node element
* @param string $tagName the type of node element to mock
* @param NodeElement|null $parent the optional parent for the node element
*
* @return MockObject|NodeElement
*/
protected function mockNode($tagName, NodeElement $parent = null)
Expand All @@ -73,15 +89,4 @@ protected function mockNode($tagName, NodeElement $parent = null)

return $node;
}

public function tearDown()
{
$this->body = null;
$this->div = null;
$this->list = null;
$this->listItem = null;
$this->button = null;

parent::tearDown();
}
}
3 changes: 2 additions & 1 deletion tests/Medology/Behat/ParallelWorker/FilterTestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ protected function getGherkinFeature()
}

/**
* @throws PHPUnit_Framework_AssertionFailedError if the parser returns null (it should never do this).
* @throws PHPUnit_Framework_AssertionFailedError if the parser returns null (it should never do this)
*
* @return FeatureNode
*/
protected function getParsedFeature()
Expand Down
13 changes: 8 additions & 5 deletions tests/Medology/Behat/StoreContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* @noinspection PhpDocMissingThrowsInspection
* @noinspection PhpUnhandledExceptionInspection
*/

namespace Tests\Medology\Behat;

use DateTime;
Expand Down Expand Up @@ -55,6 +56,7 @@ public function injectLikeSyntaxDataProvider()

/**
* @dataProvider injectLikeSyntaxDataProvider
*
* @param string $string the value to pass to injectStoredValues
*/
public function testInjectionLikeSyntaxIsNotInjected($string)
Expand All @@ -76,6 +78,7 @@ public function nonExistentItemDataProvider()

/**
* @dataProvider nonExistentItemDataProvider
*
* @param string $string the value to pass to injectStoredValues
* @param string $error the expected Exception error message
*/
Expand All @@ -91,12 +94,13 @@ public function onGetFnWrongArgsDataProvider()
{
return [
'no args' => [function () {}],
'too many args' => [function (/** @scrutinizer ignore-unused */ $a, /** @scrutinizer ignore-unused */ $b) {}],
'too many args' => [function (/* @scrutinizer ignore-unused */ $a, /* @scrutinizer ignore-unused */ $b) {}],
];
}

/**
* @dataProvider onGetFnWrongArgsDataProvider
*
* @param $onGetFn
*/
public function testOnGetFnMustTakeOneArgument($onGetFn)
Expand All @@ -115,8 +119,8 @@ public function testOnGetFnMustTakeOneArgument($onGetFn)
public function onGetFnWrongReturnTypeDataProvider()
{
return [
'no return' => [function (/** @scrutinizer ignore-unused */ $a) {}],
'return string' => [function ($a) {
'no return' => [function (/* @scrutinizer ignore-unused */ $a) {}],
'return string' => [function ($a) {
return gettype($a);
}],
'return function' => [function ($a) {
Expand All @@ -129,7 +133,6 @@ public function onGetFnWrongReturnTypeDataProvider()

/**
* @dataProvider onGetFnWrongReturnTypeDataProvider
* @param callable $onGetFn
*/
public function testOnGetFnWrongReturnType(callable $onGetFn)
{
Expand Down Expand Up @@ -268,7 +271,7 @@ function ($a, $b, $c) {

// Lambda with wrong return type throws appropriate error
$wrongReturnTypes = [
function (/** @scrutinizer ignore-unused */ $a, /** @scrutinizer ignore-unused */ $b) {
function (/* @scrutinizer ignore-unused */ $a, /* @scrutinizer ignore-unused */ $b) {
},
function ($a, $b) {
return gettype($a) . gettype($b);
Expand Down
4 changes: 2 additions & 2 deletions tests/Medology/Behat/TypeCaster/CastStringToIntTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ protected function setUp()
/**
* Test numbers are converted properly.
*
* @param $input string The input to the conversion method.
* @param $expected mixed The out put of the conversion method.
* @param $input string The input to the conversion method
* @param $expected mixed The out put of the conversion method
*
* @dataProvider conversionExamples
*/
Expand Down

0 comments on commit 87a92e2

Please sign in to comment.