Completed
Pull Request — master (#287)
by Nic
07:49
created

ShippableProductTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 4
dl 0
loc 31
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testProductWeightValidation() 0 20 1
1
<?php
2
3
/**
4
 * Class ProductHolderTest
5
 */
6
class ShippableProductTest extends SapphireTest
7
{
8
    /**
9
     * @var string
10
     */
11
    protected static $fixture_file = 'foxystripe/tests/FoxyStripeTest.yml';
12
13
    /**
14
     * Test the {@link ShippableProduct::validate()} validation is working properly
15
     */
16
    public function testProductWeightValidation()
17
    {
18
19
        $product = $this->objFromFixture('ShippableProduct', 'product1');
20
21
        $product->Weight = -5.6;
22
        $this->setExpectedException('ValidationException');
0 ignored issues
show
Bug introduced by
The method setExpectedException() does not seem to exist on object<ShippableProductTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
23
        $product->write();
24
25
        $product->Weight = 0;
26
        $this->setExpectedException('ValidationException');
0 ignored issues
show
Bug introduced by
The method setExpectedException() does not seem to exist on object<ShippableProductTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
27
        $product->write();
28
29
        $product->Weight = 10.5;
30
        $product->write();
31
32
        $productCheck = ShippableProduct::get()->byID($product->ID);
33
        $this->assertEquals($productCheck->Weight, 10.5);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ShippableProductTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
34
35
    }
36
}