Use right assert method

This commit is contained in:
Jeremiah VALERIE 2018-08-31 11:23:02 +02:00
parent eb7ff7048d
commit 62de403f27
No known key found for this signature in database
GPG Key ID: 668676FD50ADF244
7 changed files with 40 additions and 42 deletions

View File

@ -31,26 +31,24 @@ class ReactPromiseAdapterTest extends TestCase
{ {
$reactAdapter = new ReactPromiseAdapter(); $reactAdapter = new ReactPromiseAdapter();
$this->assertSame( $this->assertTrue(
true,
$reactAdapter->isThenable(new ReactPromise(function () { $reactAdapter->isThenable(new ReactPromise(function () {
})) }))
); );
$this->assertSame(true, $reactAdapter->isThenable(new FulfilledPromise())); $this->assertTrue($reactAdapter->isThenable(new FulfilledPromise()));
$this->assertSame(true, $reactAdapter->isThenable(new RejectedPromise())); $this->assertTrue($reactAdapter->isThenable(new RejectedPromise()));
$this->assertSame( $this->assertTrue(
true,
$reactAdapter->isThenable(new LazyPromise(function () { $reactAdapter->isThenable(new LazyPromise(function () {
})) }))
); );
$this->assertSame(false, $reactAdapter->isThenable(false)); $this->assertFalse($reactAdapter->isThenable(false));
$this->assertSame(false, $reactAdapter->isThenable(true)); $this->assertFalse($reactAdapter->isThenable(true));
$this->assertSame(false, $reactAdapter->isThenable(1)); $this->assertFalse($reactAdapter->isThenable(1));
$this->assertSame(false, $reactAdapter->isThenable(0)); $this->assertFalse($reactAdapter->isThenable(0));
$this->assertSame(false, $reactAdapter->isThenable('test')); $this->assertFalse($reactAdapter->isThenable('test'));
$this->assertSame(false, $reactAdapter->isThenable('')); $this->assertFalse($reactAdapter->isThenable(''));
$this->assertSame(false, $reactAdapter->isThenable([])); $this->assertFalse($reactAdapter->isThenable([]));
$this->assertSame(false, $reactAdapter->isThenable(new \stdClass())); $this->assertFalse($reactAdapter->isThenable(new \stdClass()));
} }
public function testConvertsReactPromisesToGraphQlOnes() : void public function testConvertsReactPromisesToGraphQlOnes() : void

View File

@ -51,7 +51,7 @@ class SerializationTest extends TestCase
$expectedVars = get_object_vars($expected); $expectedVars = get_object_vars($expected);
$actualVars = get_object_vars($actual); $actualVars = get_object_vars($actual);
$this->assertSame(count($expectedVars), count($actualVars), $err); $this->assertCount(count($expectedVars), $actualVars, $err);
$this->assertEquals(array_keys($expectedVars), array_keys($actualVars), $err); $this->assertEquals(array_keys($expectedVars), array_keys($actualVars), $err);
foreach ($expectedVars as $name => $expectedValue) { foreach ($expectedVars as $name => $expectedValue) {

View File

@ -66,7 +66,7 @@ class QueryExecutionTest extends ServerTestCase
$query = '{f1'; $query = '{f1';
$result = $this->executeQuery($query); $result = $this->executeQuery($query);
$this->assertSame(null, $result->data); $this->assertNull($result->data);
$this->assertCount(1, $result->errors); $this->assertCount(1, $result->errors);
$this->assertContains( $this->assertContains(
'Syntax Error: Expected Name, found <EOF>', 'Syntax Error: Expected Name, found <EOF>',

View File

@ -17,17 +17,17 @@ class ServerConfigTest extends TestCase
public function testDefaults() : void public function testDefaults() : void
{ {
$config = ServerConfig::create(); $config = ServerConfig::create();
$this->assertEquals(null, $config->getSchema()); $this->assertNull($config->getSchema());
$this->assertEquals(null, $config->getContext()); $this->assertNull($config->getContext());
$this->assertEquals(null, $config->getRootValue()); $this->assertNull($config->getRootValue());
$this->assertEquals(null, $config->getErrorFormatter()); $this->assertNull($config->getErrorFormatter());
$this->assertEquals(null, $config->getErrorsHandler()); $this->assertNull($config->getErrorsHandler());
$this->assertEquals(null, $config->getPromiseAdapter()); $this->assertNull($config->getPromiseAdapter());
$this->assertEquals(null, $config->getValidationRules()); $this->assertNull($config->getValidationRules());
$this->assertEquals(null, $config->getFieldResolver()); $this->assertNull($config->getFieldResolver());
$this->assertEquals(null, $config->getPersistentQueryLoader()); $this->assertNull($config->getPersistentQueryLoader());
$this->assertEquals(false, $config->getDebug()); $this->assertFalse($config->getDebug());
$this->assertEquals(false, $config->getQueryBatching()); $this->assertFalse($config->getQueryBatching());
} }
public function testAllowsSettingSchema() : void public function testAllowsSettingSchema() : void
@ -166,10 +166,10 @@ class ServerConfigTest extends TestCase
$config = ServerConfig::create(); $config = ServerConfig::create();
$config->setDebug(true); $config->setDebug(true);
$this->assertSame(true, $config->getDebug()); $this->assertTrue($config->getDebug());
$config->setDebug(false); $config->setDebug(false);
$this->assertSame(false, $config->getDebug()); $this->assertFalse($config->getDebug());
} }
public function testAcceptsArray() : void public function testAcceptsArray() : void
@ -204,8 +204,8 @@ class ServerConfigTest extends TestCase
$this->assertSame($arr['validationRules'], $config->getValidationRules()); $this->assertSame($arr['validationRules'], $config->getValidationRules());
$this->assertSame($arr['fieldResolver'], $config->getFieldResolver()); $this->assertSame($arr['fieldResolver'], $config->getFieldResolver());
$this->assertSame($arr['persistentQueryLoader'], $config->getPersistentQueryLoader()); $this->assertSame($arr['persistentQueryLoader'], $config->getPersistentQueryLoader());
$this->assertSame(true, $config->getDebug()); $this->assertTrue($config->getDebug());
$this->assertSame(true, $config->getQueryBatching()); $this->assertTrue($config->getQueryBatching());
} }
public function testThrowsOnInvalidArrayKey() : void public function testThrowsOnInvalidArrayKey() : void

