diff --git a/.gitignore b/.gitignore index 718b3b8..3f5925a 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,4 @@ vendor/ tests/_output composer.lock -tests/_support/* \ No newline at end of file +tests/_support/_generated/* diff --git a/codeception.yml b/codeception.yml index bfbb7f9..85fe11e 100644 --- a/codeception.yml +++ b/codeception.yml @@ -1,23 +1,24 @@ +namespace: Tests\Fei\Entities + actor: Tester + paths: tests: tests log: tests/_output data: tests/_data support: tests/_support envs: tests/_envs + settings: colors: true memory_limit: 1024M + extensions: enabled: - Codeception\Extension\RunFailed -modules: - config: - Db: - dsn: '' - user: '' - password: '' - dump: tests/_data/dump.sql + +bootstrap: bootstrap.php + coverage: enabled: true remote: false diff --git a/composer.json b/composer.json index ec20433..f51bba6 100644 --- a/composer.json +++ b/composer.json @@ -12,8 +12,7 @@ ], "require": { "php" : "^7.0", - "zendframework/zend-filter": "^2.7", - "objective-php/gateway": "^1.0.0" + "zendframework/zend-filter": "^2.7" }, "require-dev": { "zendframework/zend-eventmanager": "^3.2", @@ -21,11 +20,20 @@ "zendframework/zend-hydrator": "^2.2", "league/fractal": "^0.13.0", "squizlabs/php_codesniffer": "3.*", - "codeception/codeception": "^2.4" + "codeception/codeception": "^4.1" }, "autoload": { + "files": [ + "objective-php-polyfill.php" + ], "psr-4": { "Fei\\Entities\\": "src/" } + }, + "autoload-dev": { + "psr-4": { + "Tests\\Fei\\Entities\\": "tests/_support", + "Tests\\Fei\\Entities\\Hydrator\\": "tests/unit/Hydrator" + } } } diff --git a/objective-php-polyfill.php b/objective-php-polyfill.php new file mode 100644 index 0000000..4b05ee2 --- /dev/null +++ b/objective-php-polyfill.php @@ -0,0 +1,9 @@ +assertEquals($element->getChildrenCount(), 5); - * ``` - * - * Floating-point example: - * ```php - * assertEquals($calculator->add(0.1, 0.2), 0.3, 'Calculator should add the two numbers correctly.', 0.01); - * ``` - * - * @param $expected - * @param $actual - * @param string $message - * @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())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that two variables are not equal. If you're comparing floating-point values, - * you can specify the optional "delta" parameter which dictates how great of a precision - * error are you willing to tolerate in order to consider the two values not equal. - * - * Regular example: - * ```php - * assertNotEquals($element->getChildrenCount(), 0); - * ``` - * - * Floating-point example: - * ```php - * assertNotEquals($calculator->add(0.1, 0.2), 0.4, 'Calculator should add the two numbers correctly.', 0.01); - * ``` - * - * @param $expected - * @param $actual - * @param string $message - * @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())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that two variables are same - * - * @param $expected - * @param $actual - * @param string $message - * @see \Codeception\Module\Asserts::assertSame() - */ - public function assertSame($expected, $actual, $message = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertSame', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that two variables are not same - * - * @param $expected - * @param $actual - * @param string $message - * @see \Codeception\Module\Asserts::assertNotSame() - */ - public function assertNotSame($expected, $actual, $message = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotSame', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that actual is greater than expected - * - * @param $expected - * @param $actual - * @param string $message - * @see \Codeception\Module\Asserts::assertGreaterThan() - */ - public function assertGreaterThan($expected, $actual, $message = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterThan', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that actual is greater or equal than expected - * - * @param $expected - * @param $actual - * @param string $message - * @see \Codeception\Module\Asserts::assertGreaterThanOrEqual() - */ - public function assertGreaterThanOrEqual($expected, $actual, $message = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterThanOrEqual', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that actual is less than expected - * - * @param $expected - * @param $actual - * @param string $message - * @see \Codeception\Module\Asserts::assertLessThan() - */ - public function assertLessThan($expected, $actual, $message = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertLessThan', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that actual is less or equal than expected - * - * @param $expected - * @param $actual - * @param string $message - * @see \Codeception\Module\Asserts::assertLessThanOrEqual() - */ - public function assertLessThanOrEqual($expected, $actual, $message = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertLessThanOrEqual', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that haystack contains needle - * - * @param $needle - * @param $haystack - * @param string $message - * @see \Codeception\Module\Asserts::assertContains() - */ - public function assertContains($needle, $haystack, $message = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertContains', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that haystack doesn't contain needle. - * - * @param $needle - * @param $haystack - * @param string $message - * @see \Codeception\Module\Asserts::assertNotContains() - */ - public function assertNotContains($needle, $haystack, $message = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotContains', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that string match with pattern - * - * @param string $pattern - * @param string $string - * @param string $message - * @see \Codeception\Module\Asserts::assertRegExp() - */ - public function assertRegExp($pattern, $string, $message = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertRegExp', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that string not match with pattern - * - * @param string $pattern - * @param string $string - * @param string $message - * @see \Codeception\Module\Asserts::assertNotRegExp() - */ - public function assertNotRegExp($pattern, $string, $message = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotRegExp', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that a string starts with the given prefix. - * - * @param string $prefix - * @param string $string - * @param string $message - * @see \Codeception\Module\Asserts::assertStringStartsWith() - */ - public function assertStringStartsWith($prefix, $string, $message = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringStartsWith', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that a string doesn't start with the given prefix. - * - * @param string $prefix - * @param string $string - * @param string $message - * @see \Codeception\Module\Asserts::assertStringStartsNotWith() - */ - public function assertStringStartsNotWith($prefix, $string, $message = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringStartsNotWith', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that variable is empty. - * - * @param $actual - * @param string $message - * @see \Codeception\Module\Asserts::assertEmpty() - */ - public function assertEmpty($actual, $message = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertEmpty', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that variable is not empty. - * - * @param $actual - * @param string $message - * @see \Codeception\Module\Asserts::assertNotEmpty() - */ - public function assertNotEmpty($actual, $message = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotEmpty', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that variable is NULL - * - * @param $actual - * @param string $message - * @see \Codeception\Module\Asserts::assertNull() - */ - public function assertNull($actual, $message = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNull', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that variable is not NULL - * - * @param $actual - * @param string $message - * @see \Codeception\Module\Asserts::assertNotNull() - */ - public function assertNotNull($actual, $message = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotNull', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that condition is positive. - * - * @param $condition - * @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())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that condition is negative. - * - * @param $condition - * @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())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks if file exists - * - * @param string $filename - * @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())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks if file doesn't exist - * - * @param string $filename - * @param string $message - * @see \Codeception\Module\Asserts::assertFileNotExists() - */ - public function assertFileNotExists($filename, $message = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileNotExists', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param $expected - * @param $actual - * @param $description - * @see \Codeception\Module\Asserts::assertGreaterOrEquals() - */ - public function assertGreaterOrEquals($expected, $actual, $description = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterOrEquals', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param $expected - * @param $actual - * @param $description - * @see \Codeception\Module\Asserts::assertLessOrEquals() - */ - public function assertLessOrEquals($expected, $actual, $description = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertLessOrEquals', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param $actual - * @param $description - * @see \Codeception\Module\Asserts::assertIsEmpty() - */ - public function assertIsEmpty($actual, $description = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsEmpty', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param $key - * @param $actual - * @param $description - * @see \Codeception\Module\Asserts::assertArrayHasKey() - */ - public function assertArrayHasKey($key, $actual, $description = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertArrayHasKey', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param $key - * @param $actual - * @param $description - * @see \Codeception\Module\Asserts::assertArrayNotHasKey() - */ - public function assertArrayNotHasKey($key, $actual, $description = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertArrayNotHasKey', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that array contains subset. - * - * @param array $subset - * @param array $array - * @param bool $strict - * @param string $message - * @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())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param $expectedCount - * @param $actual - * @param $description - * @see \Codeception\Module\Asserts::assertCount() - */ - public function assertCount($expectedCount, $actual, $description = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertCount', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param $class - * @param $actual - * @param $description - * @see \Codeception\Module\Asserts::assertInstanceOf() - */ - public function assertInstanceOf($class, $actual, $description = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertInstanceOf', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param $class - * @param $actual - * @param $description - * @see \Codeception\Module\Asserts::assertNotInstanceOf() - */ - public function assertNotInstanceOf($class, $actual, $description = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotInstanceOf', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param $type - * @param $actual - * @param $description - * @see \Codeception\Module\Asserts::assertInternalType() - */ - public function assertInternalType($type, $actual, $description = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertInternalType', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Fails the test with message. - * - * @param $message - * @see \Codeception\Module\Asserts::fail() - */ - public function fail($message) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('fail', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Handles and checks exception called inside callback function. - * Either exception class name or exception instance should be provided. - * - * ```php - * expectException(MyException::class, function() { - * $this->doSomethingBad(); - * }); - * - * $I->expectException(new MyException(), function() { - * $this->doSomethingBad(); - * }); - * ``` - * If you want to check message or exception code, you can pass them with exception instance: - * ```php - * expectException(new MyException("Don't do bad things"), function() { - * $this->doSomethingBad(); - * }); - * ``` - * - * @param $exception string or \Exception - * @param $callback - * @see \Codeception\Module\Asserts::expectException() - */ - public function expectException($exception, $callback) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('expectException', func_get_args())); - } -} diff --git a/tests/acceptance.suite.yml b/tests/acceptance.suite.yml deleted file mode 100644 index 6927551..0000000 --- a/tests/acceptance.suite.yml +++ /dev/null @@ -1,10 +0,0 @@ -# Codeception Test Suite Configuration -# -# Suite for acceptance tests. -# Perform tests in browser using the WebDriver or PhpBrowser. -# If you need both WebDriver and PHPBrowser tests - create a separate suite. - -class_name: AcceptanceTester -modules: - enabled: - - \Helper\Acceptance diff --git a/tests/acceptance/_bootstrap.php b/tests/acceptance/_bootstrap.php deleted file mode 100644 index 8a88555..0000000 --- a/tests/acceptance/_bootstrap.php +++ /dev/null @@ -1,2 +0,0 @@ -hydrate(['foo' => 'foo value', 'bar' => 'bar value', 'context' => ['x' => 'y']], $entity); - + $this->assertEquals('foo value', $entity->getFoo()); $this->assertEquals('bar value', $entity->getBar()); $this->assertEquals('y', $entity->getContext('x')); - } - + + /** + * @return SomeEntity + */ public function testHydrationUsingDenormalizedContext() { - + $hydrator = new ContextAwareEntityHydrator(); - + $entity = new SomeEntity(); - + $hydrator->hydrate(['foo' => 'foo value', 'bar' => 'bar value', 'context_x' => 'y'], $entity); - + $this->assertEquals('foo value', $entity->getFoo()); $this->assertEquals('bar value', $entity->getBar()); $this->assertEquals('y', $entity->getContext('x')); - + return $entity; - } - + /** * @depends testHydrationUsingDenormalizedContext */ @@ -61,7 +55,7 @@ public function testExtraction(SomeEntity $entity) $hydrator = new ContextAwareEntityHydrator(); $this->assertEquals(['foo' => 'foo value', 'bar' => 'bar value', 'context' => ['x' => 'y']], $hydrator->extract($entity)); } - + /** * @depends testHydrationUsingDenormalizedContext */ @@ -72,16 +66,15 @@ public function testExtractionWithDenormalizedContext(SomeEntity $entity) } } - class SomeEntity implements ContextAwareEntityInterface { - + use ContextAwareTrait; - + protected $foo; - + protected $bar; - + /** * @return mixed */ @@ -89,7 +82,7 @@ public function getFoo() { return $this->foo; } - + /** * @param mixed $foo * @@ -98,10 +91,10 @@ public function getFoo() public function setFoo($foo) { $this->foo = $foo; - + return $this; } - + /** * @return mixed */ @@ -109,7 +102,7 @@ public function getBar() { return $this->bar; } - + /** * @param mixed $bar * @@ -118,8 +111,7 @@ public function getBar() public function setBar($bar) { $this->bar = $bar; - + return $this; } - }