The
now
function creates a new Illuminate\Support\Carbon
instance for the current time:
$now = now();
$environmentLastModified = $hasEnvironment
? filemtime($environmentFile)
: now()->addDays(30)->getTimestamp();
$process = $this->startProcess($hasEnvironment);
? filemtime($environmentFile)
: now()->addDays(30)->getTimestamp();
$process = $this->startProcess($hasEnvironment);
$batch = $this->createTestBatch($queue);
$this->assertFalse($batch->finished());
$batch->finishedAt = now();
$this->assertTrue($batch->finished());
$batch->options['then'] = [];
$this->assertFalse($batch->finished());
$batch->finishedAt = now();
$this->assertTrue($batch->finished());
$batch->options['then'] = [];
$this->assertTrue($batch->hasCatchCallbacks());
$this->assertFalse($batch->cancelled());
$batch->cancelledAt = now();
$this->assertTrue($batch->cancelled());
$this->assertIsString(json_encode($batch));
$this->assertFalse($batch->cancelled());
$batch->cancelledAt = now();
$this->assertTrue($batch->cancelled());
$this->assertIsString(json_encode($batch));
'failed_jobs' => '',
'failed_job_ids' => '[]',
'options' => $serialize,
'created_at' => now()->timestamp,
'cancelled_at' => null,
'finished_at' => null,
]);
'failed_job_ids' => '[]',
'options' => $serialize,
'created_at' => now()->timestamp,
'cancelled_at' => null,
'finished_at' => null,
]);
public function testAvailableInReturnsPositiveValues()
{
$cache = m::mock(Cache::class);
$cache->shouldReceive('get')->andReturn(now()->subSeconds(60)->getTimestamp(), null);
$rateLimiter = new RateLimiter($cache);
$this->assertTrue($rateLimiter->availableIn('key:timer') >= 0);
{
$cache = m::mock(Cache::class);
$cache->shouldReceive('get')->andReturn(now()->subSeconds(60)->getTimestamp(), null);
$rateLimiter = new RateLimiter($cache);
$this->assertTrue($rateLimiter->availableIn('key:timer') >= 0);
'published_at' => 'max',
'id' => 'max',
], function ($q) {
$q->where('published_at', '<', now());
});
}
'id' => 'max',
], function ($q) {
$q->where('published_at', '<', now());
});
}
'published_at' => 'max',
'id' => 'max',
], function ($q) {
$q->where('published_at', '<', now());
});
}
}
'id' => 'max',
], function ($q) {
$q->where('published_at', '<', now());
});
}
}
$this->assertEquals([], $builder->getBindings());
$builder = $this->getBuilder();
$period = now()->toPeriod(now()->addDay());
$builder->select('*')->from('users')->whereBetween('created_at', $period);
$this->assertSame('select * from "users" where "created_at" between ? and ?', $builder->toSql());
$this->assertEquals($period->toArray(), $builder->getBindings());
$builder = $this->getBuilder();
$period = now()->toPeriod(now()->addDay());
$builder->select('*')->from('users')->whereBetween('created_at', $period);
$this->assertSame('select * from "users" where "created_at" between ? and ?', $builder->toSql());
$this->assertEquals($period->toArray(), $builder->getBindings());
public function testCursorPaginateWithUnionWheres()
{
$ts = now()->toDateTimeString();
$perPage = 16;
$columns = ['test'];
{
$ts = now()->toDateTimeString();
$perPage = 16;
$columns = ['test'];
$path = 'http://foo.bar?cursor='.$cursor->encode();
$results = collect([
['id' => 1, 'created_at' => now(), 'type' => 'video'],
['id' => 2, 'created_at' => now(), 'type' => 'news'],
]);
$results = collect([
['id' => 1, 'created_at' => now(), 'type' => 'video'],
['id' => 2, 'created_at' => now(), 'type' => 'news'],
]);
$results = collect([
['id' => 1, 'created_at' => now(), 'type' => 'video'],
['id' => 2, 'created_at' => now(), 'type' => 'news'],
]);
$builder->shouldReceive('get')->once()->andReturnUsing(function () use ($builder, $results, $ts) {
['id' => 1, 'created_at' => now(), 'type' => 'video'],
['id' => 2, 'created_at' => now(), 'type' => 'news'],
]);
$builder->shouldReceive('get')->once()->andReturnUsing(function () use ($builder, $results, $ts) {
public function testCursorPaginateWithUnionWheresWithRawOrderExpression()
{
$ts = now()->toDateTimeString();
$perPage = 16;
$columns = ['test'];
{
$ts = now()->toDateTimeString();
$perPage = 16;
$columns = ['test'];
$path = 'http://foo.bar?cursor='.$cursor->encode();
$results = collect([
['id' => 1, 'created_at' => now(), 'type' => 'video', 'is_published' => true],
['id' => 2, 'created_at' => now(), 'type' => 'news', 'is_published' => true],
]);
$results = collect([
['id' => 1, 'created_at' => now(), 'type' => 'video', 'is_published' => true],
['id' => 2, 'created_at' => now(), 'type' => 'news', 'is_published' => true],
]);
$results = collect([
['id' => 1, 'created_at' => now(), 'type' => 'video', 'is_published' => true],
['id' => 2, 'created_at' => now(), 'type' => 'news', 'is_published' => true],
]);
$builder->shouldReceive('get')->once()->andReturnUsing(function () use ($builder, $results, $ts) {
['id' => 1, 'created_at' => now(), 'type' => 'video', 'is_published' => true],
['id' => 2, 'created_at' => now(), 'type' => 'news', 'is_published' => true],
]);
$builder->shouldReceive('get')->once()->andReturnUsing(function () use ($builder, $results, $ts) {
public function testCursorPaginateWithUnionWheresReverseOrder()
{
$ts = now()->toDateTimeString();
$perPage = 16;
$columns = ['test'];
{
$ts = now()->toDateTimeString();
$perPage = 16;
$columns = ['test'];