diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index fc046f5..2ca725a 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -168,6 +168,12 @@ http://127.0.0.1:9080 http://127.0.0.1:9080/docusign/authorization_code/embedded_auth_code http://127.0.0.1:9080/docusign/authorization_code/remote_auth_code +Detect and download the browser drivers automatically: + +```shell +vendor/bin/bdi detect drivers +``` + Then, run the following command to execute e2e tests: ```shell diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d96f759..03d8092 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,33 +21,22 @@ jobs: - '8.0' symfony: - '4.4.*' - - '5.1.*' + - '5.2.*' dependency: - '' - '--prefer-lowest' include: + - deprecations: false + - php: '8.0' + dependency: '' + symfony: '5.2.*' + deprecations: true - php: '7.4' dependency: '' - symfony: '5.1.*' + symfony: '5.2.*' coverage: true bootable: true - - php: '8.0' - dependency: '--ignore-platform-req=php' - symfony: '4.4.*' - - php: '8.0' - dependency: '--ignore-platform-req=php' - symfony: '5.1.*' - - php: '8.0' - dependency: '--prefer-lowest --ignore-platform-req=php' - symfony: '4.4.*' - - php: '8.0' - dependency: '--prefer-lowest --ignore-platform-req=php' - symfony: '5.1.*' - exclude: - - php: '8.0' - dependency: '' - - php: '8.0' - dependency: '--prefer-lowest' + deprecations: true fail-fast: false steps: - name: Checkout @@ -57,9 +46,13 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - extensions: composer:v2, flex coverage: pcov - tools: php-cs-fixer + tools: composer:v2, flex, php-cs-fixer + + - name: Install chromium + run: | + sudo apt-get update + sudo apt-get install -y --no-install-recommends chromium-browser - name: Get Composer Cache Directory id: composer-cache @@ -79,7 +72,7 @@ jobs: run: composer update --no-progress --ansi --prefer-stable ${{ matrix.dependency }} - name: Disable deprecations notices for lowest dependencies - if: matrix.dependency != '' + if: matrix.deprecations == false run: echo "SYMFONY_DEPRECATIONS_HELPER=weak" >> $GITHUB_ENV - name: Bundle is bootable @@ -93,20 +86,14 @@ jobs: composer req gheb/docusign-bundle - name: Run php-cs-fixer tests - if: matrix.php != '8.0' run: php-cs-fixer fix --diff --dry-run - - name: Install chromium - run: | - sudo apt-get update - sudo apt-get install -y --no-install-recommends chromium-browser - - name: Run phpstan tests - if: matrix.dependency == '' && matrix.php != '7.3' && matrix.php != '8.0' + if: matrix.dependency == '' && matrix.php == '7.4' run: vendor/bin/phpstan analyze - name: Run phpstan tests lowest - if: matrix.dependency != '' && matrix.php != '8.0' + if: matrix.dependency != '' && matrix.php == '7.4' run: vendor/bin/phpstan analyze -c phpstan.neon.lowest.dist - name: Prepare PHPUnit tests diff --git a/.gitignore b/.gitignore index 20138be..85f8fc1 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ /features/.env.* !features/var/storage/dummy.pdf /completed.pdf +/drivers/ diff --git a/composer.json b/composer.json index 8891da0..e4af240 100644 --- a/composer.json +++ b/composer.json @@ -43,6 +43,7 @@ "webmozart/assert": "^1.5" }, "require-dev": { + "dbrekelmans/bdi": "^0.3.0", "doctrine/annotations": "^1.11", "league/flysystem-bundle": "^1.2", "nyholm/symfony-bundle-test": "dev-master", @@ -54,7 +55,7 @@ "symfony/debug": "^4.4 || ^5.0", "symfony/dotenv": "^4.4 || ^5.0", "symfony/monolog-bundle": "^3.5", - "symfony/panther": "^0.6.1", + "symfony/panther": "^1.0", "symfony/phpunit-bridge": "^5.1", "symfony/polyfill-php72": "^1.9", "symfony/process": "^4.4 || ^5.0", @@ -79,10 +80,12 @@ }, "scripts": { "post-install-cmd": [ - "vendor/bin/simple-phpunit --version" + "vendor/bin/simple-phpunit --version", + "vendor/bin/bdi detect drivers" ], "post-update-cmd": [ - "vendor/bin/simple-phpunit --version" + "vendor/bin/simple-phpunit --version", + "vendor/bin/bdi detect drivers" ] }, "config": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index d079da4..cf13ed6 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -10,7 +10,7 @@ - + @@ -20,11 +20,11 @@ - - + + src - - + + diff --git a/src/Controller/Callback.php b/src/Controller/Callback.php index 7883b04..4513f71 100644 --- a/src/Controller/Callback.php +++ b/src/Controller/Callback.php @@ -23,9 +23,8 @@ final class Callback implements TranslatorAwareInterface { - public const EVENT_COMPLETE = 'signing_complete'; - use TranslatorAwareTrait; + public const EVENT_COMPLETE = 'signing_complete'; public function __invoke(Request $request, EventDispatcherInterface $eventDispatcher): Response { diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index bf6d3fd..f9856df 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -158,7 +158,7 @@ public function getConfigTreeBuilder(): TreeBuilder ->validate() ->ifString() ->then(static function ($v) { - @trigger_error('The "grant_type" configuration key has been deprecated since 5.3.0 and will be removed in 6.0. Implicit authentication should not be used in this bundle.', E_USER_DEPRECATED); + @trigger_error('The "grant_type" configuration key has been deprecated since 5.3.0 and will be removed in 6.0. Implicit authentication should not be used in this bundle.', \E_USER_DEPRECATED); return $v; }) diff --git a/src/DependencyInjection/DocusignExtension.php b/src/DependencyInjection/DocusignExtension.php index cf71d77..71afda3 100644 --- a/src/DependencyInjection/DocusignExtension.php +++ b/src/DependencyInjection/DocusignExtension.php @@ -89,7 +89,7 @@ public function load(array $configs, ContainerBuilder $container): void // Clickwrap mode if (EnvelopeBuilder::MODE_CLICKWRAP === $value['mode']) { $clickwrapExtensionDefinition->addMethodCall('addConfig', [$name, $value['demo'], [ - 'environment' => pathinfo($value['api_uri'], PATHINFO_DIRNAME), + 'environment' => pathinfo($value['api_uri'], \PATHINFO_DIRNAME), 'accountId' => $value['auth_clickwrap']['api_account_id'], 'clientUserId' => $value['auth_clickwrap']['user_guid'], 'clickwrapId' => $value['auth_clickwrap']['clickwrap_id'], diff --git a/src/EnvelopeBuilder.php b/src/EnvelopeBuilder.php index 0c8eeee..27770b3 100644 --- a/src/EnvelopeBuilder.php +++ b/src/EnvelopeBuilder.php @@ -130,7 +130,7 @@ public function addCarbonCopy(string $name, string $email): self $carbonCopy = new Model\CarbonCopy(); $carbonCopy->setEmail($email); $carbonCopy->setName($name); - $carbonCopy->setRecipientId((string) $this->docReference); + $carbonCopy->setRecipientId(sha1($email.$name)); $this->carbonCopies[] = $carbonCopy; @@ -176,7 +176,7 @@ public function addSigner(string $name, string $email): self $data = [ 'email' => $email, 'name' => $name, - 'recipient_id' => $this->docReference, + 'recipient_id' => sha1($email.$name), ]; if (self::MODE_EMBEDDED === $this->getMode()) { diff --git a/src/EnvelopeCreator/DefineEnvelope.php b/src/EnvelopeCreator/DefineEnvelope.php index e67e2eb..aa6d629 100644 --- a/src/EnvelopeCreator/DefineEnvelope.php +++ b/src/EnvelopeCreator/DefineEnvelope.php @@ -24,9 +24,8 @@ final class DefineEnvelope implements EnvelopeBuilderCallableInterface, TranslatorAwareInterface { - public const EMAIL_SUBJECT = 'Please sign this document'; - use TranslatorAwareTrait; + public const EMAIL_SUBJECT = 'Please sign this document'; private $router; private $envelopeBuilder; diff --git a/src/EnvelopeCreator/GetViewUrl.php b/src/EnvelopeCreator/GetViewUrl.php index 58dbf37..0db6b6b 100644 --- a/src/EnvelopeCreator/GetViewUrl.php +++ b/src/EnvelopeCreator/GetViewUrl.php @@ -19,7 +19,7 @@ use DocusignBundle\Utils\CallbackRouteGenerator; use Symfony\Component\Routing\RouterInterface; -/*final */class GetViewUrl implements EnvelopeBuilderCallableInterface +/*final */ class GetViewUrl implements EnvelopeBuilderCallableInterface { private $router; private $envelopeBuilder; diff --git a/src/Grant/JwtGrant.php b/src/Grant/JwtGrant.php index 1e6d3be..4258cf6 100644 --- a/src/Grant/JwtGrant.php +++ b/src/Grant/JwtGrant.php @@ -88,7 +88,7 @@ private function createToken(): string ->relatedTo($this->userGuid) // sub ->issuedAt($time) // iat ->expiresAt($time->modify("$this->ttl sec")) // exp - ->permittedFor(parse_url($this->accountApiUri, PHP_URL_HOST)) // aud + ->permittedFor(parse_url($this->accountApiUri, \PHP_URL_HOST)) // aud ->withClaim('scope', 'signature impersonation') // scope ->getToken($config->signer(), $config->signingKey()) ->toString(); @@ -101,7 +101,7 @@ private function createToken(): string ->relatedTo($this->userGuid) // sub ->issuedAt($time) // iat ->expiresAt($time + $this->ttl) // exp - ->permittedFor(parse_url($this->accountApiUri, PHP_URL_HOST)) // aud + ->permittedFor(parse_url($this->accountApiUri, \PHP_URL_HOST)) // aud ->withClaim('scope', 'signature impersonation') // scope ->getToken(new Sha256(), new Key("file://$this->privateKey")); } diff --git a/src/TokenEncoder/TokenEncoder.php b/src/TokenEncoder/TokenEncoder.php index 979c659..104c00e 100644 --- a/src/TokenEncoder/TokenEncoder.php +++ b/src/TokenEncoder/TokenEncoder.php @@ -31,7 +31,7 @@ public function encode(array $parameters): string return password_hash(http_build_query($parameters + [ 'integration_key' => $this->integrationKey, - ]), PASSWORD_BCRYPT); + ]), \PASSWORD_BCRYPT); } public function isTokenValid(array $parameters, ?string $token): bool diff --git a/tests/DependencyInjection/ConfigurationTest.php b/tests/DependencyInjection/ConfigurationTest.php index 1db54a5..2ed3328 100644 --- a/tests/DependencyInjection/ConfigurationTest.php +++ b/tests/DependencyInjection/ConfigurationTest.php @@ -19,6 +19,7 @@ use Symfony\Component\Config\Definition\ConfigurationInterface; use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; use Symfony\Component\Config\Definition\Processor; +use Symfony\Component\HttpKernel\Kernel; class ConfigurationTest extends TestCase { @@ -159,7 +160,12 @@ public function testItThrowsAnErrorOnInvalidModeConfig(): void public function testItThrowsAnErrorOnMissingModeConfig(): void { $this->expectException(InvalidConfigurationException::class); - $this->expectExceptionMessage('The child node "mode" at path "docusign.demo" must be configured.'); + // Error message has changed between Symfony 4.4 and 5.* + if (4 === Kernel::MAJOR_VERSION) { + $this->expectExceptionMessage('The child node "mode" at path "docusign.demo" must be configured.'); + } else { + $this->expectExceptionMessage('The child config "mode" under "docusign.demo" must be configured: Type of signature to use: remote or embedded.'); + } $this->processor->processConfiguration($this->configuration, [ 'docusign' => [ 'demo' => true, diff --git a/tests/EmbeddedAuthCodeTest.php b/tests/EmbeddedAuthCodeTest.php index 0d29c06..59a007d 100644 --- a/tests/EmbeddedAuthCodeTest.php +++ b/tests/EmbeddedAuthCodeTest.php @@ -117,6 +117,6 @@ public function testICanSignAnEmbeddedDocument(): void $crawler = $client->waitFor('.alert'); $this->assertSame('The document has been successfully signed!', $crawler->filter('.alert')->text()); - $this->assertSame('/embedded_auth_code', parse_url($crawler->getUri(), PHP_URL_PATH)); + $this->assertSame('/embedded_auth_code', parse_url($crawler->getUri(), \PHP_URL_PATH)); } } diff --git a/tests/EmbeddedTest.php b/tests/EmbeddedTest.php index 015e2aa..6f0165e 100644 --- a/tests/EmbeddedTest.php +++ b/tests/EmbeddedTest.php @@ -92,6 +92,6 @@ public function testICanSignAnEmbeddedDocument(): void $crawler = $client->waitFor('.alert'); $this->assertSame('The document has been successfully signed!', $crawler->filter('.alert')->text()); - $this->assertSame('/embedded', parse_url($crawler->getUri(), PHP_URL_PATH)); + $this->assertSame('/embedded', parse_url($crawler->getUri(), \PHP_URL_PATH)); } } diff --git a/tests/EnvelopeCreator/CreateDocumentTest.php b/tests/EnvelopeCreator/CreateDocumentTest.php index ffece6b..d4553bd 100644 --- a/tests/EnvelopeCreator/CreateDocumentTest.php +++ b/tests/EnvelopeCreator/CreateDocumentTest.php @@ -29,7 +29,7 @@ class CreateDocumentTest extends TestCase private $envelopeBuilderProphecyMock; private $fileSystemProphecyMock; - public function setUp(): void + protected function setUp(): void { $this->envelopeBuilderProphecyMock = $this->prophesize(EnvelopeBuilderInterface::class); $this->fileSystemProphecyMock = $this->prophesize(FilesystemInterface::class); diff --git a/tests/EnvelopeCreator/CreateSignatureTest.php b/tests/EnvelopeCreator/CreateSignatureTest.php index d34afa7..00eb279 100644 --- a/tests/EnvelopeCreator/CreateSignatureTest.php +++ b/tests/EnvelopeCreator/CreateSignatureTest.php @@ -26,7 +26,7 @@ class CreateSignatureTest extends TestCase private $envelopeBuilderProphecyMock; private $signatureExtractorProphecyMock; - public function setUp(): void + protected function setUp(): void { $this->envelopeBuilderProphecyMock = $this->prophesize(EnvelopeBuilderInterface::class); $this->signatureExtractorProphecyMock = $this->prophesize(SignatureExtractor::class); diff --git a/tests/EnvelopeCreator/DefineEnvelopeTest.php b/tests/EnvelopeCreator/DefineEnvelopeTest.php index ed0fda2..1c44ed9 100644 --- a/tests/EnvelopeCreator/DefineEnvelopeTest.php +++ b/tests/EnvelopeCreator/DefineEnvelopeTest.php @@ -34,7 +34,7 @@ class DefineEnvelopeTest extends TestCase private $translatorProphecyMock; private $tokenEncoderProphecyMock; - public function setUp(): void + protected function setUp(): void { $this->envelopeBuilderProphecyMock = $this->prophesize(EnvelopeBuilderInterface::class); $this->routerProphecyMock = $this->prophesize(RouterInterface::class); diff --git a/tests/EnvelopeCreator/EnvelopeCreatorTest.php b/tests/EnvelopeCreator/EnvelopeCreatorTest.php index 6416bc0..c251fc6 100644 --- a/tests/EnvelopeCreator/EnvelopeCreatorTest.php +++ b/tests/EnvelopeCreator/EnvelopeCreatorTest.php @@ -35,7 +35,7 @@ class EnvelopeCreatorTest extends TestCase private $defineEnvelopeProphecyMock; private $sendEnvelopeProphecyMock; - public function setUp(): void + protected function setUp(): void { $this->envelopeBuilderProphecyMock = $this->prophesize(EnvelopeBuilderInterface::class); $this->routerProphecyMock = $this->prophesize(RouterInterface::class); diff --git a/tests/EnvelopeCreator/GetViewUrlTest.php b/tests/EnvelopeCreator/GetViewUrlTest.php index 41ba40a..dda7278 100644 --- a/tests/EnvelopeCreator/GetViewUrlTest.php +++ b/tests/EnvelopeCreator/GetViewUrlTest.php @@ -31,7 +31,7 @@ class GetViewUrlTest extends TestCase private $envelopeBuilderProphecyMock; private $routerProphecyMock; - public function setUp(): void + protected function setUp(): void { $this->envelopeBuilderProphecyMock = $this->prophesize(EnvelopeBuilderInterface::class); $this->routerProphecyMock = $this->prophesize(RouterInterface::class); diff --git a/tests/EnvelopeCreator/SendEnvelopeTest.php b/tests/EnvelopeCreator/SendEnvelopeTest.php index 814f327..6a70c7c 100644 --- a/tests/EnvelopeCreator/SendEnvelopeTest.php +++ b/tests/EnvelopeCreator/SendEnvelopeTest.php @@ -34,7 +34,7 @@ class SendEnvelopeTest extends TestCase private $envelopesApiProphecyMock; private $envelopeSummaryProphecyMock; - public function setUp(): void + protected function setUp(): void { $this->envelopeBuilderProphecyMock = $this->prophesize(EnvelopeBuilderInterface::class); $this->grantProphecyMock = $this->prophesize(GrantInterface::class); diff --git a/tests/RemoteAuthCodeTest.php b/tests/RemoteAuthCodeTest.php index 2ddff9f..02d5478 100644 --- a/tests/RemoteAuthCodeTest.php +++ b/tests/RemoteAuthCodeTest.php @@ -92,6 +92,6 @@ public function testICanSentARemoteDocumentToBeSigned(): void $crawler = $client->waitFor('.alert'); $this->assertSame('The document has been successfully sent to the signer!', $crawler->filter('.alert')->text()); - $this->assertSame('/remote_auth_code', parse_url($crawler->getUri(), PHP_URL_PATH)); + $this->assertSame('/remote_auth_code', parse_url($crawler->getUri(), \PHP_URL_PATH)); } } diff --git a/tests/RemoteTest.php b/tests/RemoteTest.php index ebee443..0e49119 100644 --- a/tests/RemoteTest.php +++ b/tests/RemoteTest.php @@ -67,6 +67,6 @@ public function testICanSentARemoteDocumentToBeSigned(): void $crawler = $client->waitFor('.alert'); $this->assertSame('The document has been successfully sent to the signer!', $crawler->filter('.alert')->text()); - $this->assertSame('/remote', parse_url($crawler->getUri(), PHP_URL_PATH)); + $this->assertSame('/remote', parse_url($crawler->getUri(), \PHP_URL_PATH)); } } diff --git a/tests/config/chromedriver b/tests/config/chromedriver deleted file mode 100755 index 722ede5..0000000 Binary files a/tests/config/chromedriver and /dev/null differ