TYPO3 CMS  TYPO3_7-6
CommandLineBackendTest.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
18 
23 {
27  protected $subject = null;
28 
29  protected function setUp()
30  {
31  $this->subject = new CommandLineBackend();
32  }
33 
38  {
39  $this->skipIfWindows();
40  $keyPair = $this->subject->createNewKeyPair();
41  if ($keyPair === null) {
42  $this->markTestSkipped('KeyPair could not be generated. Maybe openssl was not found.');
43  }
44 
45  $this->assertTrue($keyPair->isReady());
46  }
47 
52  {
53  $this->skipIfWindows();
54  $keyPair = $this->subject->createNewKeyPair();
55  if ($keyPair === null) {
56  $this->markTestSkipped('KeyPair could not be generated. Maybe openssl was not found.');
57  }
58 
59  $this->assertSame(
61  $keyPair->getExponent()
62  );
63  }
64 
69  {
70  $this->skipIfWindows();
71  $this->assertSame(
72  $this->subject->createNewKeyPair(),
73  $this->subject->createNewKeyPair()
74  );
75  }
76 
80  public function doesNotAllowUnserialization()
81  {
82  $this->setExpectedException(\RuntimeException::class, '', 1531336156);
83 
85  $serialized = serialize($subject);
86  unserialize($serialized);
87  }
88 
92  public function unsetsPathsOnUnserialization()
93  {
94  try {
95  $subject = $this->getAccessibleMock(CommandLineBackend::class);
96  $subject->_set('opensslPath', 'foo');
97  $subject->_set('temporaryDirectory', 'foo');
98  $serialized = serialize($subject);
99  unserialize($serialized);
100  } catch (\RuntimeException $e) {
101  $this->assertNull($subject->_get('opensslPath'));
102  $this->assertNull($subject->_get('temporaryDirectory'));
103  }
104  }
105 
106  protected function skipIfWindows()
107  {
108  if (TYPO3_OS === 'WIN') {
109  $this->markTestSkipped(
110  'This test is not available on Windows as auto-detection of openssl path will fail.'
111  );
112  }
113  }
114 }
getAccessibleMock( $originalClassName, $methods=[], array $arguments=[], $mockClassName='', $callOriginalConstructor=true, $callOriginalClone=true, $callAutoload=true)