TYPO3 CMS  TYPO3_6-2
DownloadQueueTest.php
Go to the documentation of this file.
1 <?php
3 
22 
26  protected $downloadQueueMock;
27 
31  protected $extensionMock;
32 
36  public function setUp() {
37  $this->downloadQueueMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\DownloadQueue', array('dummy'));
38  $this->extensionMock = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension', array('dummy'));
39  $this->extensionMock->setExtensionKey('foobar');
40  $this->extensionMock->setVersion('1.0.0');
41 
42  }
43 
49  $this->downloadQueueMock->addExtensionToQueue($this->extensionMock);
50  $extensionStorage = $this->downloadQueueMock->_get('extensionStorage');
51 
52  $this->assertArrayHasKey('foobar', $extensionStorage['download']);
53  }
54 
60  $this->downloadQueueMock->addExtensionToQueue($this->extensionMock, 'update');
61  $extensionStorage = $this->downloadQueueMock->_get('extensionStorage');
62 
63  $this->assertArrayHasKey('foobar', $extensionStorage['update']);
64  }
65 
72  $this->downloadQueueMock->addExtensionToQueue($this->extensionMock, 'unknownStack');
73  }
74 
81  public function addExtensionToQueueThrowsExceptionIfExtensionWithSameKeyAndDifferentValuesAlreadyExists() {
83  $extensionMock2 = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension', array('dummy'));
84  $extensionMock2->setExtensionKey('foobar');
85  $extensionMock2->setVersion('1.0.3');
86 
87  $this->downloadQueueMock->addExtensionToQueue($extensionMock2);
88  $this->downloadQueueMock->addExtensionToQueue($this->extensionMock);
89  }
90 
96  $extensionMock2 = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension', array('dummy'));
97  $extensionMock2->_set('extensionKey', 'foobarbaz');
98  $extensionMock2->_set('version', '1.0.3');
99  $this->downloadQueueMock->_set('extensionStorage', array(
100  'download' => array(
101  'foobar' => $this->extensionMock,
102  'foobarbaz' => $extensionMock2
103  )
104  ));
105  $extensionStorageBefore = $this->downloadQueueMock->_get('extensionStorage');
106 
107  $this->assertTrue(array_key_exists('foobar', $extensionStorageBefore['download']));
108 
109  $this->downloadQueueMock->removeExtensionFromQueue($this->extensionMock);
110  $extensionStorageAfter = $this->downloadQueueMock->_get('extensionStorage');
111 
112  $this->assertFalse(array_key_exists('foobar', $extensionStorageAfter['download']));
113  }
114 
115 }
getAccessibleMock( $originalClassName, array $methods=array(), array $arguments=array(), $mockClassName='', $callOriginalConstructor=TRUE, $callOriginalClone=TRUE, $callAutoload=TRUE)