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

[Laravel 6] Bring code to a state where unit tests pass #443

Merged
merged 30 commits into from
Jan 19, 2020
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
fdbb867
Composer dependency changes
bennothommo Nov 21, 2019
b5e6e02
Update test cases to use void return type where necessary
bennothommo Nov 21, 2019
12ff056
Change otherKey to ownerKey for morphOne relations
bennothommo Nov 22, 2019
5a1a015
Fix branch alias in Composer
bennothommo Nov 22, 2019
cbd0550
Add missing "choice" method in Translator mock.
bennothommo Nov 22, 2019
4f7e57d
Change Assetic use cases to use contracts
bennothommo Nov 22, 2019
a4cbe94
Change MemoryRepository to use seconds instead of minutes.
bennothommo Nov 22, 2019
188ead3
Remove "nothing" test case
bennothommo Nov 22, 2019
050bcac
Change Exception test expections.
bennothommo Nov 22, 2019
2ac6691
Change deprecated assertInternalType() calls
bennothommo Nov 22, 2019
ce9321d
Change string assertContain() calls
bennothommo Nov 22, 2019
83139c1
Require PHPUnit array subset assertion package
bennothommo Nov 22, 2019
f23a747
Fix risky tests
bennothommo Nov 22, 2019
8bd98f7
Change Input facade calls to Request facade calls
bennothommo Nov 22, 2019
cca95c7
Fix missed exception docblock assertion calls
bennothommo Nov 22, 2019
d5eb7bd
Testing in PHP 7.1 is now pointless
bennothommo Nov 22, 2019
1d40158
Revert list() method call
bennothommo Nov 22, 2019
a859e17
Remove defined repository for assetic/framework
bennothommo Nov 22, 2019
09f79a3
Fix documentation for `input()` helper
bennothommo Nov 23, 2019
ebf54b3
Use compatible meyfa/phpunit-assert-gd version
bennothommo Nov 23, 2019
4e88f82
Adjust Git ignores
bennothommo Nov 23, 2019
dcef21a
Check that app is instantiated when running October facades
bennothommo Nov 23, 2019
39617a1
Re-add Input facade
bennothommo Nov 23, 2019
52cfd3c
Use new method for loading .env files
bennothommo Nov 23, 2019
83797ca
Use correct Assetic class for ScssCompiler
bennothommo Nov 23, 2019
f021bf3
Lock symfony/yaml to version 3.3.x
bennothommo Nov 23, 2019
34cd6d1
We have to use symfony/yaml 3.4
bennothommo Nov 23, 2019
ac0c976
Merge branch 'wip/laravel-5.9' into l6/unit-tests
bennothommo Jan 18, 2020
7a8e9f7
Test PHP 7.4 as well
bennothommo Jan 18, 2020
082989e
Change Laravel framework constraint back to 6.x
bennothommo Jan 19, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
max-parallel: 6
matrix:
phpVersions: ['7.1', '7.2', '7.3']
phpVersions: ['7.2', '7.3']
fail-fast: false
name: PHP ${{ matrix.phpVersions }}
steps:
Expand Down
35 changes: 21 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"php": "^7.2",
"doctrine/dbal": "^2.6",
"erusev/parsedown-extra": "~0.7",
"kriswallsmith/assetic": "~1.3",
"assetic/framework": "dev-2.0/dev",
"patchwork/jsqueeze": "~2.0",
"oyejorge/less.php": "~1.7",
"leafo/scssphp": "~0.6",
Expand All @@ -35,19 +35,20 @@
"fideloper/proxy": "^4.0"
},
"require-dev": {
"phpunit/phpunit": "^7.0",
"illuminate/database": "dev-master",
"illuminate/filesystem": "dev-master",
"illuminate/queue": "dev-master",
"illuminate/support": "dev-master",
"illuminate/log": "dev-master",
"illuminate/mail": "dev-master",
"illuminate/events": "dev-master",
"illuminate/pagination": "dev-master",
"illuminate/routing": "dev-master",
"illuminate/validation": "dev-master",
"illuminate/view": "dev-master",
"illuminate/cache": "dev-master",
"phpunit/phpunit": "^8.0",
"dms/phpunit-arraysubset-asserts": "^0.1.0",
"illuminate/database": "^6.0",
"illuminate/filesystem": "^6.0",
"illuminate/queue": "^6.0",
"illuminate/support": "^6.0",
"illuminate/log": "^6.0",
"illuminate/mail": "^6.0",
"illuminate/events": "^6.0",
"illuminate/pagination": "^6.0",
"illuminate/routing": "^6.0",
"illuminate/validation": "^6.0",
"illuminate/view": "^6.0",
"illuminate/cache": "^6.0",
"meyfa/phpunit-assert-gd": "1.1.0",
"squizlabs/php_codesniffer": "3.*",
"jakub-onderka/php-parallel-lint": "^1.0"
Expand Down Expand Up @@ -84,6 +85,12 @@
"October\\Rain\\Tests\\": "tests/"
}
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/assetic-php/assetic"
}
],
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
Expand Down
2 changes: 1 addition & 1 deletion src/Database/Attach/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ public function sizeToString()

