Skip to content

Commit eb07cf7

Browse files
committed
[JsonLdView] - Class not found run time exception #64
Fixes bug and adds unit tests
1 parent c2cbaa1 commit eb07cf7

5 files changed

Lines changed: 43 additions & 10 deletions

File tree

plugins/json-ld-view/src/Controller/Component/JsonLdContextComponent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function build(string $entityName): array
4747
{
4848
$table = NamespaceUtility::findClass(
4949
Configure::read('App.namespace') . '\Model\Table\\',
50-
Inflector::pluralize($entityName) . 'Table'
50+
Inflector::camelize(Inflector::pluralize($entityName)) . 'Table'
5151
);
5252

5353
$connection = ConnectionManager::get('default');

plugins/json-ld-view/tests/TestCase/Controller/JsonLdControllerTest.php

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function setUp(): void
2525
static::setAppNamespace('MixerApi\JsonLdView\Test\App');
2626
}
2727

28-
public function testContexts()
28+
public function test_context_singular_camelcase()
2929
{
3030
$this->get('/contexts/Actor');
3131

@@ -36,7 +36,40 @@ public function testContexts()
3636
$this->assertEquals('https://schema.org/givenName', $object->{'@context'}->first_name);
3737
}
3838

39-
public function testVocab()
39+
public function test_context_plural_camelcase()
40+
{
41+
$this->get('/contexts/Actors');
42+
43+
$body = (string)$this->_response->getBody();
44+
$object = json_decode($body);
45+
46+
$this->assertResponseOk();
47+
$this->assertEquals('https://schema.org/givenName', $object->{'@context'}->first_name);
48+
}
49+
50+
public function test_context_singular_lowercase()
51+
{
52+
$this->get('/contexts/actor');
53+
54+
$body = (string)$this->_response->getBody();
55+
$object = json_decode($body);
56+
57+
$this->assertResponseOk();
58+
$this->assertEquals('https://schema.org/givenName', $object->{'@context'}->first_name);
59+
}
60+
61+
public function test_context_plural_lowercase()
62+
{
63+
$this->get('/contexts/actors');
64+
65+
$body = (string)$this->_response->getBody();
66+
$object = json_decode($body);
67+
68+
$this->assertResponseOk();
69+
$this->assertEquals('https://schema.org/givenName', $object->{'@context'}->first_name);
70+
}
71+
72+
public function test_vocab()
4073
{
4174
$this->get('/vocab');
4275

plugins/json-ld-view/tests/TestCase/JsonLdSchemaTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
class JsonLdSchemaTest extends TestCase
99
{
10-
public function testJsonLdSchema()
10+
public function test_jsonld_schema()
1111
{
1212
$property = 'test';
1313
$url = 'http://schema.org/test';
@@ -18,9 +18,9 @@ public function testJsonLdSchema()
1818
$this->assertEquals($desc, $jsonLdSchema->getDescription());
1919
}
2020

21-
public function testSetSchemaUrlException()
21+
public function test_set_schema_url_exception()
2222
{
2323
$this->expectException(\InvalidArgumentException::class);
2424
(new JsonLdSchema())->setSchemaUrl('');
2525
}
26-
}
26+
}

plugins/json-ld-view/tests/TestCase/JsonSerializerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function setUp(): void
8787
/**
8888
* Test collection serialization and deserialization
8989
*/
90-
public function testCollection()
90+
public function test_collection()
9191
{
9292
$actor = FactoryLocator::get('Table')->get('Actors');
9393
$result = $actor->find()->contain('Films')->limit(1)->all();
@@ -109,7 +109,7 @@ public function testCollection()
109109
/**
110110
* Test item serialization and deserialization
111111
*/
112-
public function testItem()
112+
public function test_item()
113113
{
114114
$actor = FactoryLocator::get('Table')->get('Actors');
115115
$result = $actor->get(1, [
@@ -133,7 +133,7 @@ public function testItem()
133133
/**
134134
* Test JsonSerializer->getData()
135135
*/
136-
public function testGetData()
136+
public function test_get_data()
137137
{
138138
$actor = FactoryLocator::get('Table')->get('Actors');
139139
$result = $actor->find()->contain('Films')->limit(1)->all();

plugins/json-ld-view/tests/TestCase/SchemaMapperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class SchemaMapperTest extends TestCase
1111
{
12-
public function testSchemaMapper()
12+
public function test_schema_mapper()
1313
{
1414
$model = (new ModelFactory(
1515
ConnectionManager::get('default'),

0 commit comments

Comments
 (0)