Example #1
0
 /** @test */
 public function should_see_if_array_contains_value()
 {
     $this->assertTrue(Arr::create([1, 2, 3])->contains(1));
     $this->assertFalse(Arr::create([1, 2, 3])->contains(4));
     $this->assertTrue(Arr::create(['hello' => 'world'])->contains('hello', 'world'));
     $this->assertFalse(Arr::create(['hello' => 'world'])->contains('yo', 'dawg'));
 }
Example #2
0
 /**
  * Assert the value is valid for the expectation
  *
  * @param mixed $value
  * @param array $options
  * @return bool
  */
 public static function assert($value, array $options = [])
 {
     $locales = intlcal_get_available_locales();
     if (Arr::create($locales)->contains($value)) {
         return true;
     }
     throw new AssertionException(sprintf('%s is not a locale', $value));
 }
Example #3
0
 /**
  * Assert the value is valid for the expectation
  *
  * @param mixed $value
  * @param array $options
  * @return bool
  */
 public static function assert($value, array $options = [])
 {
     $currencies = json_decode(file_get_contents(sprintf('%s%s', __DIR__, self::$path)), true);
     $attribute = Arr::pluck($options, 'attribute', 'name');
     if (Arr::create($currencies)->contains($attribute, $value)) {
         return true;
     }
     throw new AssertionException(sprintf('%s is not a currency', $value));
 }
Example #4
0
 /**
  * Assert the value is valid for the expectation
  *
  * @param mixed $value
  * @param array $options
  * @return bool
  */
 public static function assert($value, array $options = [])
 {
     $format = Arr::pluck($options, 'format', self::$format);
     $date = DT::createFromFormat($format, $value);
     if ($date && $date->format($format) == $value) {
         return true;
     }
     throw new AssertionException(sprintf('%s is not a valid datetime', $value));
 }