BxDolStudioStoreTest.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. class BxDolStudioStoreTestProxy extends BxTemplStudioStore
  3. {
  4. private $aRemoteProduct;
  5. private $aLocalProduct;
  6. public function __construct($mixedRemoteProduct, array $aLocalProduct)
  7. {
  8. $this->aRemoteProduct = $mixedRemoteProduct;
  9. $this->aLocalProduct = $aLocalProduct;
  10. }
  11. public function getProductResult($sModuleName)
  12. {
  13. return $this->getProduct($sModuleName);
  14. }
  15. protected function loadProduct($sModuleName)
  16. {
  17. return $this->aRemoteProduct;
  18. }
  19. protected function loadLocalProduct($sModuleName)
  20. {
  21. return $this->aLocalProduct;
  22. }
  23. }
  24. class BxDolStudioStoreTest extends BxDolTestCase
  25. {
  26. public function testDownloadedModuleMetadataBacksProductPopupWhenMarketLookupFails()
  27. {
  28. $oStore = new BxDolStudioStoreTestProxy(array(), array(
  29. 'name' => 'my_una_module_doctor',
  30. 'title' => 'My UNA Module Doctor',
  31. 'vendor' => 'My UNA World',
  32. 'version' => '0.1.1',
  33. 'note' => 'Studio-only compatibility and repair tooling.',
  34. ));
  35. $aResult = $oStore->getProductResult('my_una_module_doctor');
  36. $this->assertSame(BX_DOL_STUDIO_IU_RC_SUCCESS, $aResult['code']);
  37. $this->assertSame(0, $aResult['screenshots']);
  38. $this->assertStringContainsString('My UNA Module Doctor', $aResult['popup']);
  39. $this->assertStringContainsString('My UNA World', $aResult['popup']);
  40. $this->assertStringContainsString('0.1.1', $aResult['popup']);
  41. $this->assertStringContainsString(
  42. 'Studio-only compatibility and repair tooling.',
  43. $aResult['popup']
  44. );
  45. }
  46. public function testMarketTransportFailureIsNotHiddenByLocalMetadata()
  47. {
  48. $oStore = new BxDolStudioStoreTestProxy(false, array(
  49. 'name' => 'my_una_module_doctor',
  50. 'title' => 'My UNA Module Doctor',
  51. 'vendor' => 'My UNA World',
  52. 'version' => '0.1.1',
  53. 'note' => 'Studio-only compatibility and repair tooling.',
  54. ));
  55. $aResult = $oStore->getProductResult('my_una_module_doctor');
  56. $this->assertSame(BX_DOL_STUDIO_IU_RC_FAILED, $aResult['code']);
  57. $this->assertArrayNotHasKey('popup', $aResult);
  58. }
  59. public function testMissingMarketAndLocalMetadataKeepsNoProductError()
  60. {
  61. $oStore = new BxDolStudioStoreTestProxy(array(), array());
  62. $aResult = $oStore->getProductResult('missing_module');
  63. $this->assertSame(BX_DOL_STUDIO_IU_RC_FAILED, $aResult['code']);
  64. $this->assertArrayNotHasKey('popup', $aResult);
  65. }
  66. }