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

Multi-file support on wn:resources, enhance model relationships and enable polymorphic relationships #66

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ lumen-test/app
lumen-test/database
lumen-test/tests/tmp

.DS_Store
.idea
386 changes: 175 additions & 211 deletions composer.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion formats/fields.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
{
"name": "factory",
"type": "string",
"default": false
"default": false,
"required": false
}
]
}
Expand Down
19 changes: 19 additions & 0 deletions formats/relations-hasManyThrough.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"type": "array",
"fields": {
"type": "object",
"separator": ":",
"fields": [
"name",
{
"name": "model",
"type": "string"
},
{
"name": "through",
"type": "string",
"default": false
}
]
}
}
19 changes: 19 additions & 0 deletions formats/relations-morphMany.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"type": "array",
"fields": {
"type": "object",
"separator": ":",
"fields": [
"name",
{
"name": "model",
"type": "string"
},
{
"name": "through",
"type": "string",
"default": ""
}
]
}
}
15 changes: 15 additions & 0 deletions formats/relations-morphTo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"type": "array",
"fields": {
"type": "object",
"separator": "|",
"fields": [
"name",
{
"name": "nullable",
"type": "boolean",
"default": false
}
]
}
}
2 changes: 1 addition & 1 deletion lumen-test/.env
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ DB_CONNECTION=sqlite
# DB_USERNAME=homestead
# DB_PASSWORD=secret

# CACHE_DRIVER=memcached
CACHE_DRIVER=file
# SESSION_DRIVER=memcached
# QUEUE_DRIVER=database

Expand Down
4 changes: 2 additions & 2 deletions lumen-test/app/Http/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
|
*/

$app->get("/", function () use ($app) {
return $app->welcome();
$router->get("/", function () use ($router) {
return 'Hello World';
});
10 changes: 8 additions & 2 deletions lumen-test/bootstrap/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

require_once __DIR__.'/../vendor/autoload.php';

Dotenv::load(__DIR__.'/../');
try {
(new Dotenv\Dotenv(__DIR__.'/../'))->load();
} catch (Dotenv\Exception\InvalidPathException $e) {
//
}

/*
|--------------------------------------------------------------------------
Expand Down Expand Up @@ -92,7 +96,9 @@
|
*/

$app->group(['namespace' => 'App\Http\Controllers'], function ($app) {
$app->router->group([
'namespace' => 'App\Http\Controllers',
], function ($router) {
require __DIR__.'/../app/Http/routes.php';
});

Expand Down
20 changes: 13 additions & 7 deletions lumen-test/clean.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#!/usr/bin/env bash

cd "$(dirname "$0")"

# models
rm app/*.php 2> /dev/null

Expand All @@ -11,13 +15,15 @@ echo "<?php
return \$app->welcome();
});" > app/Http/routes.php

echo "<?php
/*
|------------------------------------------
| ***** DUMMY ROUTES FOR TESTING ONLY *****
|------------------------------------------
*/
" > routes/api.php
if [ -d "routes" ]; then
echo "<?php
/*
|------------------------------------------
| ***** DUMMY ROUTES FOR TESTING ONLY *****
|------------------------------------------
*/
" > routes/api.php
fi

# Controllers
rm app/Http/Controllers/*.php 2> /dev/null
Expand Down
8 changes: 4 additions & 4 deletions lumen-test/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/lumen-framework": "5.1.*",
"vlucas/phpdotenv": "~1.0"
"php": ">=7.1.3",
"laravel/lumen-framework": "5.5.*",
"vlucas/phpdotenv": "~2.2"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"fzaninotto/faker": "~1.0",
"phpspec/phpspec": "2.0.0",
"phpspec/phpspec": "5.1.0",
"codeception/codeception": "^2.2"
},
"autoload": {
Expand Down
22 changes: 1 addition & 21 deletions lumen-test/tests/_support/_generated/AcceptanceTesterActions.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
<?php //[STAMP] d6606f78456705b0875c6b8343fc6a4a
<?php //[STAMP] 141a71be31fb850b4f0890a80e070f8c
namespace _generated;

// This class was automatically generated by build task
// You should not change it manually as it will be overwritten on next build
// @codingStandardsIgnoreFile

use Helper\Acceptance;
use Codeception\Module\Cli;
use Codeception\Module\Filesystem;

trait AcceptanceTesterActions
{
/**
Expand All @@ -17,22 +13,6 @@ trait AcceptanceTesterActions
abstract protected function getScenario();


/**
* [!] 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::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.
*
Expand Down
18 changes: 1 addition & 17 deletions lumen-test/tests/_support/_generated/FunctionalTesterActions.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<?php //[STAMP] d2a298893573661fdbd787dcfa27a7b0
<?php //[STAMP] e9c8ced0898dea0901abb2a576b5a217
namespace _generated;

// This class was automatically generated by build task
// You should not change it manually as it will be overwritten on next build
// @codingStandardsIgnoreFile

use Helper\Functional;

trait FunctionalTesterActions
{
/**
Expand All @@ -15,18 +13,4 @@ trait FunctionalTesterActions
abstract protected function getScenario();


/**
* [!] 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::assertArraySubset()
*/
public function assertArraySubset($subset, $array, $strict = null, $message = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertArraySubset', func_get_args()));
}
}
79 changes: 70 additions & 9 deletions lumen-test/tests/_support/_generated/UnitTesterActions.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
<?php //[STAMP] 1467e0d5027bbc2413077351642a21f3
<?php //[STAMP] 0c250320f7b0d08d5ec3e0f02856af50
namespace _generated;

// This class was automatically generated by build task
// You should not change it manually as it will be overwritten on next build
// @codingStandardsIgnoreFile

use Codeception\Module\Asserts;
use Helper\Unit;

trait UnitTesterActions
{
/**
Expand All @@ -26,13 +23,13 @@ abstract protected function getScenario();
* Regular example:
* ```php
* <?php
* $I->assertEquals($element->getChildrenCount(), 5);
* $I->assertEquals(5, $element->getChildrenCount());
* ```
*
* Floating-point example:
* ```php
* <?php
* $I->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
Expand All @@ -56,13 +53,13 @@ public function assertEquals($expected, $actual, $message = null, $delta = null)
* Regular example:
* ```php
* <?php
* $I->assertNotEquals($element->getChildrenCount(), 0);
* $I->assertNotEquals(0, $element->getChildrenCount());
* ```
*
* Floating-point example:
* ```php
* <?php
* $I->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
Expand Down Expand Up @@ -326,6 +323,20 @@ public function assertTrue($condition, $message = null) {
}


/**
* [!] 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 \Codeception\Step\Action('assertNotTrue', func_get_args()));
}


/**
* [!] Method is generated. Documentation taken from corresponding module.
*
Expand All @@ -340,6 +351,20 @@ public function assertFalse($condition, $message = null) {
}


/**
* [!] 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 \Codeception\Step\Action('assertNotFalse', func_get_args()));
}


/**
* [!] Method is generated. Documentation taken from corresponding module.
*
Expand Down Expand Up @@ -441,7 +466,7 @@ public function assertArrayNotHasKey($key, $actual, $description = null) {
* @param array $array
* @param bool $strict
* @param string $message
* @see \Codeception\Module::assertArraySubset()
* @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()));
Expand Down Expand Up @@ -540,9 +565,45 @@ 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()));
}


/**
* [!] 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
* <?php
* $I->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
* <?php
* // will check that throwable MyError is thrown with "Don't do bad things" message
* $I->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 \Codeception\Step\Action('expectThrowable', func_get_args()));
}
}
Loading