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

Added ORDER BY to delete operation + update composer.json + fix tests #7

Merged
merged 21 commits into from
Apr 10, 2022
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
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
100 changes: 100 additions & 0 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Tests

# Run this workflow every time a new commit pushed to your repository
on:
push:
paths-ignore:
- '**/*.md'
pull_request:
paths-ignore:
- '**/*.md'

jobs:
tests:
runs-on: ${{ matrix.operating-system }}
if: (github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository)

strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-20.04]
php-versions: ['7.4', '8.0', '8.1']
dependencies: ['no', 'low', 'beta']
exclude:
- operating-system: ubuntu-20.04
php-versions: '8.1'
dependencies: 'low'

name: PHP ${{ matrix.php-versions }} - ${{ matrix.dependencies }}

env:
COMPOSER_NO_INTERACTION: 1
extensions: curl json libxml dom
key: cache-v1 # can be any string, change to clear the extension cache.

steps:

# Checks out a copy of your repository on the ubuntu machine
- name: Checkout code
uses: actions/checkout@v2

- name: Setup cache environment
id: extcache
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php-versions }}
extensions: ${{ env.extensions }}
key: ${{ env.key }}

- name: Cache PHP Extensions
uses: actions/cache@v2
with:
path: ${{ steps.extcache.outputs.dir }}
key: ${{ steps.extcache.outputs.key }}
restore-keys: ${{ steps.extcache.outputs.key }}

- name: Cache Composer Dependencies
uses: actions/cache@v1
with:
path: ~/.composer/cache/files
key: dependencies-composer-${{ hashFiles('composer.json') }}

- name: Fix beta
if: ${{ matrix.dependencies == 'beta' }}
run: perl -pi -e 's/^}$/,"minimum-stability":"beta"}/' composer.json

- name: Setup PHP Action
uses: shivammathur/[email protected]
with:
php-version: ${{ matrix.php-versions }}
extensions: ${{ env.extensions }}
coverage: xdebug
tools: pecl, composer

- name: PHP Show modules
run: php -m

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install Composer dependencies
if: ${{ matrix.dependencies != 'low' }}
run: composer update --no-interaction

- name: Install Composer dependencies
if: ${{ matrix.dependencies == 'low' }}
run: composer update -vvv --prefer-lowest --prefer-stable --no-interaction

- name: Validate files
run: composer validate-files

- name: Run tests
run: composer run-tests
43 changes: 0 additions & 43 deletions .github/workflows/run-tests.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
composer.phar
composer.lock
.DS_Store
.php-cs-fixer.cache
.phpunit.result.cache
15 changes: 6 additions & 9 deletions README.markdown
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
[![Build Status](https://travis-ci.org/lazychaser/laravel-nestedset.svg?branch=master)](https://travis-ci.org/lazychaser/laravel-nestedset)
[![Total Downloads](https://poser.pugx.org/kalnoy/nestedset/downloads.svg)](https://packagist.org/packages/kalnoy/nestedset)
[![Latest Stable Version](https://poser.pugx.org/kalnoy/nestedset/v/stable.svg)](https://packagist.org/packages/kalnoy/nestedset)
[![Latest Unstable Version](https://poser.pugx.org/kalnoy/nestedset/v/unstable.svg)](https://packagist.org/packages/kalnoy/nestedset)
[![License](https://poser.pugx.org/kalnoy/nestedset/license.svg)](https://packagist.org/packages/kalnoy/nestedset)
[![Total Downloads](https://poser.pugx.org/lychee-org/nestedset/downloads.svg)](https://packagist.org/packages/lychee-org/nestedset)
[![Latest Stable Version](https://poser.pugx.org/lychee-org/nestedset/v/stable.svg)](https://packagist.org/packages/lychee-org/nestedset)
[![Latest Unstable Version](https://poser.pugx.org/lychee-org/nestedset/v/unstable.svg)](https://packagist.org/packages/lychee-org/nestedset)
[![License](https://poser.pugx.org/lychee-org/nestedset/license.svg)](https://packagist.org/packages/lychee-org/nestedset)

This is a Laravel 4-8 package for working with trees in relational databases.

It is a fork of [lazychaser/laravel-nestedset](https://github.com/lazychaser/laravel-nestedset) and contains patches which are required for using the library with [Lychee](https://github.com/LycheeOrg/Lychee).

* **Laravel 8.0** is supported since v6
* **Laravel 5.7, 5.8, 6.0, 7.0** is supported since v5
* **Laravel 5.5, 5.6** is supported since v4.3
* **Laravel 5.2, 5.3, 5.4** is supported since v4
* **Laravel 5.1** is supported in v3
* **Laravel 4** is supported in v2

Although this project is completely free for use, I appreciate any support!

- __[Donate via PayPal](https://www.paypal.me/lazychaser)__

__Contents:__

- [Theory](#what-are-nested-sets)
Expand Down
23 changes: 14 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kalnoy/nestedset",
"description": "Nested Set Model for Laravel 5.7 and up",
"name": "lychee-org/nestedset",
"description": "Nested Set Model for Laravel 5.7 and up (fork with patches for Lychee)",
"keywords": ["laravel", "nested sets", "nsm", "database", "hierarchy"],
"license": "MIT",

Expand All @@ -25,9 +25,19 @@
},

"require-dev": {
"phpunit/phpunit": "7.*|8.*|9.*"
"php-parallel-lint/php-parallel-lint": "^1.2",
"phpunit/phpunit": "^9.5.20"
},

"scripts": {
"run-tests": [
"vendor/bin/phpunit -c phpunit.xml",
"vendor/bin/phpunit -c phpunit.xml --coverage-clover=coverage.xml"
],
"validate-files": [
"vendor/bin/parallel-lint --exclude vendor ."
]
},
"minimum-stability": "dev",
"prefer-stable": true,

Expand All @@ -41,10 +51,5 @@
"Kalnoy\\Nestedset\\NestedSetServiceProvider"
]
}
},
"scripts": {
"test": [
"@php ./vendor/bin/phpunit"
]
}
}
}
31 changes: 11 additions & 20 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="phpunit.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
>
<testsuites>
<testsuite name="Package Test Suite">
<directory suffix=".php">./tests/</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>./src</directory>
</whitelist>
</filter>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" bootstrap="phpunit.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory>./src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Package Test Suite">
<directory suffix=".php">./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
2 changes: 1 addition & 1 deletion src/BaseRelation.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function addEagerConstraints(array $models)
// The first model in the array is always the parent, so add the scope constraints based on that model.
// @link https://github.com/laravel/framework/pull/25240
// @link https://github.com/lazychaser/laravel-nestedset/issues/351
optional($models[0])->applyNestedSetScope($this->query);
optional(reset($models))->applyNestedSetScope($this->query);

$this->query->whereNested(function (Builder $inner) use ($models) {
// We will use this query in order to apply constraints to the
Expand Down
2 changes: 1 addition & 1 deletion src/NestedSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public static function getDefaultColumns()
*/
public static function isNode($node)
{
return is_object($node) && in_array(NodeTrait::class, (array)$node);
return $node instanceof Node;
}

}
Loading