diff --git a/src/Esia/Signer/SignerPKCS7.php b/src/Esia/Signer/SignerPKCS7.php index 580b9f9..93af2bc 100644 --- a/src/Esia/Signer/SignerPKCS7.php +++ b/src/Esia/Signer/SignerPKCS7.php @@ -7,6 +7,13 @@ class SignerPKCS7 extends AbstractSignerPKCS7 implements SignerInterface { + private $pkcs7Flags = PKCS7_DETACHED; + + public function addPKCS7Flag(int $pkcs7Flag): void + { + $this->pkcs7Flags |= $pkcs7Flag; + } + /** * @throws SignFailException */ @@ -42,7 +49,8 @@ public function sign(string $message): string $signFile, $cert, $privateKey, - [] + [], + $this->pkcs7Flags ); if ($signResult) { diff --git a/tests/_support/_generated/UnitTesterActions.php b/tests/_support/_generated/UnitTesterActions.php index 91ab5de..c2cd9c5 100644 --- a/tests/_support/_generated/UnitTesterActions.php +++ b/tests/_support/_generated/UnitTesterActions.php @@ -1,18 +1,22 @@ -assertEquals($element->getChildrenCount(), 5); + * $I->assertEquals(5, $element->getChildrenCount()); * ``` * * Floating-point example: * ```php * assertEquals($calculator->add(0.1, 0.2), 0.3, 'Calculator should add the two numbers correctly.', 0.01); + * $I->assertEquals(0.3, $calculator->add(0.1, 0.2), 'Calculator should add the two numbers correctly.', 0.01); * ``` * * @param $expected * @param $actual * @param string $message - * @param float $delta + * @param float $delta * @see \Codeception\Module\Asserts::assertEquals() */ public function assertEquals($expected, $actual, $message = null, $delta = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertEquals', func_get_args())); + return $this->getScenario()->runStep(new Action('assertEquals', func_get_args())); } - + /** * [!] Method is generated. Documentation taken from corresponding module. * @@ -53,23 +57,23 @@ public function assertEquals($expected, $actual, $message = null, $delta = null) * Regular example: * ```php * assertNotEquals($element->getChildrenCount(), 0); + * $I->assertNotEquals(0, $element->getChildrenCount()); * ``` * * Floating-point example: * ```php * assertNotEquals($calculator->add(0.1, 0.2), 0.4, 'Calculator should add the two numbers correctly.', 0.01); + * $I->assertNotEquals(0.4, $calculator->add(0.1, 0.2), 'Calculator should add the two numbers correctly.', 0.01); * ``` * * @param $expected * @param $actual * @param string $message - * @param float $delta + * @param float $delta * @see \Codeception\Module\Asserts::assertNotEquals() */ public function assertNotEquals($expected, $actual, $message = null, $delta = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotEquals', func_get_args())); + return $this->getScenario()->runStep(new Action('assertNotEquals', func_get_args())); } @@ -84,7 +88,7 @@ public function assertNotEquals($expected, $actual, $message = null, $delta = nu * @see \Codeception\Module\Asserts::assertSame() */ public function assertSame($expected, $actual, $message = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertSame', func_get_args())); + return $this->getScenario()->runStep(new Action('assertSame', func_get_args())); } @@ -99,7 +103,7 @@ public function assertSame($expected, $actual, $message = null) { * @see \Codeception\Module\Asserts::assertNotSame() */ public function assertNotSame($expected, $actual, $message = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotSame', func_get_args())); + return $this->getScenario()->runStep(new Action('assertNotSame', func_get_args())); } @@ -114,7 +118,7 @@ public function assertNotSame($expected, $actual, $message = null) { * @see \Codeception\Module\Asserts::assertGreaterThan() */ public function assertGreaterThan($expected, $actual, $message = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterThan', func_get_args())); + return $this->getScenario()->runStep(new Action('assertGreaterThan', func_get_args())); } @@ -129,7 +133,7 @@ public function assertGreaterThan($expected, $actual, $message = null) { * @see \Codeception\Module\Asserts::assertGreaterThanOrEqual() */ public function assertGreaterThanOrEqual($expected, $actual, $message = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterThanOrEqual', func_get_args())); + return $this->getScenario()->runStep(new Action('assertGreaterThanOrEqual', func_get_args())); } @@ -144,7 +148,7 @@ public function assertGreaterThanOrEqual($expected, $actual, $message = null) { * @see \Codeception\Module\Asserts::assertLessThan() */ public function assertLessThan($expected, $actual, $message = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertLessThan', func_get_args())); + return $this->getScenario()->runStep(new Action('assertLessThan', func_get_args())); } @@ -159,7 +163,7 @@ public function assertLessThan($expected, $actual, $message = null) { * @see \Codeception\Module\Asserts::assertLessThanOrEqual() */ public function assertLessThanOrEqual($expected, $actual, $message = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertLessThanOrEqual', func_get_args())); + return $this->getScenario()->runStep(new Action('assertLessThanOrEqual', func_get_args())); } @@ -174,7 +178,7 @@ public function assertLessThanOrEqual($expected, $actual, $message = null) { * @see \Codeception\Module\Asserts::assertContains() */ public function assertContains($needle, $haystack, $message = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertContains', func_get_args())); + return $this->getScenario()->runStep(new Action('assertContains', func_get_args())); } @@ -189,7 +193,7 @@ public function assertContains($needle, $haystack, $message = null) { * @see \Codeception\Module\Asserts::assertNotContains() */ public function assertNotContains($needle, $haystack, $message = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotContains', func_get_args())); + return $this->getScenario()->runStep(new Action('assertNotContains', func_get_args())); } @@ -204,7 +208,7 @@ public function assertNotContains($needle, $haystack, $message = null) { * @see \Codeception\Module\Asserts::assertRegExp() */ public function assertRegExp($pattern, $string, $message = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertRegExp', func_get_args())); + return $this->getScenario()->runStep(new Action('assertRegExp', func_get_args())); } @@ -219,7 +223,7 @@ public function assertRegExp($pattern, $string, $message = null) { * @see \Codeception\Module\Asserts::assertNotRegExp() */ public function assertNotRegExp($pattern, $string, $message = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotRegExp', func_get_args())); + return $this->getScenario()->runStep(new Action('assertNotRegExp', func_get_args())); } @@ -234,7 +238,7 @@ public function assertNotRegExp($pattern, $string, $message = null) { * @see \Codeception\Module\Asserts::assertStringStartsWith() */ public function assertStringStartsWith($prefix, $string, $message = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringStartsWith', func_get_args())); + return $this->getScenario()->runStep(new Action('assertStringStartsWith', func_get_args())); } @@ -249,7 +253,7 @@ public function assertStringStartsWith($prefix, $string, $message = null) { * @see \Codeception\Module\Asserts::assertStringStartsNotWith() */ public function assertStringStartsNotWith($prefix, $string, $message = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringStartsNotWith', func_get_args())); + return $this->getScenario()->runStep(new Action('assertStringStartsNotWith', func_get_args())); } @@ -263,7 +267,7 @@ public function assertStringStartsNotWith($prefix, $string, $message = null) { * @see \Codeception\Module\Asserts::assertEmpty() */ public function assertEmpty($actual, $message = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertEmpty', func_get_args())); + return $this->getScenario()->runStep(new Action('assertEmpty', func_get_args())); } @@ -277,7 +281,7 @@ public function assertEmpty($actual, $message = null) { * @see \Codeception\Module\Asserts::assertNotEmpty() */ public function assertNotEmpty($actual, $message = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotEmpty', func_get_args())); + return $this->getScenario()->runStep(new Action('assertNotEmpty', func_get_args())); } @@ -291,7 +295,7 @@ public function assertNotEmpty($actual, $message = null) { * @see \Codeception\Module\Asserts::assertNull() */ public function assertNull($actual, $message = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNull', func_get_args())); + return $this->getScenario()->runStep(new Action('assertNull', func_get_args())); } @@ -305,10 +309,10 @@ public function assertNull($actual, $message = null) { * @see \Codeception\Module\Asserts::assertNotNull() */ public function assertNotNull($actual, $message = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotNull', func_get_args())); + return $this->getScenario()->runStep(new Action('assertNotNull', func_get_args())); } - + /** * [!] Method is generated. Documentation taken from corresponding module. * @@ -318,11 +322,27 @@ public function assertNotNull($actual, $message = null) { * @param string $message * @see \Codeception\Module\Asserts::assertTrue() */ - public function assertTrue($condition, $message = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertTrue', func_get_args())); + public function assertTrue($condition, $message = null) + { + return $this->getScenario()->runStep(new Action('assertTrue', func_get_args())); } - + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the condition is NOT true (everything but true) + * + * @param $condition + * @param string $message + * @see \Codeception\Module\Asserts::assertNotTrue() + */ + public function assertNotTrue($condition, $message = null) + { + return $this->getScenario()->runStep(new Action('assertNotTrue', func_get_args())); + } + + /** * [!] Method is generated. Documentation taken from corresponding module. * @@ -332,11 +352,27 @@ public function assertTrue($condition, $message = null) { * @param string $message * @see \Codeception\Module\Asserts::assertFalse() */ - public function assertFalse($condition, $message = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFalse', func_get_args())); + public function assertFalse($condition, $message = null) + { + return $this->getScenario()->runStep(new Action('assertFalse', func_get_args())); } - + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the condition is NOT false (everything but false) + * + * @param $condition + * @param string $message + * @see \Codeception\Module\Asserts::assertNotFalse() + */ + public function assertNotFalse($condition, $message = null) + { + return $this->getScenario()->runStep(new Action('assertNotFalse', func_get_args())); + } + + /** * [!] Method is generated. Documentation taken from corresponding module. * @@ -346,11 +382,12 @@ public function assertFalse($condition, $message = null) { * @param string $message * @see \Codeception\Module\Asserts::assertFileExists() */ - public function assertFileExists($filename, $message = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileExists', func_get_args())); + public function assertFileExists($filename, $message = null) + { + return $this->getScenario()->runStep(new Action('assertFileExists', func_get_args())); } - + /** * [!] Method is generated. Documentation taken from corresponding module. * @@ -361,7 +398,7 @@ public function assertFileExists($filename, $message = null) { * @see \Codeception\Module\Asserts::assertFileNotExists() */ public function assertFileNotExists($filename, $message = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileNotExists', func_get_args())); + return $this->getScenario()->runStep(new Action('assertFileNotExists', func_get_args())); } @@ -374,7 +411,7 @@ public function assertFileNotExists($filename, $message = null) { * @see \Codeception\Module\Asserts::assertGreaterOrEquals() */ public function assertGreaterOrEquals($expected, $actual, $description = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterOrEquals', func_get_args())); + return $this->getScenario()->runStep(new Action('assertGreaterOrEquals', func_get_args())); } @@ -387,7 +424,7 @@ public function assertGreaterOrEquals($expected, $actual, $description = null) { * @see \Codeception\Module\Asserts::assertLessOrEquals() */ public function assertLessOrEquals($expected, $actual, $description = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertLessOrEquals', func_get_args())); + return $this->getScenario()->runStep(new Action('assertLessOrEquals', func_get_args())); } @@ -399,7 +436,7 @@ public function assertLessOrEquals($expected, $actual, $description = null) { * @see \Codeception\Module\Asserts::assertIsEmpty() */ public function assertIsEmpty($actual, $description = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsEmpty', func_get_args())); + return $this->getScenario()->runStep(new Action('assertIsEmpty', func_get_args())); } @@ -412,7 +449,7 @@ public function assertIsEmpty($actual, $description = null) { * @see \Codeception\Module\Asserts::assertArrayHasKey() */ public function assertArrayHasKey($key, $actual, $description = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertArrayHasKey', func_get_args())); + return $this->getScenario()->runStep(new Action('assertArrayHasKey', func_get_args())); } @@ -425,7 +462,7 @@ public function assertArrayHasKey($key, $actual, $description = null) { * @see \Codeception\Module\Asserts::assertArrayNotHasKey() */ public function assertArrayNotHasKey($key, $actual, $description = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertArrayNotHasKey', func_get_args())); + return $this->getScenario()->runStep(new Action('assertArrayNotHasKey', func_get_args())); } @@ -441,7 +478,7 @@ public function assertArrayNotHasKey($key, $actual, $description = null) { * @see \Codeception\Module\Asserts::assertArraySubset() */ public function assertArraySubset($subset, $array, $strict = null, $message = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertArraySubset', func_get_args())); + return $this->getScenario()->runStep(new Action('assertArraySubset', func_get_args())); } @@ -454,7 +491,7 @@ public function assertArraySubset($subset, $array, $strict = null, $message = nu * @see \Codeception\Module\Asserts::assertCount() */ public function assertCount($expectedCount, $actual, $description = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertCount', func_get_args())); + return $this->getScenario()->runStep(new Action('assertCount', func_get_args())); } @@ -467,7 +504,7 @@ public function assertCount($expectedCount, $actual, $description = null) { * @see \Codeception\Module\Asserts::assertInstanceOf() */ public function assertInstanceOf($class, $actual, $description = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertInstanceOf', func_get_args())); + return $this->getScenario()->runStep(new Action('assertInstanceOf', func_get_args())); } @@ -480,7 +517,7 @@ public function assertInstanceOf($class, $actual, $description = null) { * @see \Codeception\Module\Asserts::assertNotInstanceOf() */ public function assertNotInstanceOf($class, $actual, $description = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotInstanceOf', func_get_args())); + return $this->getScenario()->runStep(new Action('assertNotInstanceOf', func_get_args())); } @@ -493,7 +530,7 @@ public function assertNotInstanceOf($class, $actual, $description = null) { * @see \Codeception\Module\Asserts::assertInternalType() */ public function assertInternalType($type, $actual, $description = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertInternalType', func_get_args())); + return $this->getScenario()->runStep(new Action('assertInternalType', func_get_args())); } @@ -506,7 +543,7 @@ public function assertInternalType($type, $actual, $description = null) { * @see \Codeception\Module\Asserts::fail() */ public function fail($message) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('fail', func_get_args())); + return $this->getScenario()->runStep(new Action('fail', func_get_args())); } @@ -537,9 +574,47 @@ public function fail($message) { * * @param $exception string or \Exception * @param $callback + * + * @deprecated Use expectThrowable instead * @see \Codeception\Module\Asserts::expectException() */ - public function expectException($exception, $callback) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('expectException', func_get_args())); + public function expectException($exception, $callback) + { + return $this->getScenario()->runStep(new Action('expectException', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Handles and checks throwables (Exceptions/Errors) called inside the callback function. + * Either throwable class name or throwable instance should be provided. + * + * ```php + * expectThrowable(MyThrowable::class, function() { + * $this->doSomethingBad(); + * }); + * + * $I->expectThrowable(new MyException(), function() { + * $this->doSomethingBad(); + * }); + * ``` + * If you want to check message or throwable code, you can pass them with throwable instance: + * ```php + * expectThrowable(new MyError("Don't do bad things"), function() { + * $this->doSomethingBad(); + * }); + * ``` + * + * @param $throwable string or \Throwable + * @param $callback + * @see \Codeception\Module\Asserts::expectThrowable() + */ + public function expectThrowable($throwable, $callback) + { + return $this->getScenario()->runStep(new Action('expectThrowable', func_get_args())); } }