diff --git a/.github/workflows/psalm.yml b/.github/workflows/psalm.yml index 9068ed0c..d00f2bb8 100644 --- a/.github/workflows/psalm.yml +++ b/.github/workflows/psalm.yml @@ -9,6 +9,7 @@ jobs: name: Run Psalm runs-on: ubuntu-latest + steps: - name: Checkout code uses: actions/checkout@v3 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 698559da..40a2155c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,9 +10,22 @@ concurrency: jobs: tests: + services: + neo4j: + image: neo4j:latest + ports: + - 7474:7474 + - 7687:7687 + env: + NEO4J_AUTH: neo4j/password + options: >- + --health-cmd "wget --no-verbose --tries=1 --spider localhost:7474 || exit 1" + --health-interval 10s + --health-retries 5 + --health-timeout 5s + name: Run PHPUnit Tests runs-on: ubuntu-latest - steps: - name: Checkout code uses: actions/checkout@v3 @@ -35,7 +48,7 @@ jobs: - name: Run Tests without phpunit.xml env: - NEO4J_ADDRESS: ${{ secrets.NEO4J_ADDRESS }} - NEO4J_USERNAME: ${{ secrets.NEO4J_USERNAME }} - NEO4J_PASSWORD: ${{ secrets.NEO4J_PASSWORD }} + NEO4J_ADDRESS: "http://localhost:7474" + NEO4J_USERNAME: "neo4j" + NEO4J_PASSWORD: "password" run: vendor/bin/phpunit --configuration phpunit.dist.xml diff --git a/.github/workflows/testaura.yml b/.github/workflows/testaura.yml new file mode 100644 index 00000000..c69b7533 --- /dev/null +++ b/.github/workflows/testaura.yml @@ -0,0 +1,44 @@ +name: Test Neo4j Aura + +on: + push: + branches: + - main + workflow_dispatch: # Allows manual trigger + +concurrency: + group: neo4j-aura-test-main + cancel-in-progress: true + +jobs: + tests-aura: + name: Run PHPUnit Tests with Neo4j Aura + runs-on: ubuntu-latest + + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.2 + tools: composer, xdebug + + - name: Cache Composer dependencies + uses: actions/cache@v3 + with: + path: vendor + key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install dependencies + run: composer install --no-progress --prefer-dist + + - name: Run Tests + env: + NEO4J_ADDRESS: ${{ secrets.NEO4J_ADDRESS }} + NEO4J_USERNAME: ${{ secrets.NEO4J_USERNAME }} + NEO4J_PASSWORD: ${{ secrets.NEO4J_PASSWORD }} + run: vendor/bin/phpunit --configuration phpunit.dist.xml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..ad10216e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +# Use an official PHP image as the base image +FROM php:8.2-fpm + +# Install necessary extensions (e.g., for Composer) +RUN apt-get update && apt-get install -y libpng-dev libjpeg-dev libfreetype6-dev \ + && docker-php-ext-configure gd --with-freetype --with-jpeg \ + && docker-php-ext-install gd + +# Set working directory +WORKDIR /var/www + +# Copy the composer.phar file to the container +COPY --from=composer:latest /usr/bin/composer /usr/bin/composer + +# Expose PHP-FPM port +EXPOSE 9000 + +# Start PHP-FPM server +CMD ["php-fpm"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..17a2afd7 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,44 @@ +version: '3.8' + +services: + # PHP Service + app: + build: + context: . + dockerfile: Dockerfile + container_name: php-app + working_dir: /var/www + volumes: + - .:/var/www + networks: + - mynetwork + ports: + - "9000:9000" # Exposing port for PHP-FPM + + # Composer Service + composer: + image: composer:latest + container_name: composer + volumes: + - .:/var/www + working_dir: /var/www + networks: + - mynetwork + command: ["install", "--no-progress", "--prefer-dist"] + + # Neo4j Service (Optional, if you need Neo4j) + neo4j: + image: neo4j:latest + container_name: neo4j + environment: + - NEO4J_AUTH=neo4j/password + ports: + - "7474:7474" # Web interface + - "7687:7687" # Bolt protocol + networks: + - mynetwork + +# Define a network for communication between containers +networks: + mynetwork: + driver: bridge diff --git a/tests/Integration/Neo4jQueryAPIIntegrationTest.php b/tests/Integration/Neo4jQueryAPIIntegrationTest.php index bd5f1f8c..88b3f2f0 100644 --- a/tests/Integration/Neo4jQueryAPIIntegrationTest.php +++ b/tests/Integration/Neo4jQueryAPIIntegrationTest.php @@ -393,18 +393,7 @@ public function testInvalidQueryException(): void } } - public function testCreateDuplicateConstraintException(): void - { - try { - $this->api->run('CREATE CONSTRAINT person_name FOR (n:Person1) REQUIRE n.name IS UNIQUE', []); - $this->fail('Expected a Neo4jException to be thrown.'); - } catch (Neo4jException $e) { - // $errorMessages = $e->getErrorType() . $e->errorSubType() . $e->errorName(); - $this->assertInstanceOf(Neo4jException::class, $e); - $this->assertEquals('Neo.ClientError.Schema.EquivalentSchemaRuleAlreadyExists', $e->getErrorCode()); - $this->assertNotEmpty($e->getMessage()); - } - } + public function testWithExactNames(): void {