Code Duplication    Length = 26-28 lines in 3 locations

vendor/phpunit/phpunit/tests/Framework/ConstraintTest.php 3 locations

@@ 1237-1264 (lines=28) @@
1234
     * @covers PHPUnit_Framework_Assert::logicalNot
1235
     * @covers PHPUnit_Framework_TestFailure::exceptionToString
1236
     */
1237
    public function testConstraintIsNotInstanceOf()
1238
    {
1239
        $constraint = PHPUnit_Framework_Assert::logicalNot(
1240
          PHPUnit_Framework_Assert::isInstanceOf('stdClass')
1241
        );
1242
1243
        $this->assertFalse($constraint->evaluate(new stdClass, '', true));
1244
        $this->assertTrue($constraint->evaluate(new Exception, '', true));
1245
        $this->assertEquals('is not instance of class "stdClass"', $constraint->toString());
1246
        $this->assertEquals(1, count($constraint));
1247
1248
        try {
1249
            $constraint->evaluate(new stdClass);
1250
        } catch (PHPUnit_Framework_ExpectationFailedException $e) {
1251
            $this->assertEquals(
1252
              <<<EOF
1253
Failed asserting that stdClass Object () is not an instance of class "stdClass".
1254
1255
EOF
1256
              ,
1257
              PHPUnit_Framework_TestFailure::exceptionToString($e)
1258
            );
1259
1260
            return;
1261
        }
1262
1263
        $this->fail();
1264
    }
1265
1266
    /**
1267
     * @covers PHPUnit_Framework_Constraint_IsInstanceOf
@@ 2153-2178 (lines=26) @@
2150
     * @covers PHPUnit_Framework_Constraint::count
2151
     * @covers PHPUnit_Framework_TestFailure::exceptionToString
2152
     */
2153
    public function testConstraintObjectHasAttribute()
2154
    {
2155
        $constraint = PHPUnit_Framework_Assert::objectHasAttribute('privateAttribute');
2156
2157
        $this->assertTrue($constraint->evaluate(new ClassWithNonPublicAttributes, '', true));
2158
        $this->assertFalse($constraint->evaluate(new stdClass, '', true));
2159
        $this->assertEquals('has attribute "privateAttribute"', $constraint->toString());
2160
        $this->assertEquals(1, count($constraint));
2161
2162
        try {
2163
            $constraint->evaluate(new stdClass);
2164
        } catch (PHPUnit_Framework_ExpectationFailedException $e) {
2165
            $this->assertEquals(
2166
              <<<EOF
2167
Failed asserting that object of class "stdClass" has attribute "privateAttribute".
2168
2169
EOF
2170
              ,
2171
              PHPUnit_Framework_TestFailure::exceptionToString($e)
2172
            );
2173
2174
            return;
2175
        }
2176
2177
        $this->fail();
2178
    }
2179
2180
    /**
2181
     * @covers PHPUnit_Framework_Constraint_ObjectHasAttribute
@@ 2214-2241 (lines=28) @@
2211
     * @covers PHPUnit_Framework_Assert::logicalNot
2212
     * @covers PHPUnit_Framework_TestFailure::exceptionToString
2213
     */
2214
    public function testConstraintObjectNotHasAttribute()
2215
    {
2216
        $constraint = PHPUnit_Framework_Assert::logicalNot(
2217
          PHPUnit_Framework_Assert::objectHasAttribute('privateAttribute')
2218
        );
2219
2220
        $this->assertTrue($constraint->evaluate(new stdClass, '', true));
2221
        $this->assertFalse($constraint->evaluate(new ClassWithNonPublicAttributes, '', true));
2222
        $this->assertEquals('does not have attribute "privateAttribute"', $constraint->toString());
2223
        $this->assertEquals(1, count($constraint));
2224
2225
        try {
2226
            $constraint->evaluate(new ClassWithNonPublicAttributes);
2227
        } catch (PHPUnit_Framework_ExpectationFailedException $e) {
2228
            $this->assertEquals(
2229
              <<<EOF
2230
Failed asserting that object of class "ClassWithNonPublicAttributes" does not have attribute "privateAttribute".
2231
2232
EOF
2233
              ,
2234
              PHPUnit_Framework_TestFailure::exceptionToString($e)
2235
            );
2236
2237
            return;
2238
        }
2239
2240
        $this->fail();
2241
    }
2242
2243
    /**
2244
     * @covers PHPUnit_Framework_Constraint_ObjectHasAttribute