TYPO3 CMS  TYPO3_8-7
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 
22 class CommandLineBackendTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
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->expectException(\RuntimeException::class);
83  $this->expectExceptionCode(1531336156);
84 
86  $serialized = serialize($subject);
87  unserialize($serialized);
88  }
89 
93  public function unsetsPathsOnUnserialization()
94  {
95  try {
96  $subject = $this->getAccessibleMock(CommandLineBackend::class);
97  $subject->_set('opensslPath', 'foo');
98  $subject->_set('temporaryDirectory', 'foo');
99  $serialized = serialize($subject);
100  unserialize($serialized);
101  } catch (\RuntimeException $e) {
102  $this->assertNull($subject->_get('opensslPath'));
103  $this->assertNull($subject->_get('temporaryDirectory'));
104  }
105  }
106 
107  protected function skipIfWindows()
108  {
109  if (TYPO3_OS === 'WIN') {
110  $this->markTestSkipped(
111  'This test is not available on Windows as auto-detection of openssl path will fail.'
112  );
113  }
114  }
115 }