1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
<?php
/*
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use Carbon\Carbon;
class FluidSettersTest extends TestFixture
{
public function testFluidYearSetter()
{
$d = Carbon::now();
$this->assertTrue($d->year(1995) instanceof Carbon);
$this->assertSame(1995, $d->year);
}
public function testFluidMonthSetter()
{
$d = Carbon::now();
$this->assertTrue($d->month(3) instanceof Carbon);
$this->assertSame(3, $d->month);
}
public function testFluidMonthSetterWithWrap()
{
$d = Carbon::createFromDate(2012, 8, 21);
$this->assertTrue($d->month(13) instanceof Carbon);
$this->assertSame(1, $d->month);
}
public function testFluidDaySetter()
{
$d = Carbon::now();
$this->assertTrue($d->day(2) instanceof Carbon);
$this->assertSame(2, $d->day);
}
public function testFluidDaySetterWithWrap()
{
$d = Carbon::createFromDate(2000, 1, 1);
$this->assertTrue($d->day(32) instanceof Carbon);
$this->assertSame(1, $d->day);
}
public function testFluidSetDate()
{
$d = Carbon::createFromDate(2000, 1, 1);
$this->assertTrue($d->setDate(1995, 13, 32) instanceof Carbon);
$this->assertCarbon($d, 1996, 2, 1);
}
public function testFluidHourSetter()
{
$d = Carbon::now();
$this->assertTrue($d->hour(2) instanceof Carbon);
$this->assertSame(2, $d->hour);
}
public function testFluidHourSetterWithWrap()
{
$d = Carbon::now();
$this->assertTrue($d->hour(25) instanceof Carbon);
$this->assertSame(1, $d->hour);
}
public function testFluidMinuteSetter()
{
$d = Carbon::now();
$this->assertTrue($d->minute(2) instanceof Carbon);
$this->assertSame(2, $d->minute);
}
public function testFluidMinuteSetterWithWrap()
{
$d = Carbon::now();
$this->assertTrue($d->minute(61) instanceof Carbon);
$this->assertSame(1, $d->minute);
}
public function testFluidSecondSetter()
{
$d = Carbon::now();
$this->assertTrue($d->second(2) instanceof Carbon);
$this->assertSame(2, $d->second);
}
public function testFluidSecondSetterWithWrap()
{
$d = Carbon::now();
$this->assertTrue($d->second(62) instanceof Carbon);
$this->assertSame(2, $d->second);
}
public function testFluidSetTime()
{
$d = Carbon::createFromDate(2000, 1, 1);
$this->assertTrue($d->setTime(25, 61, 61) instanceof Carbon);
$this->assertCarbon($d, 2000, 1, 2, 2, 2, 1);
}
public function testFluidTimestampSetter()
{
$d = Carbon::now();
$this->assertTrue($d->timestamp(10) instanceof Carbon);
$this->assertSame(10, $d->timestamp);
}
}
|