is->assertTrue($constraint->evaluate($b, '', true)); $this->assertFalse($constraint->evaluate($a, '', true)); $this->assertEquals('is not identical to an object of class "stdClass"', $constraint->toString()); $this->assertCount(1, $constraint); try { $constraint->evaluate($a); } catch (PHPUnit_Framework_ExpectationFailedException $e) { $this->assertEquals(<<trimnl(PHPUnit_Framework_TestFailure::exceptionToString($e)) ); return; } $this->fail(); } public function testConstraintIsNotIdentical2() { $a = new stdClass; $constraint = PHPUnit_Framework_Assert::logicalNot( PHPUnit_Framework_Assert::identicalTo($a) ); try { $constraint->evaluate($a, 'custom message'); } catch (PHPUnit_Framework_ExpectationFailedException $e) { $this->assertEquals(<<fail(); } public function testConstraintIsNotIdentical3() { $constraint = PHPUnit_Framework_Assert::logicalNot( PHPUnit_Framework_Assert::identicalTo('a') ); try { $constraint->evaluate('a', 'custom message'); } catch (PHPUnit_Framework_ExpectationFailedException $e) { $this->assertEquals(<<trimnl(PHPUnit_Framework_TestFailure::exceptionToString($e)) ); return; } $this->fail(); } public function testConstraintIsInstanceOf() { $constraint = PHPUnit_Framework_Assert::isInstanceOf('Exception'); $this->assertFalse($constraint->evaluate(new stdClass, '', true)); $this->assertTrue($constraint->evaluate(new Exception, '', true)); $this->assertEquals('is instance of class "Exception"', $constraint->toString()); $this->assertCount(1, $constraint); $interfaceConstraint = PHPUnit_Framework_Assert::isInstanceOf('Countable'); $this->assertFalse($interfaceConstraint->evaluate(new stdClass, '', true)); $this->assertTrue($interfaceConstraint->evaluate(new ArrayObject, '', true)); $this->assertEquals('is instance of interface "Countable"', $interfaceConstraint->toString()); try { $constraint->evaluate(new stdClass); } catch (PHPUnit_Framework_ExpectationFailedException $e) { $this->assertEquals( <<fail(); } public function testConstraintIsInstanceOf2() { $constraint = PHPUnit_Framework_Assert::isInstanceOf('Exception'); try { $constraint->evaluate(new stdClass, 'custom message'); } catch (PHPUnit_Framework_ExpectationFailedException $e) { $this->assertEquals(<<fail(); } public function testConstraintIsNotInstanceOf() { $constraint = PHPUnit_Framework_Assert::logicalNot( PHPUnit_Framework_Assert::isInstanceOf('stdClass') ); $this->assertFalse($constraint->evaluate(new stdClass, '', true)); $this->assertTrue($constraint->evaluate(new Exception, '', true)); $this->assertEquals('is not instance of class "stdClass"', $constraint->toString()); $this->assertCount(1, $constraint); try { $constraint->evaluate(new stdClass); } catch (PHPUnit_Framework_ExpectationFailedException $e) { $this->assertEquals( <<fail(); } public function testConstraintIsNotInstanceOf2() { $constraint = PHPUnit_Framework_Assert::logicalNot( PHPUnit_Framework_Assert::isInstanceOf('stdClass') ); try { $constraint->evaluate(new stdClass, 'custom message'); } catch (PHPUnit_Framework_ExpectationFailedException $e) { $this->assertEquals(<<fail(); } public function testConstraintIsType() { $constraint = PHPUnit_Framework_Assert::isType('string'); $this->assertFalse($constraint->evaluate(0, '', true)); $this->assertTrue($constraint->evaluate('', '', true)); $this->assertEquals('is of type "string"', $constraint->toString()); $this->assertCount(1, $constraint); try { $constraint->evaluate(new stdClass); } catch (PHPUnit_Framework_ExpectationFailedException $e) { $this->assertStringMatchesFormat(<<trimnl(PHPUnit_Framework_TestFailure::exceptionToString($e)) ); return; } $this->fail(); } public function testConstraintIsType2() { $constraint = PHPUnit_Framework_Assert::isType('string'); try { $constraint->evaluate(new stdClass, 'custom message'); } catch (PHPUnit_Framework_ExpectationFailedException $e) { $this->assertStringMatchesFormat(<<trimnl(PHPUnit_Framework_TestFailure::exceptionToString($e)) ); return; } $this->fail(); } public function resources() { $fh = fopen(__FILE__, 'r'); fclose($fh); return [ 'open resource' => [fopen(__FILE__, 'r')], 'closed resource' => [$fh], ]; } /** * @dataProvider resources */ public function testConstraintIsResourceTypeEvaluatesCorrectlyWithResources($resource) { $constraint = PHPUnit_Framework_Assert::isType('resource'); $this->assertTrue($constraint->evaluate($resource, '', true)); @fclose($resource); } public function testConstraintIsNotType() { $constraint = PHPUnit_Framework_Assert::logicalNot( PHPUnit_Framework_Assert::isType('string') ); $this->assertTrue($constraint->evaluate(0, '', true)); $this->assertFalse($constraint->evaluate('', '', true)); $this->assertEquals('is not of type "string"', $constraint->toString()); $this->assertCount(1, $constraint); try { $constraint->evaluate(''); } catch (PHPUnit_Framework_ExpectationFailedException $e) { $this->assertEquals( <<fail(); } public function testConstraintIsNotType2() { $constraint = PHPUnit_Framework_Assert::logicalNot( PHPUnit_Framework_Assert::isType('string') ); tr
  • Special Issue Proposal
  • Contact
  • iosr-jpte   Volume-1 ~ Issue-2 ~ March – April 2014