View File

@ -287,7 +287,7 @@ class ResolutionTest extends TestCase
]; ];
$this->assertEquals($expectedDescriptor, $eagerTypeResolution->getDescriptor()); $this->assertEquals($expectedDescriptor, $eagerTypeResolution->getDescriptor());
$this->assertSame(null, $eagerTypeResolution->resolveType('User')); $this->assertNull($eagerTypeResolution->resolveType('User'));
$this->assertSame([], $eagerTypeResolution->resolvePossibleTypes($this->node)); $this->assertSame([], $eagerTypeResolution->resolvePossibleTypes($this->node));
$this->assertSame([], $eagerTypeResolution->resolvePossibleTypes($this->content)); $this->assertSame([], $eagerTypeResolution->resolvePossibleTypes($this->content));
$this->assertSame([], $eagerTypeResolution->resolvePossibleTypes($this->mention)); $this->assertSame([], $eagerTypeResolution->resolvePossibleTypes($this->mention));

View File

@ -186,13 +186,13 @@ class ScalarSerializationTest extends TestCase
{ {
$boolType = Type::boolean(); $boolType = Type::boolean();
$this->assertSame(true, $boolType->serialize('string')); $this->assertTrue($boolType->serialize('string'));
$this->assertSame(false, $boolType->serialize('')); $this->assertFalse($boolType->serialize(''));
$this->assertSame(true, $boolType->serialize('1')); $this->assertTrue($boolType->serialize('1'));
$this->assertSame(true, $boolType->serialize(1)); $this->assertTrue($boolType->serialize(1));
$this->assertSame(false, $boolType->serialize(0)); $this->assertFalse($boolType->serialize(0));
$this->assertSame(true, $boolType->serialize(true)); $this->assertTrue($boolType->serialize(true));
$this->assertSame(false, $boolType->serialize(false)); $this->assertFalse($boolType->serialize(false));
// TODO: how should it behave on '0'? // TODO: how should it behave on '0'?
} }

View File

@ -126,7 +126,7 @@ class AstFromValueTest extends TestCase
*/ */
public function testDoesNotConvertsNonNullValuestoNullValue() : void public function testDoesNotConvertsNonNullValuestoNullValue() : void
{ {
$this->assertSame(null, AST::astFromValue(null, Type::nonNull(Type::boolean()))); $this->assertNull(AST::astFromValue(null, Type::nonNull(Type::boolean())));
} }
/** /**
@ -141,10 +141,10 @@ class AstFromValueTest extends TestCase
); );
// Note: case sensitive // Note: case sensitive
$this->assertEquals(null, AST::astFromValue('hello', $this->myEnum())); $this->assertNull(AST::astFromValue('hello', $this->myEnum()));
// Note: Not a valid enum value // Note: Not a valid enum value
$this->assertEquals(null, AST::astFromValue('VALUE', $this->myEnum())); $this->assertNull(AST::astFromValue('VALUE', $this->myEnum()));
} }
/** /**