/**
* Before the model is saved
* - check if new file data has been supplied, eg: $model->data = Input::file('something');
* - check if new file data has been supplied, eg: $model->data = Request::file('something');
*/
public function beforeSave()
{
Expand Down
6 changes: 3 additions & 3 deletions src/Database/Attach/Resizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* ->save(string 'path/to/file.jpg', int $quality);
*
* // Resize and save an image.
* Resizer::open(Input::file('field_name'))
* Resizer::open(Request::file('field_name'))
* ->resize(800, 600, 'crop')
* ->save('path/to/file.jpg', 100);
*
Expand Down Expand Up @@ -72,7 +72,7 @@ class Resizer

/**
* Instantiates the Resizer and receives the path to an image we're working with
* @param mixed $file The file array provided by Laravel's Input::file('field_name') or a path to a file
* @param mixed $file The file array provided by Laravel's Request::file('field_name') or a path to a file
* @throws Exception
*/
public function __construct($file)
Expand Down Expand Up @@ -107,7 +107,7 @@ public function __construct($file)
/**
* Static call, Laravel style.
* Returns a new Resizer object, allowing for chainable calls
* @param mixed $file The file array provided by Laravel's Input::file('field_name') or a path to a file
* @param mixed $file The file array provided by Laravel's Request::file('field_name') or a path to a file
* @return Resizer
* @throws Exception
*/
Expand Down
33 changes: 24 additions & 9 deletions src/Database/Concerns/HasRelationships.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,20 @@ trait HasRelationships
/**
* @var array Excepted relationship types, used to cycle and verify relationships.
*/
protected static $relationTypes = ['hasOne', 'hasMany', 'belongsTo', 'belongsToMany', 'morphTo', 'morphOne', 'morphMany', 'morphToMany', 'morphedByMany', 'attachOne', 'attachMany', 'hasManyThrough'];
protected static $relationTypes = [
'hasOne',
'hasMany',
'belongsTo',
'belongsToMany',
'morphTo',
'morphOne',
'morphMany',
'morphToMany',
'morphedByMany',
'attachOne',
'attachMany',
'hasManyThrough'
];


//
Expand Down Expand Up @@ -416,17 +429,17 @@ public function belongsTo($related, $foreignKey = null, $parentKey = null, $rela
* Overridden from {@link Eloquent\Model} to allow the usage of the intermediary methods to handle the relation.
* @return \October\Rain\Database\Relations\BelongsTo
*/
public function morphTo($name = null, $type = null, $id = null)
public function morphTo($name = null, $type = null, $id = null, $ownerKey = null)
{
if (is_null($name)) {
$name = $this->getRelationCaller();
}

list($type, $id) = $this->getMorphs(Str::snake($name), $type, $id);
[$type, $id] = $this->getMorphs(Str::snake($name), $type, $id);
bennothommo marked this conversation as resolved.
Show resolved Hide resolved

return empty($class = $this->{$type})
? $this->morphEagerTo($name, $type, $id)
: $this->morphInstanceTo($class, $name, $type, $id);
? $this->morphEagerTo($name, $type, $id, $ownerKey)
: $this->morphInstanceTo($class, $name, $type, $id, $ownerKey);
}

/**
Expand All @@ -435,15 +448,16 @@ public function morphTo($name = null, $type = null, $id = null)
* @param string $name
* @param string $type
* @param string $id
* @param string $ownerKey
* @return \Illuminate\Database\Eloquent\Relations\MorphTo
*/
protected function morphEagerTo($name, $type, $id)
protected function morphEagerTo($name, $type, $id, $ownerKey)
{
return new MorphTo(
$this->newQuery()->setEagerLoads([]),
$this,
$id,
null,
$ownerKey,
$type,
$name
);
Expand All @@ -456,9 +470,10 @@ protected function morphEagerTo($name, $type, $id)
* @param string $name
* @param string $type
* @param string $id
* @param string $ownerKey
* @return \Illuminate\Database\Eloquent\Relations\MorphTo
*/
protected function morphInstanceTo($target, $name, $type, $id)
protected function morphInstanceTo($target, $name, $type, $id, $ownerKey)
{
$instance = $this->newRelatedInstance(
static::getActualClassNameForMorph($target)
Expand All @@ -468,7 +483,7 @@ protected function morphInstanceTo($target, $name, $type, $id)
$instance->newQuery(),
$this,
$id,
$instance->getKeyName(),
$ownerKey ?? $instance->getKeyName(),
$type,
$name
);
Expand Down
4 changes: 2 additions & 2 deletions src/Database/Relations/MorphTo.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ class MorphTo extends MorphToBase
*/
protected $relationName;

public function __construct(Builder $query, Model $parent, $foreignKey, $otherKey, $type, $relationName)
public function __construct(Builder $query, Model $parent, $foreignKey, $ownerKey, $type, $relationName)
{
$this->relationName = $relationName;

parent::__construct($query, $parent, $foreignKey, $otherKey, $type, $relationName);
parent::__construct($query, $parent, $foreignKey, $ownerKey, $type, $relationName);

$this->addDefinedConstraints();
}
Expand Down
6 changes: 3 additions & 3 deletions src/Database/Traits/Validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use App;
use Lang;
use Input;
use Request;
use October\Rain\Database\ModelException;
use Illuminate\Support\MessageBag;
use Illuminate\Support\Facades\Validator;
Expand Down Expand Up @@ -312,8 +312,8 @@ public function validate($rules = null, $customMessages = null, $attributeNames
}
else {
$this->validationErrors = $validator->messages();
if (Input::hasSession()) {
Input::flash();
if (Request::hasSession()) {
Request::flash();
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/Halcyon/MemoryRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,18 @@ public function get($key, $default = null)
*
* @param string $key
* @param mixed $value
* @param \DateTimeInterface|\DateInterval|float|int $minutes
* @param \DateTimeInterface|\DateInterval|int $seconds
* @return void
*/
public function put($key, $value, $minutes = null)
public function put($key, $value, $seconds = null)
{
if (is_array($key)) {
$this->putMany($key, $value);
}

if (!is_null($minutes = $this->getMinutes($minutes))) {
if (!is_null($seconds = $this->getSeconds($seconds))) {
$this->putInMemoryCache($key, $value);
parent::put($key, $value, $minutes);
parent::put($key, $value, $seconds);
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/Halcyon/Traits/Validation.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php namespace October\Rain\Halcyon\Traits;

use Illuminate\Support\MessageBag;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Request;
use Illuminate\Support\Facades\Validator;
use October\Rain\Halcyon\Exception\ModelException;
use Exception;
Expand Down Expand Up @@ -204,14 +204,14 @@ public function validate($rules = null, $customMessages = null, $attributeNames
$this->validationErrors = $validator->messages();

/*
* Flash input, if available
* Flash request, if available
*/
if (
($input = Input::getFacadeRoot()) &&
method_exists($input, 'hasSession') &&
$input->hasSession()
($request = Request::getFacadeRoot()) &&
method_exists($request, 'hasSession') &&
$request->hasSession()
) {
$input->flash();
$request->flash();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Parse/Assetic/FilesystemCache.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php namespace October\Rain\Parse\Assetic;

use File;
use Assetic\Cache\CacheInterface;
use Assetic\Contracts\Cache\CacheInterface;
use RuntimeException;

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Parse/Assetic/JavascriptImporter.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php namespace October\Rain\Parse\Assetic;

use File;
use Assetic\Asset\AssetInterface;
use Assetic\Filter\FilterInterface;
use Assetic\Contracts\Asset\AssetInterface;
use Assetic\Contracts\Filter\FilterInterface;
use RuntimeException;

/**
Expand Down
9 changes: 4 additions & 5 deletions src/Parse/Assetic/LessCompiler.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<?php namespace October\Rain\Parse\Assetic;

use Event;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bennothommo @jaxwilko @christianWilling is there value in moving this filter to the Assetic core? I'm not 100% sure what it does differently from the already included Assetic filters.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the looks of it the October one also add's in file version hashing functionality, could merge it in this filter or add in that functionality as an option for the Assetic project?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't spent enough time on this filter or the core Assetic filter to understand the difference between those two options @jaxwilko, are you able to explain it in a bit more detail for me?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaxwilko ping

use Less_Parser;
use Assetic\Asset\AssetInterface;
use Assetic\Contracts\Asset\AssetInterface;
use Assetic\Factory\AssetFactory;
use Assetic\Filter\LessphpFilter;
use Assetic\Filter\HashableInterface;
use Assetic\Filter\DependencyExtractorInterface;
use Assetic\Filter\FilterInterface;
use Assetic\Contracts\Filter\HashableInterface;
use Assetic\Contracts\Filter\DependencyExtractorInterface;
use Assetic\Contracts\Filter\FilterInterface;

/**
* Less.php Compiler Filter
Expand Down
9 changes: 4 additions & 5 deletions src/Parse/Assetic/ScssCompiler.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<?php namespace October\Rain\Parse\Assetic;

use Event;
Copy link
Contributor

@LukeTowers LukeTowers Nov 22, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bennothommo @jaxwilko @christianWilling is there value in moving this filter to the Assetic core? I'm not 100% sure what it does differently from the already included Assetic filters.

use Assetic\Asset\AssetInterface;
use Assetic\Contracts\Asset\AssetInterface;
use Assetic\Factory\AssetFactory;
use Assetic\Filter\ScssphpFilter;
use Assetic\Filter\HashableInterface;
use Assetic\Filter\DependencyExtractorInterface;
use Assetic\Filter\FilterInterface;
use Assetic\Contracts\Filter\ScssphpFilter;
use Assetic\Contracts\Filter\HashableInterface;
use Assetic\Contracts\Filter\DependencyExtractorInterface;

/**
* Less.php Compiler Filter
Expand Down
4 changes: 2 additions & 2 deletions src/Parse/Assetic/StylesheetMinify.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php namespace October\Rain\Parse\Assetic;

use Assetic\Asset\AssetInterface;
use Assetic\Filter\FilterInterface;
use Assetic\Contracts\Asset\AssetInterface;
use Assetic\Contracts\Filter\FilterInterface;

/**
* Minify CSS Filter
Expand Down
2 changes: 1 addition & 1 deletion src/Support/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ $class = MyClass::instance();

**input()**

Similar to `Input::get()` this returns an input parameter or the default value. However it supports HTML Array names. Booleans are also converted from strings.
Similar to `Request::get()` this returns an input parameter or the default value. However it supports HTML Array names. Booleans are also converted from strings.
```php
$value = input('value', 'not found');
$name = input('contact[name]');
Expand Down
4 changes: 2 additions & 2 deletions src/Support/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
function input($name = null, $default = null)
{
if ($name === null) {
return Input::all();
return Request::all();
}

/*
Expand All @@ -27,7 +27,7 @@ function input($name = null, $default = null)
$name = implode('.', October\Rain\Html\Helper::nameToArray($name));
}

return Input::get($name, $default);
return Request::get($name, $default);
}
}

Expand Down
6 changes: 3 additions & 3 deletions tests/Config/ConfigWriterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ public function testToContent()

$this->assertArrayHasKey('default', $result);
$this->assertEquals('pgsql', $result['default']);
$this->assertInternalType('array', $result);
$this->assertIsArray($result);
$this->assertArrayHasKey('redis', $result);
$this->assertInternalType('array', $result['redis']);
$this->assertIsArray($result['redis']);
$this->assertArrayHasKey('default', $result['redis']);
$this->assertInternalType('array', $result['redis']['default']);
$this->assertIsArray($result['redis']['default']);
$this->assertArrayHasKey('host', $result['redis']['default']);
$this->assertArrayHasKey('password', $result['redis']['default']);
$this->assertArrayHasKey('port', $result['redis']['default']);
Expand Down
2 changes: 1 addition & 1 deletion tests/Database/Attach/ResizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class ResizerTest extends TestCase
/**
* Remove the temporary file after running each test.
*/
protected function tearDown()
protected function tearDown(): void
{
@unlink($this->tmpTarget);
@rmdir(self::TMP_TEST_FILE_PATH);
Expand Down
2 changes: 1 addition & 1 deletion tests/Database/SortableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class SortableTest extends TestCase
{
public function setUp()
public function setUp(): void
{
$capsule = new Illuminate\Database\Capsule\Manager;
$capsule->addConnection([
Expand Down
Loading