backend/tests/Feature/SitemapTest.php
/**
     * Test existence and validity of XML file.
     *
     * @return void
     */
Test existence and validity of XML file.
@return void
Test existence and validity of XML file . @return void
public function testFile()
    {
        factory(User::class, 30)
            ->create()
            ->each(function ($user) {
                foreach (range(0, 10) as $i) {
                    $user->books()->save(factory(Book::class)->make());
                }
            });
        Artisan::call('sitemap:create');
        $this->assertTrue(Storage::exists('sitemap.xml'));
        $content = Storage::get('sitemap.xml');
        $this->assertFalse(trim($content) == '');
        libxml_use_internal_errors(true);
        $doc = new DOMDocument('1.0', 'UTF-8');
        $doc->loadXML($content);
        $errors = libxml_get_errors();
        libxml_clear_errors();
        $this->assertTrue(empty($errors));
    }
public function testFile ( ) { factory ( User :: class , 30 ) -> create ( ) -> each ( function ( $ user ) { foreach ( range ( 0 , 10 ) as $ i ) { $ user -> books ( ) -> save ( factory ( Book :: class ) -> make ( ) ) ; } } ) ; Artisan :: call ( 'sitemap:create' ) ; $ this -> assertTrue ( Storage :: exists ( 'sitemap.xml' ) ) ; $ content = Storage :: get ( 'sitemap.xml' ) ; $ this -> assertFalse ( trim ( $ content ) == '' ) ; libxml_use_internal_errors ( true ) ; $ doc = new DOMDocument ( '1.0' , 'UTF-8' ) ; $ doc -> loadXML ( $ content ) ; $ errors = libxml_get_errors ( ) ; libxml_clear_errors ( ) ; $ this -> assertTrue ( empty ( $ errors ) ) ; }
Test existence and validity of XML file.
Test existence and validity of XML file .
// Create entries // Test if file created // Test if file is not empty // Test if file is a valid XML file