ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Twig_Tests_Extension_DateTest Class Reference
+ Inheritance diagram for Twig_Tests_Extension_DateTest:
+ Collaboration diagram for Twig_Tests_Extension_DateTest:

Public Member Functions

 setUp ()
 
 testDiffWithStringsFromGivenNow ($expected, $translated, $date, $now)
 getDiffTestData() More...
 
 testDiffWithStringsFromNow ()
 
 testDiffWithDateTimeFromGivenNow ($expected, $translated, $date, $now)
 getDiffTestData() More...
 
 testDiffWithDateTimeFromNow ()
 
 testDiffCanReturnTranslatableString ($expected, $translated, $date, $now)
 getDiffTestData() More...
 
 getDiffTestData ()
 
 getDiffAgoTestData ()
 
 getDiffInTestData ()
 

Private Attributes

 $env
 

Detailed Description

Author
Robin van der Vleuten robin.nosp@m.vdvl.nosp@m.euten.nosp@m.@gma.nosp@m.il.co.nosp@m.m

Definition at line 15 of file DateTest.php.

Member Function Documentation

◆ getDiffAgoTestData()

Twig_Tests_Extension_DateTest::getDiffAgoTestData ( )

Definition at line 77 of file DateTest.php.

Referenced by getDiffTestData().

78  {
79  return array(
80  array('1 second ago', 'diff.ago.second', '24-07-2014 17:28:01', '24-07-2014 17:28:02'),
81  array('5 seconds ago', 'diff.ago.second', '24-07-2014 17:28:01', '24-07-2014 17:28:06'),
82  array('1 minute ago', 'diff.ago.minute', '24-07-2014 17:28:01', '24-07-2014 17:29:01'),
83  array('5 minutes ago', 'diff.ago.minute', '24-07-2014 17:28:01', '24-07-2014 17:33:03'),
84  array('1 hour ago', 'diff.ago.hour', '24-07-2014 17:28:01', '24-07-2014 18:29:01'),
85  array('9 hours ago', 'diff.ago.hour', '24-07-2014 17:28:01', '25-07-2014 02:33:03'),
86  array('1 day ago', 'diff.ago.day', '23-07-2014', '24-07-2014'),
87  array('5 days ago', 'diff.ago.day', '19-07-2014', '24-07-2014'),
88  array('1 month ago', 'diff.ago.month', '23-07-2014', '24-08-2014'),
89  array('6 months ago', 'diff.ago.month', '19-07-2014', '24-01-2015'),
90  array('1 year ago', 'diff.ago.year', '19-07-2014', '20-08-2015'),
91  array('3 years ago', 'diff.ago.year', '19-07-2014', '20-08-2017'),
92  );
93  }
+ Here is the caller graph for this function:

◆ getDiffInTestData()

Twig_Tests_Extension_DateTest::getDiffInTestData ( )

Definition at line 95 of file DateTest.php.

Referenced by getDiffTestData().

96  {
97  return array(
98  array('in 1 second', 'diff.in.second', '24-07-2014 17:28:02', '24-07-2014 17:28:01'),
99  array('in 5 seconds', 'diff.in.second', '24-07-2014 17:28:06', '24-07-2014 17:28:01'),
100  array('in 1 minute', 'diff.in.minute', '24-07-2014 17:29:01', '24-07-2014 17:28:01'),
101  array('in 5 minutes', 'diff.in.minute', '24-07-2014 17:33:03', '24-07-2014 17:28:01'),
102  array('in 1 hour', 'diff.in.hour', '24-07-2014 18:29:01', '24-07-2014 17:28:01'),
103  array('in 9 hours', 'diff.in.hour', '25-07-2014 02:33:03', '24-07-2014 17:28:01'),
104  array('in 1 day', 'diff.in.day', '24-07-2014', '23-07-2014'),
105  array('in 5 days', 'diff.in.day', '24-07-2014', '19-07-2014'),
106  array('in 1 month', 'diff.in.month', '24-08-2014', '23-07-2014'),
107  array('in 6 months', 'diff.in.month', '24-01-2015', '19-07-2014'),
108  array('in 1 year', 'diff.in.year', '20-08-2015', '19-07-2014'),
109  array('in 3 years', 'diff.in.year', '20-08-2017', '19-07-2014'),
110  );
111  }
+ Here is the caller graph for this function:

◆ getDiffTestData()

Twig_Tests_Extension_DateTest::getDiffTestData ( )

Definition at line 72 of file DateTest.php.

References getDiffAgoTestData(), and getDiffInTestData().

73  {
74  return array_merge($this->getDiffAgoTestData(), $this->getDiffInTestData());
75  }
+ Here is the call graph for this function:

◆ setUp()

Twig_Tests_Extension_DateTest::setUp ( )

Definition at line 22 of file DateTest.php.

23  {
24  $this->env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
25  }
Stores the Twig configuration.
Definition: Environment.php:17

◆ testDiffCanReturnTranslatableString()

Twig_Tests_Extension_DateTest::testDiffCanReturnTranslatableString (   $expected,
  $translated,
  $date,
  $now 
)

getDiffTestData()

Definition at line 60 of file DateTest.php.

References $translator, and Sabre\Event\once().

61  {
62  $translator = $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock();
64  ->expects($this->once())
65  ->method('transChoice')
66  ->with($translated);
67 
69  $extension->diff($this->env, $date, $now);
70  }
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
$translator
Definition: getconsent.php:119
+ Here is the call graph for this function:

◆ testDiffWithDateTimeFromGivenNow()

Twig_Tests_Extension_DateTest::testDiffWithDateTimeFromGivenNow (   $expected,
  $translated,
  $date,
  $now 
)

getDiffTestData()

Definition at line 45 of file DateTest.php.

46  {
47  $extension = new Twig_Extensions_Extension_Date();
48  $this->assertEquals($expected, $extension->diff($this->env, new DateTime($date), new DateTime($now)));
49  }

◆ testDiffWithDateTimeFromNow()

Twig_Tests_Extension_DateTest::testDiffWithDateTimeFromNow ( )

Definition at line 51 of file DateTest.php.

52  {
53  $extension = new Twig_Extensions_Extension_Date();
54  $this->assertRegExp('/^[0-9]+ (second|minute|hour|day|month|year)s* ago$/', $extension->diff($this->env, new DateTime('24-07-2014')));
55  }

◆ testDiffWithStringsFromGivenNow()

Twig_Tests_Extension_DateTest::testDiffWithStringsFromGivenNow (   $expected,
  $translated,
  $date,
  $now 
)

getDiffTestData()

Definition at line 30 of file DateTest.php.

31  {
32  $extension = new Twig_Extensions_Extension_Date();
33  $this->assertEquals($expected, $extension->diff($this->env, $date, $now));
34  }

◆ testDiffWithStringsFromNow()

Twig_Tests_Extension_DateTest::testDiffWithStringsFromNow ( )

Definition at line 36 of file DateTest.php.

37  {
38  $extension = new Twig_Extensions_Extension_Date();
39  $this->assertRegExp('/^[0-9]+ (second|minute|hour|day|month|year)s* ago$/', $extension->diff($this->env, '24-07-2014'));
40  }

Field Documentation

◆ $env

Twig_Tests_Extension_DateTest::$env
private

Definition at line 20 of file DateTest.php.


The documentation for this class was generated from the following file: