public static function check(\PHPUnit_Framework_TestCase $test, SSODescriptor $descriptor, array $expectedNameIdFormats) { $test->assertCount(count($expectedNameIdFormats), $descriptor->getAllNameIDFormats()); foreach ($expectedNameIdFormats as $nameIdFormat) { $test->assertTrue($descriptor->hasNameIDFormat($nameIdFormat)); } }
public static function assertCount($expectedCount, $haystack, $message = '') { if (method_exists(get_parent_class(__CLASS__), 'assertCount')) { parent::assertCount($expectedCount, $haystack, $message); } else { self::assertSame($expectedCount, count($haystack)); } }
/** * @param array $values * * @test * @dataProvider getInstanceValues */ public function containsValues($values) { $collection = $this->getCollectionInstance($values); parent::assertCount(count($values), $collection); foreach ($collection as $value) { parent::assertTrue($collection->contains($value)); } }
/** * @param object $instance * @param string $propertyName * @param mixed $testItem */ public static function assertPropertyCollection($instance, $propertyName, $testItem) { $propertyAccess = new CollectionAccessor($instance, $propertyName); // Check default value \PHPUnit_Framework_TestCase::assertInstanceOf('Doctrine\\Common\\Collections\\Collection', $propertyAccess->getItems(), $propertyName . ': Default value must be instance of Collection'); // Check default size \PHPUnit_Framework_TestCase::assertCount(0, $propertyAccess->getItems(), $propertyName . ': Default collection size must be 0'); // Add first item \PHPUnit_Framework_TestCase::assertSame($instance, $propertyAccess->addItem($testItem), sprintf('%s::%s() - must return %s', ClassUtils::getClass($instance), $propertyAccess->getAddItemMethod(), ClassUtils::getClass($instance))); // Check added item \PHPUnit_Framework_TestCase::assertCount(1, $propertyAccess->getItems(), $propertyName . ': After add item - collection size must be 1'); \PHPUnit_Framework_TestCase::assertInstanceOf('Doctrine\\Common\\Collections\\Collection', $propertyAccess->getItems(), $propertyName . ': After addition of a first item - property value must be instance of Collection'); \PHPUnit_Framework_TestCase::assertEquals([$testItem], $propertyAccess->getItems()->toArray(), $propertyName . ': After addition of a first item - collections must be equals'); // Add already added item $propertyAccess->addItem($testItem); \PHPUnit_Framework_TestCase::assertCount(1, $propertyAccess->getItems(), $propertyName . ': After addition already added item - collection size must be same and equal 1'); // Remove item \PHPUnit_Framework_TestCase::assertSame($instance, $propertyAccess->removeItem($testItem), sprintf('%s:%s() - must return %s', ClassUtils::getClass($instance), $propertyAccess->getRemoveItemMethod(), ClassUtils::getClass($instance))); \PHPUnit_Framework_TestCase::assertCount(0, $propertyAccess->getItems(), $propertyName . ': After removal of a single item - collection size must be 0'); // Remove already removed item $propertyAccess->removeItem($testItem); \PHPUnit_Framework_TestCase::assertCount(0, $propertyAccess->getItems(), $propertyName . ': After removal already removed item - collection size must be same and equal 0'); \PHPUnit_Framework_TestCase::assertNotContains($testItem, $propertyAccess->getItems()->toArray(), $propertyName . ': After removal of a single item - collection must not contains test item'); }
public function testRemove($data) { $count = count($this->entityGet()); $countBeforeRemove = $this->countDataInCollection($data); $returnOfRemoveMethod = $this->entityRemove($data); if ($this->fluent) { TestCase::assertEquals($this->entity, $this->entityRemove($data), $this->msg(self::$MSG_REMOVE_METHOD_NOT_FLUENT)); } TestCase::assertNotContains($data, $this->entityGet(), $this->msg(self::$MSG_REMOVE_METHOD_DOES_NOT_REMOVE)); TestCase::assertCount($count - $countBeforeRemove, $this->entityGet(), $this->msg(self::$MSG_REMOVE_METHOD_DOES_NOT_REMOVE_GOOD_NUMBER_OF_ITEMS)); return $this; }