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

Use Jane v8 #182

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
13 changes: 9 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
"homepage": "https://jolicode.com/"
}
],
"repositories": [
{
"type": "vcs",
"url": "https://github.com/Korbeil/jane-v8"
}
],
"require": {
"php": ">=8.0",
"ext-json": "*",
Expand All @@ -22,13 +28,12 @@
"symfony/deprecation-contracts": "^2.4 || ^3.0",
"symfony/property-access": "^5.4 || ^6.0",
"symfony/property-info": "^5.4 || ^6.0",
"symfony/serializer": "^5.4 || ^6.0",
"symfony/yaml": "^5.4 || ^6.0"
"symfony/serializer": "^7.0",
"symfony/yaml": "^7.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.17.0",
"jane-php/json-schema": "^7.4",
"jane-php/json-schema-runtime": "^7.4",
"jane-php/jane-php": "@dev",
"phpstan/phpstan": "^1.9",
"symfony/browser-kit": "^5.4 || ^6.0",
"symfony/framework-bundle": "^5.4.17 || ^6.0",
Expand Down
38 changes: 14 additions & 24 deletions tests/Jane/JaneTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@

namespace JoliCode\Elastically\Tests\Jane;

use Jane\Component\JsonSchema\Console\Command\GenerateCommand;
use Jane\Component\JsonSchema\Console\Loader\ConfigLoader;
use Jane\Component\JsonSchema\Console\Loader\SchemaLoader;
use Jane\Component\JsonSchemaGenerator\Configuration;
use Jane\Component\JsonSchemaGenerator\Generator;
use JoliCode\Elastically\Client;
use JoliCode\Elastically\IndexBuilder;
use JoliCode\Elastically\Indexer;
Expand All @@ -25,11 +24,9 @@
use JoliCode\Elastically\ResultSetBuilder;
use JoliCode\Elastically\Serializer\StaticContextBuilder;
use JoliCode\Elastically\Tests\Jane\generated\Model\MyModel;
use JoliCode\Elastically\Tests\Jane\generated\Model\MyModelIngredientsItemAnyOf;
use JoliCode\Elastically\Tests\Jane\generated\Normalizer\JaneObjectNormalizer;
use JoliCode\Elastically\Tests\Jane\generated\Model\MyModelIngredients;
use JoliCode\Elastically\Tests\Jane\generated\Normalizer\JaneNormalizer;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\NullOutput;
use Symfony\Component\Serializer\Encoder\JsonDecode;
use Symfony\Component\Serializer\Encoder\JsonEncode;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
Expand All @@ -41,17 +38,16 @@ class JaneTest extends TestCase
public function testCreateIndexAndSearchWithJaneObject()
{
// Build the models
$command = new GenerateCommand(new ConfigLoader(), new SchemaLoader());
$inputArray = new ArrayInput([
'--config-file' => __DIR__ . '/jane-config.php',
], $command->getDefinition());

$command->execute($inputArray, new NullOutput());
$generator = new Generator(new Configuration(
outputDirectory: __DIR__ . '/generated/',
baseNamespace: 'JoliCode\\Elastically\\Tests\\Jane\\generated',
));
$generator->fromPath(__DIR__ . '/schema.json', 'MyModel');

// Build the Serializer
$normalizers = [
new ArrayDenormalizer(),
new JaneObjectNormalizer(),
new JaneNormalizer(),
];
$encoders = [
new JsonEncoder(
Expand Down Expand Up @@ -81,16 +77,10 @@ public function testCreateIndexAndSearchWithJaneObject()
$indexBuilder->markAsLive($index, 'beers');

// Create a DTO
$dto = new MyModel();
$dto->setName('La Montreuilloise Smoked Porter');
$dto->setPrice(3.20);
$ingredient1 = new MyModelIngredientsItemAnyOf();
$ingredient1->setName('Water');
$ingredient2 = new MyModelIngredientsItemAnyOf();
$ingredient2->setName('Malt');
$ingredient3 = new MyModelIngredientsItemAnyOf();
$ingredient3->setName('Hops');
$dto->setIngredients([$ingredient1, $ingredient2, $ingredient3]);
$ingredient1 = new MyModelIngredients('Water');
$ingredient2 = new MyModelIngredients('Malt');
$ingredient3 = new MyModelIngredients('Hops');
$dto = new MyModel('La Montreuilloise Smoked Porter', 3.20, [$ingredient1, $ingredient2, $ingredient3]);

// Index the DTO
$indexer->scheduleIndex('beers', new Document('123', $dto));
Expand Down
18 changes: 0 additions & 18 deletions tests/Jane/jane-config.php

This file was deleted.

2 changes: 2 additions & 0 deletions tests/SearchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ public function supportsDenormalization($data, $type, $format = null, array $con
public function serialize(mixed $data, string $format, array $context = []): string {}

public function deserialize(mixed $data, string $type, string $format, array $context = []): mixed {}

public function getSupportedTypes(?string $format): array {}
}

class SearchTestDto
Expand Down
Loading