assertContainsOnly() public static method

Asserts that a haystack contains only values of a given type.
public static assertContainsOnly ( string $type, mixed $haystack, boolean $isNativeType = null, string $message = '' )
$type string
$haystack mixed
$isNativeType boolean
$message string
Example #1
0
/**
 * Asserts that a haystack contains only values of a given type.
 *
 * @param  string  $type
 * @param  mixed   $haystack
 * @param  boolean $isNativeType
 * @param  string  $message
 * @since  Method available since Release 3.1.4
 */
function assertContainsOnly($type, $haystack, $isNativeType = NULL, $message = '')
{
    return PHPUnit_Framework_Assert::assertContainsOnly($type, $haystack, $isNativeType, $message);
}
Example #2
0
 public function toContainType($type)
 {
     if ($this->negate) {
         a::assertNotContainsOnly($type, $this->actual);
     } else {
         a::assertContainsOnly($type, $this->actual);
     }
 }
Example #3
0
 public function containsOnly($type, $isNativeType = NULL)
 {
     a::assertContainsOnly($type, $this->actual, $isNativeType, $this->description);
 }
Example #4
0
 /**
  * Expect that a haystack contains only values of a given type.
  *
  * @param string $type
  * @param bool $isNativeType
  * @param string $message
  *
  * @return Expect
  */
 public function toContainOnly($type, $isNativeType = null, $message = '')
 {
     Assert::assertContainsOnly($type, $this->value, $isNativeType, $message);
     return $this;
 }
 /**
  * @Then the api/API result should contain at least :count item(s)
  * @Then the api/API result contains at least :count item(s)
  */
 public function theResultContainsAtLeastItems($count)
 {
     $result = $this->getApiResult();
     Assert::assertContainsOnly('array', $result);
     Assert::assertGreaterThanOrEqual($count, count($result));
 }
Example #6
0
 /**
  * Tests that key & value arrays are converted to indexed
  * arrays during map instantiation
  *
  * @covers \ERP\ComplexMap::__constructor
  */
 public function testInternalArrayConversion()
 {
     $reflectionClass = new \ReflectionClass(new ComplexMap(['foo' => 'bar'], ['bax' => 12345]));
     $keysProperty = $reflectionClass->getProperty('keys');
     $valuesProperty = $reflectionClass->getProperty('values');
     $keysProperty->setAccessible(true);
     $valuesProperty->setAccessible(true);
     \PHPUnit_Framework_Assert::assertContainsOnly('integer', array_keys($keysProperty->getValue($this->complexMap)));
     \PHPUnit_Framework_Assert::assertContainsOnly('integer', array_keys($valuesProperty->getValue($this->complexMap)));
 }