Example #1
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 #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 = [])
 {
     $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));
 }
Example #3
0
 /** @test */
 public function should_get_item_or_return_default()
 {
     $this->assertEquals('world', Arr::pluck(['hello' => 'world'], 'hello'));
     $this->assertNull(Arr::pluck([], 'hello'));
     $this->assertEquals('world', Arr::pluck([], 'hello', 'world'));
 }