Esempio n. 1
0
 public function create_identifier()
 {
     $class = array_any([App\User::class, App\Email::class, App\Guest::class]);
     $model = factory($class)->create();
     $identifier = factory(App\Identifier::class)->create(['type' => $class, 'value' => $model->id]);
     return $identifier;
 }
function validate_value_delete($value)
{
    $value = filter_var_array($value, array('delete' => array("filter" => FILTER_VALIDATE_INT, "options" => array('min_range' => 0, 'max_range' => 1))));
    if (!array_any($value)) {
        $value = false;
    }
    return $value;
}
Esempio n. 3
0
<?php

/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| Here you may define all of your model factories. Model factories give
| you a convenient way to create models for testing and seeding your
| database. Just tell the factory how a default model should look.
|
*/
$factory->define(App\User::class, function (Faker\Generator $faker) {
    return ['name' => $faker->name, 'email' => $faker->email, 'password' => bcrypt(str_random(10)), 'remember_token' => str_random(10)];
});
$factory->define(App\Email::class, function (Faker\Generator $faker) {
    return ['email' => $faker->email];
});
$factory->define(App\Guest::class, function (Faker\Generator $faker) {
    return ['identifier' => array_any([$faker->ipv4, $faker->ipv6])];
});
$factory->define(App\Identifier::class, function (Faker\Generator $faker) {
    $selectedClass = array_any([App\User::class, App\Email::class, App\Guest::class]);
    return ['type' => $selectedClass, 'value' => rand(1000, 9999)];
});
$factory->define(App\PostIt::class, function (Faker\Generator $faker) {
    return ['identifier_id' => rand(1000, 9999), 'message' => implode(' ', $faker->sentences), 'coordinates' => [$faker->latitude, $faker->longitude], 'status' => rand(1, 10)];
});
$factory->define(App\Vote::class, function (Faker\Generator $faker) {
    return ['identifier_id' => rand(1000, 9999), 'postit_id' => rand(1000, 9999), 'value' => array_any([1, -1])];
});
Esempio n. 4
0
 /**
  * @dataProvider arrayAnyProvider
  * @param $array
  * @param $callback
  * @param $result
  */
 public function testArrayAny($array, $callback, $result)
 {
     $this->assertEquals($result, array_any($array, $callback));
 }
Esempio n. 5
0
 private function isRunning()
 {
     return array_any($this->tests, function ($test) {
         return $test->status == 'running';
     });
 }