Skip to content
Snippets Groups Projects

Added Interface and Mock classes, Unit Test

This takes advantage of the interfaces to put into place a mock and a soap implementation and unit tests for Product and ProductService

Please review: @ahoffmann @npblair @weizhong-wang

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
16 16 },
17 17
18 18 "require": {
19 "php": "^5.3.0",
19 "php": "^5.3.0"
  • 45 46 * Call getPresentTerm, confirm successful response.
    46 47 */
    47 48 public function testGetPresentTerm() {
  • Andrew Lundholm Added 1 commit:

    Added 1 commit:

    • cb405194 - Mock Testing with fix for constructors, general code reformatting
  • 1 <?php
    2 /**
    3 * Created by alundholm
    4 */
    5
    6 namespace edu\wisc\services\cbs;
    7
    8
    9 class SoapTechstoreClient implements ProductService
  • 13 private $doitSoaItemService;
    14
    15 /**
    16 * SoapTechstoreClient constructor.
    17 * @param $username
    18 * @param $password
    19 * @internal param DOIT_SOA_ITEM_Service $doitSoaItemService
    20 */
    21 public function __construct($username, $password)
    22 {
    23 $serviceFactory = new DOIT_SOA_ITEM_ServiceFactory();
    24 $this->doitSoaItemService = $serviceFactory->getInstance($username, $password);
    25 }
    26
    27
    28 /**
  • 14 {
    15 $product = new Product("4229", "Test Mouse", "Test mouse used for clicking", "19.95");
    16
    17 $client = new MockTechstoreCbsClient();
    18 $result = $client->createProduct($product);
    19
    20
    21 $this->assertInstanceOf(Product::class, $result);
    22 $this->assertTrue($result->getItemNumber() == "4229");
    23 $this->assertTrue($result->getName() == "Test Mouse");
    24 $this->assertTrue($result->getCost() == "19.95");
    25 $this->assertTrue($result->getDescription() == "Test mouse used for clicking");
    26 }
    27
    28 /**
    29 * @expectedException edu\wisc\services\cbs\MockCbsClientException
  • Andrew Lundholm Added 1 commit:

    Added 1 commit:

    • b031ff6b - Correct Phpdoc formatting and Type Hinting
  • booya

  • Andrew Hoffmann Status changed to merged

    Status changed to merged

  • Andrew Hoffmann mentioned in commit 617a3419

    mentioned in commit 617a3419

  • Please register or sign in to reply
    Loading