Merge branch 'master' into PHRAS-2680-webhook-privacy-and-security

This commit is contained in:
Nicolas Maillat
2019-11-26 17:46:31 +01:00
committed by GitHub
84 changed files with 3445 additions and 1777 deletions

View File

@@ -230,6 +230,7 @@ class FieldsTest extends \PhraseanetAuthenticatedWebTestCase
'vocabulary-type' => 'User',
'vocabulary-restricted' => true,
'gui_editable' => true,
'gui_visible' => true,
'generate_cterms' => true,
]);

View File

@@ -48,6 +48,7 @@ class TextNodeTest extends \PHPUnit_Framework_TestCase
$query_context->getUnrestrictedFields()->willReturn([$field]);
$query_context->getPrivateFields()->willReturn([]);
$query_context->localizeField($field)->willReturn(['foo.fr', 'foo.en']);
$query_context->truncationField($field)->willReturn([]);
$node = new TextNode('bar', new Context('baz'));
$query = $node->buildQuery($query_context->reveal());
@@ -80,12 +81,18 @@ class TextNodeTest extends \PHPUnit_Framework_TestCase
$query_context
->localizeField($public_field)
->willReturn(['foo.fr', 'foo.en']);
$query_context
->truncationField($public_field)
->willReturn([]);
$query_context
->getPrivateFields()
->willReturn([$private_field]);
$query_context
->localizeField($private_field)
->willReturn(['private_caption.bar.fr', 'private_caption.bar.en']);
$query_context
->truncationField($private_field)
->willReturn([]);
$node = new TextNode('baz');
$query = $node->buildQuery($query_context->reveal());
@@ -136,6 +143,7 @@ class TextNodeTest extends \PHPUnit_Framework_TestCase
$query_context->getUnrestrictedFields()->willReturn([$field]);
$query_context->getPrivateFields()->willReturn([]);
$query_context->localizeField($field)->willReturn(['foo.fr', 'foo.en']);
$query_context->truncationField($field)->willReturn([]);
$node = new TextNode('bar');
$node->setConcepts([
@@ -180,12 +188,18 @@ class TextNodeTest extends \PHPUnit_Framework_TestCase
$query_context
->localizeField($public_field)
->willReturn(['foo.fr', 'foo.en']);
$query_context
->truncationField($public_field)
->willReturn([]);
$query_context
->getPrivateFields()
->willReturn([$private_field]);
$query_context
->localizeField($private_field)
->willReturn(['private_caption.bar.fr', 'private_caption.bar.en']);
$query_context
->truncationField($private_field)
->willReturn([]);
$node = new TextNode('baz');
$node->setConcepts([

View File

@@ -18,7 +18,7 @@ class QueryContextTest extends \PHPUnit_Framework_TestCase
{
$structure = $this->prophesize(Structure::class)->reveal();
$available_locales = ['ab', 'cd', 'ef'];
$context = new QueryContext($structure, $available_locales, 'fr');
$context = new QueryContext(null, $structure, $available_locales, 'fr');
$narrowed = $context->narrowToFields(['some_field']);
$this->assertEquals(['some_field'], $narrowed->getFields());
}
@@ -33,10 +33,10 @@ class QueryContextTest extends \PHPUnit_Framework_TestCase
'bar' => $bar_field
]);
$context = new QueryContext($structure->reveal(), [], 'fr');
$context = new QueryContext(null, $structure->reveal(), [], 'fr');
$this->assertEquals([$foo_field, $bar_field], $context->getUnrestrictedFields());
$narrowed_context = new QueryContext($structure->reveal(), [], 'fr', ['foo']);
$narrowed_context = new QueryContext(null, $structure->reveal(), [], 'fr', ['foo']);
$this->assertEquals([$foo_field], $narrowed_context->getUnrestrictedFields());
}
@@ -50,10 +50,10 @@ class QueryContextTest extends \PHPUnit_Framework_TestCase
'bar' => $bar_field
]);
$context = new QueryContext($structure->reveal(), [], 'fr');
$context = new QueryContext(null, $structure->reveal(), [], 'fr');
$this->assertEquals([$foo_field, $bar_field], $context->getPrivateFields());
$narrowed_context = new QueryContext($structure->reveal(), [], 'fr', ['foo']);
$narrowed_context = new QueryContext(null, $structure->reveal(), [], 'fr', ['foo']);
$this->assertEquals([$foo_field], $narrowed_context->getPrivateFields());
}
}

View File

@@ -36,6 +36,7 @@ class StructureTest extends \PHPUnit_Framework_TestCase
$field->isFacet()->willReturn(false);
$field->hasConceptInference()->willReturn(false);
$field->getDependantCollections()->willReturn(['1']);
$field->get_databox_id()->willReturn('1');
$structure->add($field->reveal());
$this->assertCount(1, $structure->getAllFields());
@@ -60,6 +61,7 @@ class StructureTest extends \PHPUnit_Framework_TestCase
$field->isPrivate()->willReturn(false);
$field->isFacet()->willReturn(false);
$field->hasConceptInference()->willReturn(false);
$field->get_databox_id()->willReturn('1');
$other = new Field('foo', FieldMapping::TYPE_STRING);

View File

@@ -14,14 +14,14 @@ use Alchemy\Phrasea\SearchEngine\Elastic\Structure\Typed;
class ValueCheckerTest extends \PHPUnit_Framework_TestCase
{
/**
* @dataProvider escapeRawProvider
* @dataProvider valueCheckerProvider
*/
public function testValueCompatibility($subject, $value, $compatible)
{
$this->assertEquals($compatible, ValueChecker::isValueCompatible($subject, $value));
}
public function escapeRawProvider()
public function valueCheckerProvider()
{
$values = [
[FieldMapping::TYPE_FLOAT , 42 , true ],