-
-
Notifications
You must be signed in to change notification settings - Fork 342
Add Indexes via Schema #357
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
Changes from all commits
56a3fc0
ec14e63
e9be5d7
a921116
f3ff221
c3531e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -190,6 +190,24 @@ public function testUpdateSchemaCurl() | |
} | ||
} | ||
|
||
public function testUpdateMultipleNoDuplicateFields() | ||
{ | ||
$schema = self::$schema; | ||
$schema->save(); | ||
$schema->addString('name'); | ||
$schema->update(); | ||
|
||
$getSchema = new ParseSchema('SchemaTest'); | ||
$result = $getSchema->get(); | ||
$this->assertEquals(count($result['fields']), 5); | ||
|
||
$schema->update(); | ||
|
||
$getSchema = new ParseSchema('SchemaTest'); | ||
$result = $getSchema->get(); | ||
$this->assertEquals(count($result['fields']), 5); | ||
} | ||
|
||
public function testUpdateWrongFieldType() | ||
{ | ||
$this->setExpectedException('Exception', 'WrongType is not a valid type.'); | ||
|
@@ -411,7 +429,7 @@ public function testBadSchemaGet() | |
*/ | ||
public function testBadSchemaSave() | ||
{ | ||
$this->setExpectedException('\Parse\ParseException'); | ||
$this->setExpectedException('\Exception'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One last thing. Is there a particular reason you changed the expected exception here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://github.com/dplewis/parse-php-sdk/blob/schema-index/src/Parse/ParseSchema.php#L277 It throws exception instead of parse exception. The test were failing locally for some reason. On a side note testBadSchemaDelete doesn't pass locally for me. If I remove the spaces from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh that's something I missed. That change is good then. And quick question, are you running these tests on a windows machine by chance? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MacOS 10.12.6 Sierra There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, good on mine and we're on the same setup. There's certainly a reason for it but I wonder what 🤔 . Anyways this is all good then. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for waiting. Now onto 1.4.0 👍 |
||
|
||
$user = new ParseUser(); | ||
$user->setUsername('schema-user'); | ||
|
@@ -427,7 +445,7 @@ public function testBadSchemaSave() | |
*/ | ||
public function testBadSchemaUpdate() | ||
{ | ||
$this->setExpectedException('\Parse\ParseException'); | ||
$this->setExpectedException('\Exception'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same question for this here too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same above |
||
|
||
$user = new ParseUser(); | ||
$user->setUsername('schema-user'); | ||
|
@@ -449,8 +467,67 @@ public function testBadSchemaDelete() | |
$user->setUsername('schema-user'); | ||
$user->setPassword('basicpassword'); | ||
$user->signUp(); | ||
|
||
$schema = new ParseSchema(self::$badClassName); | ||
$schema->delete(); | ||
} | ||
|
||
public function testCreateIndexSchema() | ||
{ | ||
$schema = self::$schema; | ||
$schema->addString('name'); | ||
$index = [ 'name' => 1 ]; | ||
$schema->addIndex('test_index', $index); | ||
$schema->save(); | ||
|
||
$getSchema = new ParseSchema('SchemaTest'); | ||
$result = $getSchema->get(); | ||
$this->assertNotNull($result['indexes']['test_index']); | ||
} | ||
|
||
public function testUpdateIndexSchema() | ||
{ | ||
$schema = self::$schema; | ||
$schema->save(); | ||
$schema->addString('name'); | ||
$index = [ 'name' => 1 ]; | ||
$schema->addIndex('test_index', $index); | ||
$schema->update(); | ||
|
||
$getSchema = new ParseSchema('SchemaTest'); | ||
$result = $getSchema->get(); | ||
$this->assertNotNull($result['indexes']['test_index']); | ||
} | ||
|
||
public function testDeleteIndexSchema() | ||
{ | ||
$schema = self::$schema; | ||
$schema->save(); | ||
$schema->addString('name'); | ||
$index = [ 'name' => 1 ]; | ||
$schema->addIndex('test_index', $index); | ||
$schema->update(); | ||
|
||
$getSchema = new ParseSchema('SchemaTest'); | ||
$result = $getSchema->get(); | ||
$this->assertNotNull($result['indexes']['test_index']); | ||
|
||
$schema->deleteIndex('test_index'); | ||
$schema->update(); | ||
$result = $getSchema->get(); | ||
$this->assertEquals(array_key_exists('text_index', $result['indexes']), false); | ||
} | ||
|
||
public function testIndexNameException() | ||
{ | ||
$schema = self::$schema; | ||
$this->setExpectedException('\Exception', 'index name may not be null.'); | ||
$schema->addIndex(null, null); | ||
} | ||
|
||
public function testIndexException() | ||
{ | ||
$schema = self::$schema; | ||
$this->setExpectedException('\Exception', 'index may not be null.'); | ||
$schema->addIndex('name', null); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a few lines showing how to check existing indexes?