Code Duplication    Length = 24-24 lines in 2 locations

tests/CSVBulkLoaderTest.php 2 locations

@@ 89-112 (lines=24) @@
86
    /**
87
     * Does the importer fail on a duplicate column?
88
     */
89
    public function testDuplicateColumn()
90
    {
91
        // Remove any existing records
92
        Player::get()->removeAll();
93
94
        $loader = new CsvBulkLoader(Player::class);
95
        $filepath = $this->csvPath . 'PlayerDuplicate.csv';
96
        $file = fopen($filepath, 'r');
97
        $results = $loader->load($filepath);
98
99
        $this->assertEquals(
100
            1,
101
            $results->ErrorCount(),
102
            'Test error count on duplicates'
103
        );
104
105
        $obj = DataObject::get_one(
106
            Player::class,
107
            [ "FirstName" => 'John' ]
108
        );
109
110
        $this->assertNull($obj);
111
        fclose($file);
112
    }
113
114
    /**
115
     * Does the importer fail on a duplicate column
@@ 117-140 (lines=24) @@
114
    /**
115
     * Does the importer fail on a duplicate column
116
     */
117
    public function testMissingRequired()
118
    {
119
        // Remove any existing records
120
        Player::get()->removeAll();
121
122
        $loader = new CsvBulkLoader(Player::class);
123
        $filepath = $this->csvPath . 'PlayerMissingRequired.csv';
124
        $file = fopen($filepath, 'r');
125
        $results = $loader->load($filepath);
126
127
        $this->assertEquals(
128
            1,
129
            $results->ErrorCount(),
130
            'Test errors generated when required fields missing'
131
        );
132
133
        $obj = DataObject::get_one(
134
            Player::class,
135
            ["FirstName" => 'Jane']
136
        );
137
138
        $this->assertNull($obj);
139
        fclose($file);
140
    }
141
}
142