Conditions | 1 |
Paths | 1 |
Total Lines | 64 |
Code Lines | 50 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
20 | public function testGettersSetters() |
||
21 | { |
||
22 | $stockMovement = $this->getMockForAbstractClass(StockMovement::class); |
||
23 | |||
24 | $product = new Product(); |
||
25 | $orderLine = new OrderLine(); |
||
26 | |||
27 | $qty = -3; |
||
28 | $retailPrice = new Money(10396, new Currency('DKK')); |
||
29 | $totalRetailPrice = new Money(31188, new Currency('DKK')); |
||
30 | $price = new Money(7999, new Currency('DKK')); |
||
31 | $totalPrice = new Money(23997, new Currency('DKK')); |
||
32 | $discount = new Money(2397, new Currency('DKK')); |
||
33 | $totalDiscount = new Money(7191, new Currency('DKK')); |
||
34 | |||
35 | // with vat |
||
36 | $retailPriceInclVat = new Money(12995, new Currency('DKK')); |
||
37 | $totalRetailPriceInclVat = new Money(38985, new Currency('DKK')); |
||
38 | $priceInclVat = new Money(9999, new Currency('DKK')); |
||
39 | $totalPriceInclVat = new Money(29996, new Currency('DKK')); |
||
40 | $discountInclVat = new Money(2996, new Currency('DKK')); |
||
41 | $totalDiscountInclVat = new Money(8989, new Currency('DKK')); |
||
42 | |||
43 | $stockMovement |
||
44 | ->setId(1) |
||
45 | ->setQuantity($qty) |
||
46 | ->setRetailPrice($retailPrice) |
||
47 | ->setPrice($price) |
||
48 | ->setType(StockMovement::TYPE_SALE) |
||
49 | ->setReference('order') |
||
50 | ->setComplaint(false) |
||
51 | ->setVatPercentage(25.0) |
||
52 | ->setOrderLine($orderLine) |
||
53 | ->setProduct($product) |
||
54 | ; |
||
55 | |||
56 | $stockMovement->validate(); |
||
57 | |||
58 | $this->assertSame(1, $stockMovement->getId()); |
||
59 | $this->assertSame($qty, $stockMovement->getQuantity()); |
||
60 | $this->assertSame('DKK', $stockMovement->getCurrency()); |
||
61 | $this->assertSame(StockMovement::TYPE_SALE, $stockMovement->getType()); |
||
62 | $this->assertSame('order', $stockMovement->getReference()); |
||
63 | $this->assertFalse($stockMovement->isComplaint()); |
||
64 | $this->assertSame(25.0, $stockMovement->getVatPercentage()); |
||
65 | $this->assertSame($product, $stockMovement->getProduct()); |
||
66 | $this->assertSame($orderLine, $stockMovement->getOrderLine()); |
||
67 | |||
68 | // test prices excl vat |
||
69 | $this->assertEquals($retailPrice, $stockMovement->getRetailPrice()); |
||
70 | $this->assertEquals($totalRetailPrice, $stockMovement->getTotalRetailPrice()); |
||
71 | $this->assertEquals($price, $stockMovement->getPrice()); |
||
72 | $this->assertEquals($totalPrice, $stockMovement->getTotalPrice()); |
||
73 | $this->assertEquals($discount, $stockMovement->getDiscount()); |
||
74 | $this->assertEquals($totalDiscount, $stockMovement->getTotalDiscount()); |
||
75 | |||
76 | // test prices incl vat |
||
77 | $this->assertEquals($retailPriceInclVat, $stockMovement->getRetailPriceInclVat()); |
||
78 | $this->assertEquals($totalRetailPriceInclVat, $stockMovement->getTotalRetailPriceInclVat()); |
||
79 | $this->assertEquals($priceInclVat, $stockMovement->getPriceInclVat()); |
||
80 | $this->assertEquals($totalPriceInclVat, $stockMovement->getTotalPriceInclVat()); |
||
81 | $this->assertEquals($discountInclVat, $stockMovement->getDiscountInclVat()); |
||
82 | $this->assertEquals($totalDiscountInclVat, $stockMovement->getTotalDiscountInclVat()); |
||
83 | } |
||
84 | |||
168 |